Title: | Cross-Quantilogram |
Version: | 3.1.1 |
Maintainer: | Tatsushi Oka <oka.econ@gmail.com> |
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>. |
License: | GPL (≥ 3) |
Depends: | R (≥ 3.5.0) |
Encoding: | UTF-8 |
RoxygenNote: | 7.3.2 |
Imports: | ggplot2, np, quantreg, rlang, scales, stats |
Suggests: | knitr, rmarkdown, SparseM |
LazyData: | true |
NeedsCompilation: | no |
Packaged: | 2024-08-27 12:16:43 UTC; student-t |
Author: | Tatsushi Oka [aut, cre], Heejon Han [ctb], Oliver Linton [ctb], Yoon-Jae Whang [ctb] |
Repository: | CRAN |
Date/Publication: | 2024-08-27 12:40:02 UTC |
Quantilogram Analysis Tools
Description
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.
Details
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.
Author(s)
Maintainer: Tatsushi Oka oka.econ@gmail.com
Other contributors:
Heejon Han [contributor]
Oliver Linton [contributor]
Yoon-Jae Whang [contributor]
References
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.
Q-statistics
Description
Te Box-Pierece and Ljung-Box type Q-statistics
Usage
Qstat(vecTest, Tsize)
Arguments
vecTest |
A vector of test statistics ordered with respect the number of lags |
Tsize |
A original sample size |
Details
This function returns Box-Pierece and Ljung-Box type Q-statistics
Value
the Box-Pierece and Ljung-Box statistics
Author(s)
Heejoon Han, Oliver Linton, Tatsushi Oka and Yoon-Jae Whang
References
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 for Q statistics
Description
Stationary Bootstrap procedure to generate critical values for both Box-Pierece and Ljung-Box type Q-statistics
Usage
Qstat.reg.sb(DATA1, DATA2, vecA, Psize, gamma, Bsize, sigLev)
Arguments
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 |
Details
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).
Value
The bootstrap critical values
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.
Politis, Dimitris N., and Joseph P. Romano. (1994). "The stationary bootstrap." Journal of the American Statistical Association 89.428, pp.1303-1313.
Examples
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 for Q statistics
Description
Stationary Bootstrap procedure to generate critical values for both Box-Pierece and Ljung-Box type Q-statistics
Usage
Qstat.sb(DATA, vecA, Psize, gamma, Bsize, sigLev)
Arguments
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 |
Details
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).
Value
The bootstrap critical values
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.
Politis, Dimitris N., and Joseph P. Romano. (1994). "The stationary bootstrap." Journal of the American Statistical Association 89.428, pp.1303-1313.
Examples
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 for Q statistics
Description
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.
Usage
Qstat.sb.opt(DATA, vecA, Psize, Bsize, sigLev)
Arguments
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 |
Details
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.
Value
The bootstrap critical values
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.
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.
Examples
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)
Correlation Function
Description
The correlation statistics for a given lag order
Usage
corr.lag(matH, k)
Arguments
matH |
The matrix with the column size of 2 |
k |
The lag order (integer) |
Details
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.
Value
Correlation
Author(s)
Heejoon Han, Oliver Linton, Tatsushi Oka and Yoon-Jae Whang
Partial Cross-correlation function
Description
A function used to obtain partial cross-correlation function for a give lag order
Usage
corr.lag.partial(matH, k)
Arguments
matH |
A matrix with multiple columns (more than 3 columns) |
k |
The lag order (integer) |
Details
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.
Value
Partial corss-correlation at k lags and the correlation statistics at k lags.
Author(s)
Heejoon Han, Oliver Linton, Tatsushi Oka and Yoon-Jae Whang
Cross-Quantilogram
Description
Returns the cross-quantilogram
Usage
crossq(DATA, vecA, k)
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. |
vecA |
A pair of two probability values at which sample quantiles are estimated |
k |
A lag order (integer) |
Details
This function obtains the cross-quantilogram at the k lag order.
Value
Cross-Quantilogram
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
## 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)
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"
)
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". |
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:
|
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)
Corss-Quantilogram up to a Given Lag Order
Description
The cross-quantilograms from 1 to a given lag order.
Usage
crossq.max(DATA, vecA, Kmax)
Arguments
DATA |
An input matrix |
vecA |
A pair of two probability values at which sample quantiles are estimated |
Kmax |
The maximum lag order (integer) |
Details
This function calculates the partial cross-quantilograms up to the lag order users specify.
Value
A vector of cross-quantilogram
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
## 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)
Partial Corss-Quantilogram upto a given lag order
Description
The partial cross-quantilograms from 1 to a given lag order.
Usage
crossq.max.partial(DATA, vecA, Kmax)
Arguments
DATA |
An input matrix |
vecA |
A vector of probability values at which sample quantiles are estimated |
Kmax |
The maximum lag order (integer) |
Details
This function calculates the partial cross-quantilograms up to the lag order users specify.
Value
A vector of cross-quantilogram and a vector of partial cross-quantilograms
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
## 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)
Paritial Cross-Quantilogram
Description
Returns the partial cross-quantilogram
Usage
crossq.partial(DATA, vecA, k)
Arguments
DATA |
A matrix |
vecA |
A vector of probability values at which sample quantiles are estiamted |
k |
The lag order |
Details
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.
Value
The partial corss-quantilogram and the cross-quantilogram
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
## 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)
Stationary Bootstrap for the Partial Cross-Quantilogram
Description
Returns critical values for the partial cross-quantilogram, based on the stationary bootstrap.
Usage
crossq.partial.sb(DATA, vecA, k, gamma, Bsize, sigLev)
Arguments
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 |
Details
This function generates critical values for for the partial cross-quantilogram, using the stationary bootstrap in Politis and Romano (1994).
Value
The boostrap critical values
Author(s)
Heejoon Han, Oliver Linton, Tatsushi Oka and Yoon-Jae Whang
References
Politis, Dimitris N., and Joseph P. Romano. "The stationary bootstrap." Journal of the American Statistical Association 89.428 (1994): 1303-1313.
Stationary Bootstrap for the Partial Cross-Quantilogram dwith the choice of the stationary-bootstrap parameter
Description
Returns critical values for the partial cross-quantilogram, based on the stationary bootstrap with the choice of the stationary-bootstrap parameter.
Usage
crossq.partial.sb.opt(DATA, vecA, k, Bsize, sigLev)
Arguments
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 |
Details
This function generates critical values for for the partial cross-quantilogram, using the stationary bootstrap in Politis and Romano (1994).
Value
The boostrap critical values
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.
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.
Plot of Cross-Quantilogram
Description
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.
Usage
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
)
Arguments
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). |
Value
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. |
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("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)
Stationary Bootstrap for the Cross-Quantilogram
Description
Returns critical values for the cross-quantilogram, based on the stationary bootstrap.
Usage
crossq.sb(DATA, vecA, k, gamma, Bsize, sigLev)
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. |
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 |
Details
This function generates critical values for for the cross-quantilogram, using the stationary bootstrap in Politis and Romano (1994).
Value
The boostrap critical values
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.
Politis, Dimitris N., and Joseph P. Romano. "The stationary bootstrap." Journal of the American Statistical Association 89.428 (1994): 1303-1313.
Examples
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)
Stationary Bootstrap for the Cross-Quantilogram with the choice of the stationary-bootstrap parameter
Description
Returns critical values for the cross-quantilogram, based on the stationary bootstrap with the choice of the stationary-bootstrap parameter.
Usage
crossq.sb.opt(DATA, vecA, k, Bsize, sigLev = 0.05)
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. |
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). |
Details
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.
Value
The boostrap critical values
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.
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.
Examples
## 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)
Cross-Quantilogram
Description
Returns the cross-quantilogram
Usage
crossqreg(DATA1, DATA2, vecA, k)
Arguments
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) |
Details
This function obtains the cross-quantilogram at the k lag order.
Value
Cross-Quantilogram
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.
Koenker, R., and Bassett Jr, G. (1978). "Regression quantiles." Econometrica, 46(1), 33-50.
Examples
## 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)
Corss-Quantilogram up to a Given Lag Order
Description
The cross-quantilograms from 0 to a given lag order.
Usage
crossqreg.max(DATA1, DATA2, vecA, Kmax)
Arguments
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) |
Details
This function calculates the partial cross-quantilograms up to the lag order users specify.
Value
A vector of cross-quantilogram
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.
Partial Corss-Quantilogram upto a given lag order
Description
The partial cross-quantilograms from 1 to a given lag order.
Usage
crossqreg.max.partial(DATA1, DATA2, vecA, Kmax)
Arguments
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) |
Details
This function calculates the partial cross-quantilograms up to the lag order users specify.
Value
A vector of cross-quantilogram and a vector of partial cross-quantilograms
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.
Paritial Cross-Quantilogram
Description
Returns the partial cross-quantilogram
Usage
crossqreg.partial(DATA1, DATA2, vecA, k)
Arguments
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 |
Details
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.
Value
The partial corss-quantilogram and the cross-quantilogram
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.
Stationary Bootstrap for the Cross-Quantilogram
Description
Returns critical values for the cross-quantilogram, based on the stationary bootstrap.
Usage
crossqreg.sb(DATA1, DATA2, vecA, k, gamma, Bsize, sigLev)
Arguments
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 |
Details
This function generates critical values for for the cross-quantilogram, using the stationary bootstrap in Politis and Romano (1994).
Value
The boostrap critical values
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.
Politis, Dimitris N., and Joseph P. Romano. "The stationary bootstrap." Journal of the American Statistical Association 89.428 (1994): 1303-1313.
Examples
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)
Quantile Hit
Description
Returns the matrix of quantil-hits
Usage
q.hit(DATA, vecA)
Arguments
DATA |
A matrix that has time-series observations in its columns |
vecA |
A vector of probabilty values at which sample quantiles are estimated |
Details
This function generates the quantile hits given a vector of probabilty values. The quantile hits are obtained for each column of an input matrix.
Value
A matrix of quantile-hits
Author(s)
Heejoon Han, Oliver Linton, Tatsushi Oka and Yoon-Jae Whang
Quantile Hit
Description
Returns the matrix of quantil-hits
Usage
qreg.hit(DATA1, DATA2, vecA)
Arguments
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 |
Details
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.
Value
A matrix of quantile-hits
Author(s)
Heejoon Han, Oliver Linton, Tatsushi Oka and Yoon-Jae Whang
References
Koenker, R., and Bassett Jr, G. (1978). "Regression quantiles." Econometrica, 46(1), 33-50.
Stationary Bootstrap Index
Description
A subfunction for the statioanry bootstrap
Usage
sb.index(Nsize, gamma)
Arguments
Nsize |
The size of the stationary bootstrap resample |
gamma |
A parameter for the stationary boostrap. |
Details
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.
Value
A vector of indicies for the stationary bootstrap
Author(s)
Heejoon Han, Oliver Linton, Tatsushi Oka and Yoon-Jae Whang
References
The Oxford MFE toolbox (http://www.kevinsheppard.com/wiki/MFE_Toolbox) by Kevin Sheppard
The Data Set of Monthly Stock Return and Sotck Variance
Description
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
Usage
data(stock)
Format
A data object with two variables
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.
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 for Systemic Risk Analysis
Description
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.
Usage
data(sys.risk)
Format
A data object with five variables
Details
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)
References
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.