Title: | Cross-Quantilogram |
---|---|
Description: | Estimation and inference methods for the cross-quantilogram. The cross-quantilogram is a measure of nonlinear dependence between two variables, based on either unconditional or conditional quantile functions. It can be considered an extension of the correlogram, which is a correlation function over multiple lag periods that mainly focuses on linear dependency. One can use the cross-quantilogram to detect the presence of directional predictability from one time series to another. This package provides a statistical inference method based on the stationary bootstrap. For detailed theoretical and empirical explanations, see Linton and Whang (2007) for univariate time series analysis and Han, Linton, Oka and Whang (2016) for multivariate time series analysis. The full references for these key publications are as follows: (1) Linton, O., and Whang, Y. J. (2007). The quantilogram: with an application to evaluating directional predictability. Journal of Econometrics, 141(1), 250-282 <doi:10.1016/j.jeconom.2007.01.004>; (2) 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 <doi:10.1016/j.jeconom.2016.03.001>. |
Authors: | Tatsushi Oka [aut, cre], Heejon Han [ctb], Oliver Linton [ctb], Yoon-Jae Whang [ctb] |
Maintainer: | Tatsushi Oka <[email protected]> |
License: | GPL (>= 3) |
Version: | 3.1.1 |
Built: | 2024-11-26 06:43:48 UTC |
Source: | CRAN |
This package provides a comprehensive set of tools for quantilogram analysis in R. It includes functions for computing and visualizing cross-quantilograms, which are useful for analyzing dependence structures in financial time series data. The package implements methods described in Han et al. (2016) for measuring quantile dependence and testing directional predictability between time series.
The package's functions can be categorized into several groups:
Core Quantilogram Functions:
crossq
: Compute basic cross-quantilogram
crossq.sb
: Cross-quantilogram with stationary bootstrap
crossq.sb.opt
: Optimized cross-quantilogram with bootstrap
Visualization Functions:
crossq.heatmap
: Create heatmap visualization of cross-quantilograms
crossq.plot
: Plot method for crossq objects
Advanced Analysis Functions:
crossq.max
: Compute maximum cross-quantilogram
crossq.partial
: Compute partial cross-quantilogram
For a complete list of functions, see the package index.
Maintainer: Tatsushi Oka [email protected]
Other contributors:
Heejon Han [contributor]
Oliver Linton [contributor]
Yoon-Jae Whang [contributor]
Han, H., Linton, O., Oka, T., & Whang, Y. J. (2016). The cross-quantilogram: Measuring quantile dependence and testing directional predictability between time series. Journal of Econometrics, 193(1), 251-270.
The correlation statistics for a given lag order
corr.lag(matH, k)
corr.lag(matH, k)
matH |
The matrix with the column size of 2 |
k |
The lag order (integer) |
The function obtains the simple correlation statistics. The values in the first column of input matrix is interacted with the k-lagged values in the second column.
Correlation
Heejoon Han, Oliver Linton, Tatsushi Oka and Yoon-Jae Whang
A function used to obtain partial cross-correlation function for a give lag order
corr.lag.partial(matH, k)
corr.lag.partial(matH, k)
matH |
A matrix with multiple columns (more than 3 columns) |
k |
The lag order (integer) |
This function obtains the partial corss-correlation and the simple correlation. To obtain the partial cross-correlation, this function uses the first column of the input matrix and k-lagged values of the rest of the matrix.
Partial corss-correlation at k lags and the correlation statistics at k lags.
Heejoon Han, Oliver Linton, Tatsushi Oka and Yoon-Jae Whang
Returns the cross-quantilogram
crossq(DATA, vecA, k)
crossq(DATA, vecA, k)
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. |
vecA |
A pair of two probability values at which sample quantiles are estimated |
k |
A lag order (integer) |
This function obtains the cross-quantilogram at the k lag order.
Cross-Quantilogram
Heejoon Han, Oliver Linton, Tatsushi Oka and Yoon-Jae Whang
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.
## data source data("sys.risk") ## data: 2 variables D = sys.risk[,c("Market", "JPM")] # probability levels for the 2 variables vecA = c(0.1, 0.5) ## cross-quantilogram with the lag of 5 crossq.max(D, vecA, 5)
## data source data("sys.risk") ## data: 2 variables D = sys.risk[,c("Market", "JPM")] # probability levels for the 2 variables vecA = c(0.1, 0.5) ## cross-quantilogram with the lag of 5 crossq.max(D, vecA, 5)
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.
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" )
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" )
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". |
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:
|
Heejoon Han, Oliver Linton, Tatsushi Oka and Yoon-Jae Whang
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.
## 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)
## 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)
The cross-quantilograms from 1 to a given lag order.
crossq.max(DATA, vecA, Kmax)
crossq.max(DATA, vecA, Kmax)
DATA |
An input matrix |
vecA |
A pair of two probability values at which sample quantiles are estimated |
Kmax |
The maximum lag order (integer) |
This function calculates the partial cross-quantilograms up to the lag order users specify.
A vector of cross-quantilogram
Heejoon Han, Oliver Linton, Tatsushi Oka and Yoon-Jae Whang
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.
## data source data("sys.risk") ## data: 2 variables D = sys.risk[,c("Market", "JPM")] # probability levels for the 2 variables vecA = c(0.1, 0.5) ## cross-quantilogram with lags between 1 and 5 crossq.max(D, vecA, 5)
## data source data("sys.risk") ## data: 2 variables D = sys.risk[,c("Market", "JPM")] # probability levels for the 2 variables vecA = c(0.1, 0.5) ## cross-quantilogram with lags between 1 and 5 crossq.max(D, vecA, 5)
The partial cross-quantilograms from 1 to a given lag order.
crossq.max.partial(DATA, vecA, Kmax)
crossq.max.partial(DATA, vecA, Kmax)
DATA |
An input matrix |
vecA |
A vector of probability values at which sample quantiles are estimated |
Kmax |
The maximum lag order (integer) |
This function calculates the partial cross-quantilograms up to the lag order users specify.
A vector of cross-quantilogram and a vector of partial cross-quantilograms
Heejoon Han, Oliver Linton, Tatsushi Oka and Yoon-Jae Whang
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.
## data source data("sys.risk") ## data with 3 variables D = sys.risk[,c("Market", "JPM", "VIX")] ## probablity levels for the 3 variables vecA = c(0.1, 0.1, 0.1) ## partial cross-quantilogram with lags from 1 to 5 crossq.max.partial(D, vecA, 5)
## data source data("sys.risk") ## data with 3 variables D = sys.risk[,c("Market", "JPM", "VIX")] ## probablity levels for the 3 variables vecA = c(0.1, 0.1, 0.1) ## partial cross-quantilogram with lags from 1 to 5 crossq.max.partial(D, vecA, 5)
Returns the partial cross-quantilogram
crossq.partial(DATA, vecA, k)
crossq.partial(DATA, vecA, k)
DATA |
A matrix |
vecA |
A vector of probability values at which sample quantiles are estiamted |
k |
The lag order |
This function obtains the partial corss-quantilogram and the cross-quantilogram. To obtain the partial cross-correlation given an input matrix, this function interacts the values of the first column and the k-lagged values of the rest of the matrix.
The partial corss-quantilogram and the cross-quantilogram
Heejoon Han, Oliver Linton, Tatsushi Oka and Yoon-Jae Whang
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.
## data source data("sys.risk") ## data with 3 variables D = sys.risk[,c("Market", "JPM", "VIX")] ## probablity levels for the 3 variables vecA = c(0.1, 0.1, 0.1) ## partial cross-quantilogram with the lag of 5 crossq.max.partial(D, vecA, 5)
## data source data("sys.risk") ## data with 3 variables D = sys.risk[,c("Market", "JPM", "VIX")] ## probablity levels for the 3 variables vecA = c(0.1, 0.1, 0.1) ## partial cross-quantilogram with the lag of 5 crossq.max.partial(D, vecA, 5)
Returns critical values for the partial cross-quantilogram, based on the stationary bootstrap.
crossq.partial.sb(DATA, vecA, k, gamma, Bsize, sigLev)
crossq.partial.sb(DATA, vecA, k, gamma, Bsize, sigLev)
DATA |
The original data matrix |
vecA |
A pair of two probability values at which sample quantiles are estimated |
k |
A lag order |
gamma |
A parameter for the stationary bootstrap |
Bsize |
The number of repetition of bootstrap |
sigLev |
The statistical significance level |
This function generates critical values for for the partial cross-quantilogram, using the stationary bootstrap in Politis and Romano (1994).
The boostrap critical values
Heejoon Han, Oliver Linton, Tatsushi Oka and Yoon-Jae Whang
Politis, Dimitris N., and Joseph P. Romano. "The stationary bootstrap." Journal of the American Statistical Association 89.428 (1994): 1303-1313.
Returns critical values for the partial cross-quantilogram, based on the stationary bootstrap with the choice of the stationary-bootstrap parameter.
crossq.partial.sb.opt(DATA, vecA, k, Bsize, sigLev)
crossq.partial.sb.opt(DATA, vecA, k, Bsize, sigLev)
DATA |
The original data matrix |
vecA |
A pair of two probability values at which sample quantiles are estimated |
k |
A lag order |
Bsize |
The number of repetition of bootstrap |
sigLev |
The statistical significance level |
This function generates critical values for for the partial cross-quantilogram, using the stationary bootstrap in Politis and Romano (1994).
The boostrap critical values
Heejoon Han, Oliver Linton, Tatsushi Oka and Yoon-Jae Whang
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.
Patton, A., Politis, D. N., and White, H. (2009). Correction to "Automatic block-length selection for the dependent bootstrap" by D. Politis and H. White. Econometric Reviews, 28(4), 372-375.
Politis, D. N., and White, H. (2004). "Automatic block-length selection for the dependent bootstrap." Econometric Reviews, 23(1), 53-70.
Politis, Dimitris N., and Joseph P. Romano. (1994). "The stationary bootstrap." Journal of the American Statistical Association 89.428: 1303-1313.
This function creates a plot of the cross-quantilogram with confidence intervals. It computes the cross-quantilogram and its confidence intervals using stationary bootstrap, then creates a ggplot visualization of the results.
crossq.plot( DATA, vecA, Kmax, Bsize, sigLev = 0.05, vec.lag, vec.CQ, mat.CI, y.min = -1, y.max = 1, ribbon_color = "gray", ribbon_alpha = 0.8, bar_color = "black", bar_width = 0.2, title = "", subtitle = NULL )
crossq.plot( DATA, vecA, Kmax, Bsize, sigLev = 0.05, vec.lag, vec.CQ, mat.CI, y.min = -1, y.max = 1, ribbon_color = "gray", ribbon_alpha = 0.8, bar_color = "black", bar_width = 0.2, title = "", subtitle = NULL )
DATA |
A 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. |
vecA |
A numeric vector of quantiles for the first variable. |
Kmax |
An integer representing the maximum lag to compute. |
Bsize |
Bootstrap sample size for stationary bootstrap. |
sigLev |
Significance level for confidence intervals. Default is 0.05 (95% confidence level). |
vec.lag |
A vector of lag values (integer values). Not used in computation, only for plotting. |
vec.CQ |
A numeric vector of cross-quantilogram values. Not used in computation, only for plotting. |
mat.CI |
A matrix with two columns representing the lower and upper bounds of the confidence interval. Not used in computation, only for plotting. |
y.min |
The minimum y-axis value. Default is -1. |
y.max |
The maximum y-axis value. Default is 1. |
ribbon_color |
Color for the confidence interval ribbon. Default is "gray". |
ribbon_alpha |
Alpha (transparency) for the confidence interval ribbon. Default is 0.8. |
bar_color |
Color for the quantilogram bars. Default is "black". |
bar_width |
Width of the quantilogram bars. Default is 0.2. |
title |
Plot title. Default is an empty string. |
subtitle |
Plot subtitle. Default is NULL (no subtitle). |
A list containing two elements:
plot |
A ggplot object representing the cross-quantilogram plot over lags. |
df.res |
A data frame containing cross-quantilogram values and critical values. It includes the following columns:
|
A list containing two elements:
plot |
A ggplot object representing the cross-quantilogram plot. |
df.res |
A data frame containing lag values, cross-quantilogram values, and confidence intervals. |
Heejoon Han, Oliver Linton, Tatsushi Oka and Yoon-Jae Whang
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.
## Not run: data("sys.risk") DATA = sys.risk[,c("JPM", "Market")] vecA = 0.05 Kmax = 20 Bsize = 200 result = crossq.plot(DATA, vecA, Kmax, Bsize) print(result$plot) ## End(Not run)
## Not run: data("sys.risk") DATA = sys.risk[,c("JPM", "Market")] vecA = 0.05 Kmax = 20 Bsize = 200 result = crossq.plot(DATA, vecA, Kmax, Bsize) print(result$plot) ## End(Not run)
Returns critical values for the cross-quantilogram, based on the stationary bootstrap.
crossq.sb(DATA, vecA, k, gamma, Bsize, sigLev)
crossq.sb(DATA, vecA, k, gamma, Bsize, sigLev)
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. |
vecA |
A pair of two probability values at which sample quantiles are estimated |
k |
A lag order |
gamma |
A parameter for the stationary bootstrap |
Bsize |
The number of repetition of bootstrap |
sigLev |
The statistical significance level |
This function generates critical values for for the cross-quantilogram, using the stationary bootstrap in Politis and Romano (1994).
The boostrap critical values
Heejoon Han, Oliver Linton, Tatsushi Oka and Yoon-Jae Whang
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.
Politis, Dimitris N., and Joseph P. Romano. "The stationary bootstrap." Journal of the American Statistical Association 89.428 (1994): 1303-1313.
data("sys.risk") ## data source D = sys.risk[,c("Market", "JPM")] ## data: 2 variables # probability levels for the 2 variables vecA = c(0.1, 0.5) ## setup for stationary bootstrap gamma = 1/10 ## bootstrap parameter depending on data Bsize = 5 ## small size, 5, for test sigLev = 0.05 ## significance level ## cross-quantilogram with the lag of 5 crossq.sb(D, vecA, 5, gamma, Bsize, sigLev)
data("sys.risk") ## data source D = sys.risk[,c("Market", "JPM")] ## data: 2 variables # probability levels for the 2 variables vecA = c(0.1, 0.5) ## setup for stationary bootstrap gamma = 1/10 ## bootstrap parameter depending on data Bsize = 5 ## small size, 5, for test sigLev = 0.05 ## significance level ## cross-quantilogram with the lag of 5 crossq.sb(D, vecA, 5, gamma, Bsize, sigLev)
Returns critical values for the cross-quantilogram, based on the stationary bootstrap with the choice of the stationary-bootstrap parameter.
crossq.sb.opt(DATA, vecA, k, Bsize, sigLev = 0.05)
crossq.sb.opt(DATA, vecA, k, Bsize, sigLev = 0.05)
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. |
vecA |
A pair of two probability values at which sample quantiles are estimated |
k |
A lag order |
Bsize |
The number of repetition of bootstrap |
sigLev |
The statistical significance level. Default is 0.05 (5% significance level). |
This function generates critical values for for the cross-quantilogram, using the stationary bootstrap in Politis and Romano (1994). To choose parameter for the statioanry bootstrap, this function first obtaines the optimal value for each time serie using the result provided by Politis and White (2004) and Patton, Politis and White (2004) (The R-package, "np", written by Hayfield and Racine is used). Next, the average of the obtained values is used as the parameter value.
The boostrap critical values
Heejoon Han, Oliver Linton, Tatsushi Oka and Yoon-Jae Whang
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.
Patton, A., Politis, D. N., and White, H. (2009). Correction to "Automatic block-length selection for the dependent bootstrap" by D. Politis and H. White. Econometric Reviews, 28(4), 372-375.
Politis, D. N., and White, H. (2004). "Automatic block-length selection for the dependent bootstrap." Econometric Reviews, 23(1), 53-70.
Politis, Dimitris N., and Joseph P. Romano. (1994). "The stationary bootstrap." Journal of the American Statistical Association 89.428: 1303-1313.
## data source data("sys.risk") ## data: 2 variables D = sys.risk[,c("Market", "JPM")] # probability levels for the 2 variables vecA = c(0.1, 0.5) ## setup for stationary bootstrap Bsize = 5 ## small size 5 for test sigLev = 0.05 ## significance level ## cross-quantilogram with the lag of 5 crossq.sb.opt(D, vecA, 5, Bsize, sigLev)
## data source data("sys.risk") ## data: 2 variables D = sys.risk[,c("Market", "JPM")] # probability levels for the 2 variables vecA = c(0.1, 0.5) ## setup for stationary bootstrap Bsize = 5 ## small size 5 for test sigLev = 0.05 ## significance level ## cross-quantilogram with the lag of 5 crossq.sb.opt(D, vecA, 5, Bsize, sigLev)
Returns the cross-quantilogram
crossqreg(DATA1, DATA2, vecA, k)
crossqreg(DATA1, DATA2, vecA, k)
DATA1 |
An input matrix (T x p1) |
DATA2 |
An input matrix (T x p2) |
vecA |
A pair of two probability values at which sample quantiles are estimated |
k |
A lag order (integer) |
This function obtains the cross-quantilogram at the k lag order.
Cross-Quantilogram
Heejoon Han, Oliver Linton, Tatsushi Oka and Yoon-Jae Whang
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.
Koenker, R., and Bassett Jr, G. (1978). "Regression quantiles." Econometrica, 46(1), 33-50.
## data source data(sys.risk) ## sample size T = nrow(sys.risk) ## matrix for quantile regressions ## - 1st column: dependent variables ## - the rest: regressors or predictors D1 = cbind(sys.risk[2:T,"Market"], sys.risk[1:(T-1),"Market"]) D2 = cbind(sys.risk[2:T,"JPM"], sys.risk[1:(T-1),"JPM"]) ## probability levels vecA = c(0.1, 0.2) ## cross-quantilogram with the lag of 5, after quantile regression crossqreg(D1, D2, vecA, 5)
## data source data(sys.risk) ## sample size T = nrow(sys.risk) ## matrix for quantile regressions ## - 1st column: dependent variables ## - the rest: regressors or predictors D1 = cbind(sys.risk[2:T,"Market"], sys.risk[1:(T-1),"Market"]) D2 = cbind(sys.risk[2:T,"JPM"], sys.risk[1:(T-1),"JPM"]) ## probability levels vecA = c(0.1, 0.2) ## cross-quantilogram with the lag of 5, after quantile regression crossqreg(D1, D2, vecA, 5)
The cross-quantilograms from 0 to a given lag order.
crossqreg.max(DATA1, DATA2, vecA, Kmax)
crossqreg.max(DATA1, DATA2, vecA, Kmax)
DATA1 |
An input matrix (T x p1) |
DATA2 |
An input matrix (T x p2) |
vecA |
A pair of two probability values at which sample quantiles are estimated |
Kmax |
The maximum lag order (integer) |
This function calculates the partial cross-quantilograms up to the lag order users specify.
A vector of cross-quantilogram
Heejoon Han, Oliver Linton, Tatsushi Oka and Yoon-Jae Whang
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.
The partial cross-quantilograms from 1 to a given lag order.
crossqreg.max.partial(DATA1, DATA2, vecA, Kmax)
crossqreg.max.partial(DATA1, DATA2, vecA, Kmax)
DATA1 |
An input matrix (T x p1) |
DATA2 |
An input matrix (T x p2) |
vecA |
A vector of probability values at which sample quantiles are estimated |
Kmax |
The maximum lag order (integer) |
This function calculates the partial cross-quantilograms up to the lag order users specify.
A vector of cross-quantilogram and a vector of partial cross-quantilograms
Heejoon Han, Oliver Linton, Tatsushi Oka and Yoon-Jae Whang
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.
Returns the partial cross-quantilogram
crossqreg.partial(DATA1, DATA2, vecA, k)
crossqreg.partial(DATA1, DATA2, vecA, k)
DATA1 |
An input matrix (T x p1) |
DATA2 |
An input matrix (T x p2) |
vecA |
A vector of probability values at which sample quantiles are estiamted |
k |
The lag order |
This function obtains the partial corss-quantilogram and the cross-quantilogram. To obtain the partial cross-correlation given an input matrix, this function interacts the values of the first column and the k-lagged values of the rest of the matrix.
The partial corss-quantilogram and the cross-quantilogram
Heejoon Han, Oliver Linton, Tatsushi Oka and Yoon-Jae Whang
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.
Returns critical values for the cross-quantilogram, based on the stationary bootstrap.
crossqreg.sb(DATA1, DATA2, vecA, k, gamma, Bsize, sigLev)
crossqreg.sb(DATA1, DATA2, vecA, k, gamma, Bsize, sigLev)
DATA1 |
The original data matrix (T x p1) |
DATA2 |
The original data matrix (T x p2) |
vecA |
A pair of two probability values at which sample quantiles are estimated |
k |
A lag order |
gamma |
A parameter for the stationary bootstrap |
Bsize |
The number of repetition of bootstrap |
sigLev |
The statistical significance level |
This function generates critical values for for the cross-quantilogram, using the stationary bootstrap in Politis and Romano (1994).
The boostrap critical values
Heejoon Han, Oliver Linton, Tatsushi Oka and Yoon-Jae Whang
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.
Politis, Dimitris N., and Joseph P. Romano. "The stationary bootstrap." Journal of the American Statistical Association 89.428 (1994): 1303-1313.
data(sys.risk) ## sample size T = nrow(sys.risk) ## matrix for quantile regressions ## - 1st column: dependent variables ## - the rest: regressors or predictors D1 = cbind(sys.risk[2:T,"Market"], sys.risk[1:(T-1),"Market"]) D2 = cbind(sys.risk[2:T,"JPM"], sys.risk[1:(T-1),"JPM"]) ## probability levels vecA = c(0.1, 0.2) ## setup for stationary bootstrap gamma = 1/10 ## bootstrap parameter depending on data Bsize = 5 ## small size 10 for test sigLev = 0.05 ## significance level ## cross-quantilogram with the lag of 5, after quantile regression crossqreg.sb(D1, D2, vecA, 5, gamma, Bsize, sigLev)
data(sys.risk) ## sample size T = nrow(sys.risk) ## matrix for quantile regressions ## - 1st column: dependent variables ## - the rest: regressors or predictors D1 = cbind(sys.risk[2:T,"Market"], sys.risk[1:(T-1),"Market"]) D2 = cbind(sys.risk[2:T,"JPM"], sys.risk[1:(T-1),"JPM"]) ## probability levels vecA = c(0.1, 0.2) ## setup for stationary bootstrap gamma = 1/10 ## bootstrap parameter depending on data Bsize = 5 ## small size 10 for test sigLev = 0.05 ## significance level ## cross-quantilogram with the lag of 5, after quantile regression crossqreg.sb(D1, D2, vecA, 5, gamma, Bsize, sigLev)
Returns the matrix of quantil-hits
q.hit(DATA, vecA)
q.hit(DATA, vecA)
DATA |
A matrix that has time-series observations in its columns |
vecA |
A vector of probabilty values at which sample quantiles are estimated |
This function generates the quantile hits given a vector of probabilty values. The quantile hits are obtained for each column of an input matrix.
A matrix of quantile-hits
Heejoon Han, Oliver Linton, Tatsushi Oka and Yoon-Jae Whang
Returns the matrix of quantil-hits
qreg.hit(DATA1, DATA2, vecA)
qreg.hit(DATA1, DATA2, vecA)
DATA1 |
An input matrix (T x p1+1) with the first column of the dependent varaible and the the rest of columns with regressors |
DATA2 |
An input matrix (T x p2+1) with the first column of the dependent varaible and the the rest of columns with regressors |
vecA |
A vector of probabilty values at which sample quantiles are estimated |
This function generates the quantile hits based on quantile regression, given a vector of probabilty values. The quantile regressions are esimated for each matrix of data and a pair of quantile hits are produced.
A matrix of quantile-hits
Heejoon Han, Oliver Linton, Tatsushi Oka and Yoon-Jae Whang
Koenker, R., and Bassett Jr, G. (1978). "Regression quantiles." Econometrica, 46(1), 33-50.
Te Box-Pierece and Ljung-Box type Q-statistics
Qstat(vecTest, Tsize)
Qstat(vecTest, Tsize)
vecTest |
A vector of test statistics ordered with respect the number of lags |
Tsize |
A original sample size |
This function returns Box-Pierece and Ljung-Box type Q-statistics
the Box-Pierece and Ljung-Box statistics
Heejoon Han, Oliver Linton, Tatsushi Oka and Yoon-Jae Whang
Box, G. EP, and D. A. Pierce. (1970). "Distribution of residual autocorrelations in autoregressive-integrated moving average time series models." Journal of the American Statistical Association 65.332, pp.1509-1526.
Ljung, G. M., and G. EP Box. (1978). "On a measure of lack of fit in time series models." Biometrika 65.2, pp.297-303.
Stationary Bootstrap procedure to generate critical values for both Box-Pierece and Ljung-Box type Q-statistics
Qstat.reg.sb(DATA1, DATA2, vecA, Psize, gamma, Bsize, sigLev)
Qstat.reg.sb(DATA1, DATA2, vecA, Psize, gamma, Bsize, sigLev)
DATA1 |
The original data set (1) |
DATA2 |
The original data set (2) |
vecA |
A pair of two probabity values at which sample quantiles are estimated |
Psize |
The maximum number of lags |
gamma |
A parameter for the stationary bootstrap |
Bsize |
The number of repetition of bootstrap |
sigLev |
The statistical significance level |
This function returns critical values for for both Box-Pierece and Ljung-Box type Q-statistics through the statioanry bootstrap proposed by Politis and Romano (1994).
The bootstrap critical values
Heejoon Han, Oliver Linton, Tatsushi Oka and Yoon-Jae Whang
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.
Politis, Dimitris N., and Joseph P. Romano. (1994). "The stationary bootstrap." Journal of the American Statistical Association 89.428, pp.1303-1313.
data(sys.risk) ## sample size T = nrow(sys.risk) ## matrix for quantile regressions ## - 1st column: dependent variables ## - the rest: regressors or predictors D1 = cbind(sys.risk[2:T,"Market"], sys.risk[1:(T-1),"Market"]) D2 = cbind(sys.risk[2:T,"JPM"], sys.risk[1:(T-1),"JPM"]) ## probability levels vecA = c(0.1, 0.2) ## setup for stationary bootstrap gamma = 1/10 ## bootstrap parameter depending on data Bsize = 5 ## small size, 5, for test sigLev = 0.05 ## significance level ## Q statistics with lags from 1 to 5, after quantile regression Qstat.reg.sb(D1, D2, vecA, 5, gamma, Bsize, sigLev)
data(sys.risk) ## sample size T = nrow(sys.risk) ## matrix for quantile regressions ## - 1st column: dependent variables ## - the rest: regressors or predictors D1 = cbind(sys.risk[2:T,"Market"], sys.risk[1:(T-1),"Market"]) D2 = cbind(sys.risk[2:T,"JPM"], sys.risk[1:(T-1),"JPM"]) ## probability levels vecA = c(0.1, 0.2) ## setup for stationary bootstrap gamma = 1/10 ## bootstrap parameter depending on data Bsize = 5 ## small size, 5, for test sigLev = 0.05 ## significance level ## Q statistics with lags from 1 to 5, after quantile regression Qstat.reg.sb(D1, D2, vecA, 5, gamma, Bsize, sigLev)
Stationary Bootstrap procedure to generate critical values for both Box-Pierece and Ljung-Box type Q-statistics
Qstat.sb(DATA, vecA, Psize, gamma, Bsize, sigLev)
Qstat.sb(DATA, vecA, Psize, gamma, Bsize, sigLev)
DATA |
The original data |
vecA |
A pair of two probabity values at which sample quantiles are estimated |
Psize |
The maximum number of lags |
gamma |
A parameter for the stationary bootstrap |
Bsize |
The number of repetition of bootstrap |
sigLev |
The statistical significance level |
This function returns critical values for for both Box-Pierece and Ljung-Box type Q-statistics through the statioanry bootstrap proposed by Politis and Romano (1994).
The bootstrap critical values
Heejoon Han, Oliver Linton, Tatsushi Oka and Yoon-Jae Whang
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.
Politis, Dimitris N., and Joseph P. Romano. (1994). "The stationary bootstrap." Journal of the American Statistical Association 89.428, pp.1303-1313.
data("sys.risk") ## data source D = sys.risk[,c("Market", "JPM")] ## data: 2 variables # probability levels for the 2 variables vecA = c(0.1, 0.5) ## setup for stationary bootstrap gamma = 1/10 ## bootstrap parameter depending on data Bsize = 5 ## small size, 5, for test sigLev = 0.05 ## significance level ## Q statistics with lags from 1 to5 Qstat.sb(D, vecA, 5, gamma, Bsize, sigLev)
data("sys.risk") ## data source D = sys.risk[,c("Market", "JPM")] ## data: 2 variables # probability levels for the 2 variables vecA = c(0.1, 0.5) ## setup for stationary bootstrap gamma = 1/10 ## bootstrap parameter depending on data Bsize = 5 ## small size, 5, for test sigLev = 0.05 ## significance level ## Q statistics with lags from 1 to5 Qstat.sb(D, vecA, 5, gamma, Bsize, sigLev)
Stationary Bootstrap procedure to generate critical values for both Box-Pierece and Ljung-Box type Q-statistics with the choice of the stationary-bootstrap parameter.
Qstat.sb.opt(DATA, vecA, Psize, Bsize, sigLev)
Qstat.sb.opt(DATA, vecA, Psize, Bsize, sigLev)
DATA |
The original data |
vecA |
A pair of two probabity values at which sample quantiles are estimated |
Psize |
The maximum number of lags |
Bsize |
The number of repetition of bootstrap |
sigLev |
The statistical significance level |
This function returns critical values for for both Box-Pierece and Ljung-Box type Q-statistics through the statioanry bootstrap proposed by Politis and Romano (1994). To choose parameter for the statioanry bootstrap, this function first obtaines the optimal value for each time serie using the result provided by Politis and White (2004) and Patton, Politis and White (2004) (The R-package, "np", written by Hayfield and Racine is used). Next, the average of the obtained values is used as the parameter value.
The bootstrap critical values
Heejoon Han, Oliver Linton, Tatsushi Oka and Yoon-Jae Whang
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.
Patton, A., Politis, D. N., and White, H. (2009). Correction to "Automatic block-length selection for the dependent bootstrap" by D. Politis and H. White. Econometric Reviews, 28(4), 372-375.
Politis, D. N., and White, H. (2004). "Automatic block-length selection for the dependent bootstrap." Econometric Reviews, 23(1), 53-70.
Politis, Dimitris N., and Joseph P. Romano. (1994). "The stationary bootstrap." Journal of the American Statistical Association 89.428: 1303-1313.
data("sys.risk") ## data source D = sys.risk[,c("Market", "JPM")] ## data: 2 variables # probability levels for the 2 variables vecA = c(0.1, 0.5) ## setup for stationary bootstrap Bsize = 5 ## small size, 5, for test sigLev = 0.05 ## significance level ## Q statistics with lags from 1 to5 Qstat.sb.opt(D, vecA, 5, Bsize, sigLev)
data("sys.risk") ## data source D = sys.risk[,c("Market", "JPM")] ## data: 2 variables # probability levels for the 2 variables vecA = c(0.1, 0.5) ## setup for stationary bootstrap Bsize = 5 ## small size, 5, for test sigLev = 0.05 ## significance level ## Q statistics with lags from 1 to5 Qstat.sb.opt(D, vecA, 5, Bsize, sigLev)
A subfunction for the statioanry bootstrap
sb.index(Nsize, gamma)
sb.index(Nsize, gamma)
Nsize |
The size of the stationary bootstrap resample |
gamma |
A parameter for the stationary boostrap. |
This function resamples blocks of indicies with random block lengths. This code follows the MATLAB file of the Oxford MFE Toolbox written by Kevin Sheppard.
A vector of indicies for the stationary bootstrap
Heejoon Han, Oliver Linton, Tatsushi Oka and Yoon-Jae Whang
The Oxford MFE toolbox (http://www.kevinsheppard.com/wiki/MFE_Toolbox) by Kevin Sheppard
The dataset contains monthly excess stock returns and stock varaince, which are included in the data set analyzed in Goyal and Welch (2008). Stock returns are measured by the S&P 500 index and include dividens. A treasury-bill rate is subtracted from stock returns to give excess stock returns The stock variance is a volatility estimate based on daily squared returns and is treated as an estimate of equity risk in the literature. The sample period is from Feburary 1885 to December 2005 with sample size 1,451.
Date: Year-Month-Day
Return: excess stock returns
Variance: stock variance
data(stock)
data(stock)
A data object with two variables
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.
Welch, Ivo, and Amit Goyal. "A comprehensive look at the empirical performance of equity premium prediction." Review of Financial Studies 21.4 (2008): 1455-1508.
The data set contains the daily CRSP market value weighted index returns, which are used as the market index returns in Brownless and Engle (2012), and also includes daily stock returns on JP Morgan Chase (JPM), Goldman Sachs (GS) and American International Group (AIG). The sample period is from 2 Jan. 2001 to 30 Dec. 2011 with sample size 2,767.
data(sys.risk)
data(sys.risk)
A data object with five variables
date: The time index (day)
Market: The daily CRSP market value weighted incex returns
JPM: stock returns on JP Morgan Chase (JPM)
GS: stock returns on Goldman Sachs (GS)
AIG: stock returns on American International Group (AIG)
Brownlees, Christian T., and Robert F. Engle. "Volatility, correlation and tails for systemic risk measurement." Available at SSRN 1611229 (2012).
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.