Learn R Programming

quantilogram (version 3.1.1)

crossq.heatmap: 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. The heatmap uses 0 values if the test of no correlation cannot be rejected, and it uses cross-quantilogram values otherwise. 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"
)

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.

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".

Author

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

Run this code
if (FALSE) {
## 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)
}

Run the code above in your browser using DataLab