## ----setup, include = FALSE--------------------------------------------------- knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.width = 7.5, fig.height = 4.8, message = FALSE, warning = FALSE ) ## ----------------------------------------------------------------------------- library(wqrr) ## ----------------------------------------------------------------------------- dat <- read.csv(system.file("extdata", "wqrr_data.csv", package = "wqrr")) str(dat) head(dat) ## ----------------------------------------------------------------------------- dat <- tail(dat, 192) ## ----------------------------------------------------------------------------- wqr_fit <- wavelet_qr( y = dat$sp500_return, x = dat$oil_return, quantiles = seq(0.1, 0.9, by = 0.1), wavelet = "la8", J = 5, verbose = FALSE ) print(wqr_fit) ## ----------------------------------------------------------------------------- wqr_to_matrix(wqr_fit) ## ----eval = FALSE------------------------------------------------------------- # plot_wqr_heatmap(wqr_fit, colorscale = "Parula") ## ----eval = FALSE------------------------------------------------------------- # plot(wqr_fit) ## ----------------------------------------------------------------------------- results_table(wqr_fit, digits = 3) ## ----------------------------------------------------------------------------- mwqr_fit <- multivariate_wqr( y = dat$sp500_return, X_list = list(oil = dat$oil_return, epu = dat$epu), quantiles = c(0.10, 0.25, 0.50, 0.75, 0.90), wavelet = "la8", J = 5, verbose = FALSE ) print(mwqr_fit) ## ----eval = FALSE------------------------------------------------------------- # plot(mwqr_fit, variable = "oil", colorscale = "Parula") ## ----------------------------------------------------------------------------- wqqr_fit <- wavelet_qqr( y = dat$sp500_return, x = dat$oil_return, quantile_step = 0.10, wavelet = "la8", J = 5, band = "long", verbose = FALSE ) print(wqqr_fit) ## ----eval = FALSE------------------------------------------------------------- # plot(wqqr_fit, type = "3d", colorscale = "Parula") # plot(wqqr_fit, type = "pvalue") # plot(wqqr_fit, type = "compare") ## ----------------------------------------------------------------------------- cause_fit <- np_quantile_causality( x = dat$oil_return, y = dat$sp500_return, test_type = "mean", q = seq(0.1, 0.9, by = 0.1) ) print(cause_fit) ## ----eval = FALSE------------------------------------------------------------- # plot(cause_fit) ## ----------------------------------------------------------------------------- wcr_fit <- wavelet_np_causality( x = dat$oil_return, y = dat$sp500_return, q = seq(0.1, 0.9, by = 0.1), wavelet = "la8", J = 5, verbose = FALSE ) print(wcr_fit) ## ----eval = FALSE------------------------------------------------------------- # plot(wcr_fit, colorscale = "Parula") ## ----------------------------------------------------------------------------- med_fit <- wavelet_mediation( y = dat$sp500_return, x = dat$oil_return, z = dat$epu, quantiles = c(0.10, 0.25, 0.50, 0.75, 0.90), wavelet = "la8", J = 5, dep_name = "SP500", main_name = "OIL", mod_name = "EPU", verbose = FALSE ) print(med_fit) ## ----eval = FALSE------------------------------------------------------------- # panels <- plot_mediation_panel(med_fit, colorscale = "Parula") # panels$Direct # panels$Indirect ## ----------------------------------------------------------------------------- wc_fit <- wavelet_quantile_correlation( x = dat$oil_return, y = dat$sp500_return, quantiles = c(0.10, 0.25, 0.50, 0.75, 0.90), wavelet = "la8", J = 5, n_sim = 100, verbose = FALSE ) print(wc_fit) head(wc_fit$results) ## ----eval = FALSE------------------------------------------------------------- # plot(wc_fit, colorscale = "Parula") ## ----------------------------------------------------------------------------- qd_fit <- wavelet_quantile_density(dat$sp500_return, j0 = 4, bandwidth = 0.15) print(qd_fit) ## ----eval = FALSE------------------------------------------------------------- # plot(qd_fit) ## ----------------------------------------------------------------------------- wqrr_colorscales(show_preview = TRUE) ## ----fig.height = 1.2--------------------------------------------------------- op <- par(mar = c(0, 0, 0, 0)) image(matrix(1:256, ncol = 1), col = parula_colors(256), axes = FALSE) par(op)