crossq.heatmap: Heatmap of Cross-Quantilogram

View source: R/crossq.heatmap.R

crossq.heatmapR Documentation

Heatmap of Cross-Quantilogram

Description

This function creates a customizable heatmap visualization of the cross-quantilogram matrix and returns a list containing the plot and a data frame of cross-quantilogram values with critical values. Each cell is colored and labelled by the cross-quantilogram value. Cells that are significant at the given level (stationary bootstrap) are labelled in bold. The critical values are obtained by stationary bootstrap.

Usage

crossq.heatmap(
  DATA,
  k,
  vec.q,
  Bsize,
  sigLev = 0.05,
  var1_name = NULL,
  var2_name = NULL,
  title = "Cross-Quantilogram Heatmap",
  subtitle = NULL,
  colors = c("blue", "lightblue", "white", "pink", "red"),
  color_values = c(-1, -0.15, 0, 0.15, 1),
  tile_border_color = "black",
  tile_border_width = 0.5,
  x_angle = 90,
  x_lab = NULL,
  y_lab = NULL,
  legend_title = "Cross-Q",
  gamma = NULL,
  text_size = 3
)

Arguments

DATA

An input matrix of dimensions T x 2, where T is the number of observations. Column 1 contains the first variable and Column 2 contains the second variable. This function will apply a k-period lag to the second variable during computation.

k

An integer representing the lag.

vec.q

A numeric vector of quantiles.

Bsize

Bootstrap sample size for stationary bootstrap.

sigLev

Significance level for statistical test. Default is 0.05 (5% significance level).

var1_name

Name of the first variable (predicted variable). If NULL, defaults to "Variable 1".

var2_name

Name of the second variable (predicting variable). If NULL, defaults to "Variable 2".

title

Plot title. Default is "Cross-Quantilogram Heatmap".

subtitle

Plot subtitle. Default is NULL (no subtitle).

colors

A vector of colors for the heatmap. Default is c("blue", "lightblue", "white", "pink", "red").

color_values

A vector of values for color scaling. Default is c(-1, -0.15, 0, 0.15, 1).

tile_border_color

Color for tile borders. Default is "black".

tile_border_width

Width for tile borders. Default is 0.5.

x_angle

Angle for x-axis labels. Default is 90.

x_lab

X-axis label. If NULL (default), it's automatically generated.

y_lab

Y-axis label. If NULL (default), it's automatically generated.

legend_title

Title for the legend. Default is "Cross-Q".

gamma

Stationary-bootstrap parameter (the mean block length is 1/gamma). If NULL (default), it is chosen once by the Politis-White rule via np::b.star on the two series. Supplying a value avoids the dependency on the np package.

text_size

Font size of the per-cell cross-quantilogram value. Default is 3.

Value

A list containing two elements:

plot

A ggplot object representing the cross-quantilogram heatmap.

df.res

A data frame containing cross-quantilogram values and critical values. It includes the following columns:

  • Quantile1: The quantile values for the first variable.

  • Quantile2: The quantile values for the second variable.

  • vCRQ: The cross-quantilogram values.

  • Lower_CV: The lower critical values.

  • Upper_CV: The upper critical values.

  • Significant: A logical vector indicating whether the cross-quantilogram is significant at the given significance level.

Author(s)

Heejoon Han, Oliver Linton, Tatsushi Oka and Yoon-Jae Whang

References

Han, H., Linton, O., Oka, T., and Whang, Y. J. (2016). "The cross-quantilogram: Measuring quantile dependence and testing directional predictability between time series." Journal of Econometrics, 193(1), 251-270.

Examples

## Not run: 
## data source
data("sys.risk")

## two variables data: T x 2
DATA = sys.risk[,c("JPM", "Market")]

## setup and estimation
k = 1                             ## lag order
vec.q  = seq(0.05, 0.95, 0.05)    ## a list of quantiles
B.size = 200                      ## Repetition of bootstrap
res = crossq.heatmap(DATA, k, vec.q, B.size)

## result
print(res$plot)

## End(Not run)


quantilogram documentation built on June 19, 2026, 1:06 a.m.