| Title: | Wavelet Quantile Regression Toolbox |
|---|---|
| Description: | A comprehensive toolbox for wavelet-domain quantile analyses of bivariate and multivariate time series. Provides Wavelet Quantile Regression and Multivariate Wavelet Quantile Regression after Adebayo and Ozkan (2024) <doi:10.1016/j.jclepro.2024.140832>, Wavelet Quantile-on-Quantile regression with bootstrap p-values extending Sim and Zhou (2015) <doi:10.1016/j.jbankfin.2015.01.013>, the nonparametric Causality-in-Quantiles test of Balcilar, Gupta and Pierdzioch (2016) <doi:10.1016/j.resourpol.2016.04.004> together with its wavelet variant, Wavelet Quantile Mediation and Moderation, Wavelet Quantile Correlation, and a wavelet-based nonparametric Quantile Density estimator. The Maximal Overlap Discrete Wavelet Transform (MODWT) decomposition is performed via 'waveslim' and Short / Medium / Long band aggregation is supported throughout. For plain Quantile-on-Quantile regression see the companion CRAN package 'QuantileOnQuantile'. All interactive 3D surfaces, heatmaps and contour plots default to the 'MATLAB' 'Parula' colour map. |
| Authors: | Merwan Roudane [aut, cre, cph], Nicholas Sim [ctb] (Original Quantile-on-Quantile methodology), Hongtao Zhou [ctb] (Original Quantile-on-Quantile methodology), Tomiwa Sunday Adebayo [ctb] (Wavelet Quantile Regression methodology), Mehmet Balcilar [ctb] (Nonparametric quantile causality methodology) |
| Maintainer: | Merwan Roudane <[email protected]> |
| License: | GPL-3 |
| Version: | 1.0.0 |
| Built: | 2026-06-09 11:11:58 UTC |
| Source: | https://github.com/merwanroudane/wqrr |
Eight wavelet-quantile estimators in one consistent interface: Wavelet Quantile Regression, Multivariate WQR, Wavelet Quantile-on-Quantile Regression with p-values, nonparametric Causality-in-Quantiles and its wavelet variant, Wavelet Quantile Mediation and Moderation, Wavelet Quantile Correlation, and a wavelet nonparametric Quantile Density estimator.
wavelet_qr - Wavelet Quantile Regression.
multivariate_wqr - Multivariate WQR.
wavelet_qqr - Wavelet QQR with p-values.
np_quantile_causality - Causality-in-Quantiles.
wavelet_np_causality - Wavelet variant.
wavelet_mediation - Mediation / moderation.
wavelet_quantile_correlation - WQC.
wavelet_quantile_density - Quantile density.
parula_colors, wqrr_colorscales -
MATLAB-style colour palettes.
For plain Quantile-on-Quantile regression see the companion CRAN
package QuantileOnQuantile.
Dr Merwan Roudane [email protected]
GitHub: https://github.com/merwanroudane/wqrr
Maximal Overlap Discrete Wavelet Transform (MODWT) MRA via
waveslim::mra, plus a helper to combine details into Short /
Medium / Long bands.
modwt_mra(x, wavelet = "la8", level = NULL, boundary = "periodic") aggregate_bands(details, band_spec = NULL)modwt_mra(x, wavelet = "la8", level = NULL, boundary = "periodic") aggregate_bands(details, band_spec = NULL)
x |
Numeric vector. |
wavelet |
Wavelet filter (e.g. |
level |
Integer or |
boundary |
|
details |
List of detail series from |
band_spec |
Named list of integer index vectors. |
For modwt_mra: a list with elements details and
smooth. For aggregate_bands: a named list of aggregated
band series.
set.seed(1); x <- cumsum(rnorm(128)) dec <- modwt_mra(x, "la8", level = 4) bands <- aggregate_bands(dec$details) sapply(bands, length)set.seed(1); x <- cumsum(rnorm(128)) dec <- modwt_mra(x, "la8", level = 4) bands <- aggregate_bands(dec$details) sapply(bands, length)
MWQR aggregates MODWT details into Short / Medium / Long bands and runs a multiple quantile regression of y_b on all regressors at each quantile within each band.
multivariate_wqr(y, X_list, quantiles = c(0.05, 0.10, 0.25, 0.50, 0.75, 0.90, 0.95), wavelet = "la8", J = 5, bands = TRUE, dep_name = "Y", verbose = TRUE)multivariate_wqr(y, X_list, quantiles = c(0.05, 0.10, 0.25, 0.50, 0.75, 0.90, 0.95), wavelet = "la8", J = 5, bands = TRUE, dep_name = "Y", verbose = TRUE)
y |
Numeric response. |
X_list |
Named list of numeric regressors. |
quantiles |
Numeric vector of tau in (0, 1). |
wavelet, J, bands, verbose
|
See |
dep_name |
Character label for the dependent variable. |
An object of class "mwqr_result".
set.seed(1); n <- 200 x1 <- cumsum(rnorm(n)); x2 <- cumsum(rnorm(n)) y <- 0.4 * x1 - 0.2 * x2 + rnorm(n, sd = 0.5) fit <- multivariate_wqr(y, list(X1 = x1, X2 = x2), quantiles = c(0.25, 0.5, 0.75), wavelet = "la8", J = 4, verbose = FALSE)set.seed(1); n <- 200 x1 <- cumsum(rnorm(n)); x2 <- cumsum(rnorm(n)) y <- 0.4 * x1 - 0.2 * x2 + rnorm(n, sd = 0.5) fit <- multivariate_wqr(y, list(X1 = x1, X2 = x2), quantiles = c(0.25, 0.5, 0.75), wavelet = "la8", J = 4, verbose = FALSE)
Nonparametric quantile Granger-causality test. Standard critical values are 1.96 (5%) and 1.645 (10%).
np_quantile_causality(x, y, test_type = c("mean", "variance"), q = seq(0.05, 0.95, by = 0.05), bandwidth = NULL) wavelet_np_causality(x, y, test_type = c("mean", "variance"), q = seq(0.05, 0.95, by = 0.05), wavelet = "la8", J = 5, bands = TRUE, bandwidth = NULL, verbose = TRUE)np_quantile_causality(x, y, test_type = c("mean", "variance"), q = seq(0.05, 0.95, by = 0.05), bandwidth = NULL) wavelet_np_causality(x, y, test_type = c("mean", "variance"), q = seq(0.05, 0.95, by = 0.05), wavelet = "la8", J = 5, bands = TRUE, bandwidth = NULL, verbose = TRUE)
x, y
|
Numeric vectors of equal length. |
test_type |
|
q |
Numeric vector of tau in (0, 1). |
bandwidth |
Numeric or |
wavelet, J, bands, verbose
|
See |
An object of class "causality_result" or
"wavelet_causality_result".
Balcilar, M., Gupta, R., Pierdzioch, C. (2016). <doi:10.1016/j.resourpol.2016.04.004>.
set.seed(1); n <- 200 x <- rnorm(n); y <- 0.3 * c(0, x[-n]) + rnorm(n, sd = 0.5) fit <- np_quantile_causality(x, y, q = c(0.25, 0.5, 0.75))set.seed(1); n <- 200 x <- rnorm(n); y <- 0.3 * c(0, x[-n]) + rnorm(n, sd = 0.5) fit <- np_quantile_causality(x, y, q = c(0.25, 0.5, 0.75))
Colour palettes used by wqrr plots, with MATLAB Parula as the default. The Parula stops are reproduced exactly from MathWorks' 64 RGB values.
parula_colors(n = 256) matlab_jet_colors(n = 256) turbo_colors(n = 256) bluered_colors(n = 256) sinha_colors(n = 256) green_orange_red_colors(n = 256) green_yellow_red_colors(n = 256) wqrr_palette(cols, n_breaks = 32) resolve_colorscale(name = "Parula", n_breaks = 32) wqrr_colorscales(show_preview = TRUE)parula_colors(n = 256) matlab_jet_colors(n = 256) turbo_colors(n = 256) bluered_colors(n = 256) sinha_colors(n = 256) green_orange_red_colors(n = 256) green_yellow_red_colors(n = 256) wqrr_palette(cols, n_breaks = 32) resolve_colorscale(name = "Parula", n_breaks = 32) wqrr_colorscales(show_preview = TRUE)
n |
Number of interpolated colours. |
cols |
Character vector of hex colours. |
n_breaks |
Stops for the plotly list. |
name |
Scale name (Parula by default). |
show_preview |
Print descriptions. |
Character vector or plotly colorscale list, depending on the function.
parula_colors(8) wqrr_colorscales(show_preview = FALSE)parula_colors(8) wqrr_colorscales(show_preview = FALSE)
Interactive 3D surfaces, heatmaps and contour plots for
all wqrr estimators. All default to the MATLAB 'Parula' colour map
(see parula_colors and wqrr_colorscales).
plot_qq_3d(qq_result, value = "coefficient", colorscale = "Parula", show_contour = TRUE, x_label = "X Quantile (tau)", y_label = "Y Quantile (theta)", title = NULL) plot_qq_heatmap(qq_result, value = "coefficient", colorscale = "Parula", show_stars = FALSE, x_label = "X Quantile (tau)", y_label = "Y Quantile (theta)", title = NULL) plot_qq_contour(qq_result, value = "coefficient", colorscale = "Parula", x_label = "X Quantile (tau)", y_label = "Y Quantile (theta)", title = NULL) plot_wqr_heatmap(wqr_result, value = "beta", colorscale = "GreenOrangeRed", title = "Wavelet Quantile Regression", x_label = "Quantiles", y_label = "Time Horizons") plot_wqqr_surface(wqqr_result, colorscale = "Parula", title = NULL) plot_wqqr_pvalue_heatmap(wqqr_result, alpha = 0.05, colorscale = "Sinha", title = NULL) plot_wqr_vs_wqqr(wqqr_result, ...) plot_causality(causality_result, cv = 1.96, title = NULL) plot_wavelet_causality(wcr, colorscale = "GreenOrangeRed", title = NULL) plot_correlation_heatmap(x, y, quantiles = seq(0.1, 0.9, by = 0.1), colorscale = "RdBu", title = "Quantile Correlation Heatmap") plot_wqc_heatmap(wqc_result, colorscale = "Parula", title = "Wavelet Quantile Correlation") plot_quantile_density(qd_result, ...) plot_mediation_panel(med_result, colorscale = "GreenYellowRed")plot_qq_3d(qq_result, value = "coefficient", colorscale = "Parula", show_contour = TRUE, x_label = "X Quantile (tau)", y_label = "Y Quantile (theta)", title = NULL) plot_qq_heatmap(qq_result, value = "coefficient", colorscale = "Parula", show_stars = FALSE, x_label = "X Quantile (tau)", y_label = "Y Quantile (theta)", title = NULL) plot_qq_contour(qq_result, value = "coefficient", colorscale = "Parula", x_label = "X Quantile (tau)", y_label = "Y Quantile (theta)", title = NULL) plot_wqr_heatmap(wqr_result, value = "beta", colorscale = "GreenOrangeRed", title = "Wavelet Quantile Regression", x_label = "Quantiles", y_label = "Time Horizons") plot_wqqr_surface(wqqr_result, colorscale = "Parula", title = NULL) plot_wqqr_pvalue_heatmap(wqqr_result, alpha = 0.05, colorscale = "Sinha", title = NULL) plot_wqr_vs_wqqr(wqqr_result, ...) plot_causality(causality_result, cv = 1.96, title = NULL) plot_wavelet_causality(wcr, colorscale = "GreenOrangeRed", title = NULL) plot_correlation_heatmap(x, y, quantiles = seq(0.1, 0.9, by = 0.1), colorscale = "RdBu", title = "Quantile Correlation Heatmap") plot_wqc_heatmap(wqc_result, colorscale = "Parula", title = "Wavelet Quantile Correlation") plot_quantile_density(qd_result, ...) plot_mediation_panel(med_result, colorscale = "GreenYellowRed")
qq_result, wqr_result, wqqr_result, causality_result, wcr, wqc_result, qd_result, med_result
|
Result objects from the respective estimators. |
x, y, quantiles
|
Inputs for |
value, colorscale, title, x_label, y_label, alpha, cv, show_contour, show_stars, ...
|
Plot options. |
A plotly object (or a named list of plotly objects for
plot_mediation_panel).
set.seed(1); n <- 128 x <- cumsum(rnorm(n)); y <- 0.5 * x + rnorm(n, sd = 0.5) fit <- wavelet_qr(y, x, quantiles = c(0.25, 0.5, 0.75), wavelet = "la8", J = 4, verbose = FALSE) p <- plot_wqr_heatmap(fit, colorscale = "Parula")set.seed(1); n <- 128 x <- cumsum(rnorm(n)); y <- 0.5 * x + rnorm(n, sd = 0.5) fit <- wavelet_qr(y, x, quantiles = c(0.25, 0.5, 0.75), wavelet = "la8", J = 4, verbose = FALSE) p <- plot_wqr_heatmap(fit, colorscale = "Parula")
Convenience formatter to insert WQR / MWQR / mediation slope coefficients into a paper-style table.
results_table(x, value = "beta", digits = 3, row = "level", variable = NULL)results_table(x, value = "beta", digits = 3, row = "level", variable = NULL)
x |
A data frame, or a |
value |
Column to format. Default |
digits |
Rounding digits. |
row |
Pivot row column name ( |
variable |
Optional filter for MWQR results. |
Character data frame with rows = bands and columns = quantiles.
Entries look like "0.345**" (stars for 1% / 5% / 10%).
set.seed(1); n <- 128 x <- cumsum(rnorm(n)); y <- 0.5 * x + rnorm(n, sd = 0.5) fit <- wavelet_qr(y, x, quantiles = c(0.25, 0.5, 0.75), wavelet = "la8", J = 4, verbose = FALSE) results_table(fit)set.seed(1); n <- 128 x <- cumsum(rnorm(n)); y <- 0.5 * x + rnorm(n, sd = 0.5) fit <- wavelet_qr(y, x, quantiles = c(0.25, 0.5, 0.75), wavelet = "la8", J = 4, verbose = FALSE) results_table(fit)
Five wavelet-band quantile regressions for the triplet (y, x, z): direct effect, x*z moderation (interaction), path a (x -> z), path b (z -> y | x), indirect (a * b).
wavelet_mediation(y, x, z, quantiles = c(0.05, 0.10, 0.25, 0.50, 0.75, 0.90, 0.95), wavelet = "la8", J = NULL, dep_name = "Y", main_name = "X", mod_name = "Z", verbose = TRUE)wavelet_mediation(y, x, z, quantiles = c(0.05, 0.10, 0.25, 0.50, 0.75, 0.90, 0.95), wavelet = "la8", J = NULL, dep_name = "Y", main_name = "X", mod_name = "Z", verbose = TRUE)
y, x, z
|
Numeric vectors of equal length. |
quantiles |
Numeric vector of tau in (0, 1). |
wavelet |
Wavelet filter. |
J |
Decomposition depth or |
dep_name, main_name, mod_name
|
Character labels for printing. |
verbose |
Logical. |
An object of class "mediation_result" containing five
data frames: direct, interaction, path_a,
path_b, indirect.
set.seed(1); n <- 200 x <- rnorm(n); z <- 0.4 * x + rnorm(n, sd = 0.5) y <- 0.3 * x + 0.4 * z + rnorm(n, sd = 0.5) fit <- wavelet_mediation(y, x, z, quantiles = c(0.25, 0.5, 0.75), wavelet = "la8", J = 4, verbose = FALSE)set.seed(1); n <- 200 x <- rnorm(n); z <- 0.4 * x + rnorm(n, sd = 0.5) y <- 0.3 * x + 0.4 * z + rnorm(n, sd = 0.5) fit <- wavelet_mediation(y, x, z, quantiles = c(0.25, 0.5, 0.75), wavelet = "la8", J = 4, verbose = FALSE)
For a selected MODWT frequency band, builds the (theta, tau) coefficient and p-value surface of a kernel-weighted local linear quantile regression of y_b on x_b. Also returns the standard band-level WQR slopes for comparison.
wavelet_qqr(y, x, quantile_step = 0.05, wavelet = "la8", J = 5, band = "long", bandwidth = 1.0, verbose = TRUE)wavelet_qqr(y, x, quantile_step = 0.05, wavelet = "la8", J = 5, band = "long", bandwidth = 1.0, verbose = TRUE)
y, x
|
Numeric vectors of equal length. |
quantile_step |
Step of the tau-grid. |
wavelet, J, verbose
|
See |
band |
One of |
bandwidth |
Gaussian-kernel bandwidth for the local linear QR. |
An object of class "wqqr_result" with coefficient matrix,
p-value matrix, the standard WQR slopes (qr_coef) and their
p-values.
set.seed(1); n <- 128 x <- cumsum(rnorm(n)); y <- 0.4 * x + rnorm(n, sd = 0.5) fit <- wavelet_qqr(y, x, quantile_step = 0.25, wavelet = "la8", J = 4, band = "long", verbose = FALSE)set.seed(1); n <- 128 x <- cumsum(rnorm(n)); y <- 0.4 * x + rnorm(n, sd = 0.5) fit <- wavelet_qqr(y, x, quantile_step = 0.25, wavelet = "la8", J = 4, band = "long", verbose = FALSE)
Decompose y and x by MODWT, then run quantile regression of y_b on x_b at each quantile in each band b.
wavelet_qr(y, x, quantiles = seq(0.05, 0.95, by = 0.05), wavelet = "la8", J = 5, bands = TRUE, verbose = TRUE) wqr_to_matrix(wqr, value = "beta")wavelet_qr(y, x, quantiles = seq(0.05, 0.95, by = 0.05), wavelet = "la8", J = 5, bands = TRUE, verbose = TRUE) wqr_to_matrix(wqr, value = "beta")
y, x
|
Numeric vectors of equal length. |
quantiles |
Numeric vector of tau in (0, 1). |
wavelet |
Wavelet filter; e.g. "la8" (sym4), "la16" (sym8), "d4" (db2), "haar". |
J |
Decomposition depth. |
bands |
Logical. |
verbose |
Logical. |
wqr |
A |
value |
Column to pivot: |
An object of class "wqr_result" (or numeric matrix).
Adebayo, T.S., Ozkan, O. (2024) <doi:10.1016/j.jclepro.2024.140832>.
set.seed(1); n <- 128 x <- cumsum(rnorm(n)); y <- 0.5 * x + rnorm(n, sd = 0.5) fit <- wavelet_qr(y, x, quantiles = c(0.25, 0.5, 0.75), wavelet = "la8", J = 4, verbose = FALSE) wqr_to_matrix(fit)set.seed(1); n <- 128 x <- cumsum(rnorm(n)); y <- 0.5 * x + rnorm(n, sd = 0.5) fit <- wavelet_qr(y, x, quantiles = c(0.25, 0.5, 0.75), wavelet = "la8", J = 4, verbose = FALSE) wqr_to_matrix(fit)
Quantile correlation between MODWT detail series of two time series, with parametric-bootstrap 95% confidence intervals.
wavelet_quantile_correlation(x, y, quantiles = c(0.05, 0.25, 0.50, 0.75, 0.95), wavelet = "la8", J = 8, n_sim = 200, verbose = TRUE)wavelet_quantile_correlation(x, y, quantiles = c(0.05, 0.25, 0.50, 0.75, 0.95), wavelet = "la8", J = 8, n_sim = 200, verbose = TRUE)
x, y
|
Numeric vectors of equal length. |
quantiles |
Numeric vector of tau in (0, 1). |
wavelet, J, verbose
|
See |
n_sim |
Bootstrap replicates for the 95% confidence intervals. |
An object of class "wqc_result".
set.seed(1); n <- 256 x <- cumsum(rnorm(n)); y <- 0.4 * x + rnorm(n, sd = 0.5) fit <- wavelet_quantile_correlation( x, y, quantiles = c(0.25, 0.5, 0.75), J = 4, n_sim = 20, verbose = FALSE)set.seed(1); n <- 256 x <- cumsum(rnorm(n)); y <- 0.4 * x + rnorm(n, sd = 0.5) fit <- wavelet_quantile_correlation( x, y, quantiles = c(0.25, 0.5, 0.75), J = 4, n_sim = 20, verbose = FALSE)
Three nonparametric estimators of the quantile density q(p) = 1 / f(F^-1(p)): linear wavelet, hard-thresholded, and local-linear smoothed.
wavelet_quantile_density(y, j0 = 5, bandwidth = 0.15, wavelet = "haar", gld_params = NULL)wavelet_quantile_density(y, j0 = 5, bandwidth = 0.15, wavelet = "haar", gld_params = NULL)
y |
Numeric sample. |
j0 |
Coarsest decomposition level. Default 5. |
bandwidth |
Gaussian-kernel bandwidth for local linear smoothing. |
wavelet |
Wavelet filter for the thresholding step. |
gld_params |
Length-4 |
An object of class "quantile_density_result".
set.seed(1); y <- rnorm(256) qd <- wavelet_quantile_density(y, j0 = 4)set.seed(1); y <- rnorm(256) qd <- wavelet_quantile_density(y, j0 = 4)