CI {timevarcorr} | R Documentation |
Internal functions for the computation of confidence intervals
Description
These functions compute the different terms required for tcor()
to compute the confidence
interval around the time-varying correlation coefficient. These terms are defined in Choi & Shin (2021).
Usage
calc_H(smoothed_obj)
calc_e(smoothed_obj, H)
calc_Gamma(e, l)
calc_GammaINF(e, L)
calc_L_And(e, AR.method = c("yule-walker", "burg", "ols", "mle", "yw"))
calc_D(smoothed_obj)
calc_SE(
smoothed_obj,
h,
AR.method = c("yule-walker", "burg", "ols", "mle", "yw")
)
Arguments
smoothed_obj |
an object created with |
H |
an object created with |
e |
an object created with |
l |
a scalar indicating a number of time points. |
L |
a scalar indicating a bandwidth parameter. |
AR.method |
character string specifying the method to fit the autoregressive model used to compute |
h |
a scalar indicating the bandwidth used by the smoothing function. |
Value
-
calc_H()
returns a 5 x 5 xarray of elements of class numeric, which corresponds to
in Choi & Shin (2021).
-
calc_e()
returns ax 5 matrix of elements of class numeric storing the residuals, which corresponds to
in Choi & Shin (2021).
-
calc_Gamma()
returns a 5 x 5 matrix of elements of class numeric, which corresponds toin Choi & Shin (2021).
-
calc_GammaINF()
returns a 5 x 5 matrix of elements of class numeric, which corresponds toin Choi & Shin (2021).
-
calc_L_And()
returns a scalar of class numeric, which corresponds toin Choi & Shin (2021).
-
calc_D()
returns ax 5 matrix of elements of class numeric storing the residuals, which corresponds to
in Choi & Shin (2021).
-
calc_SE()
returns a vector of lengthof elements of class numeric, which corresponds to
in Choi & Shin (2021).
Functions
-
calc_H()
: computes thearray.
is a component needed to compute confidence intervals;
is defined in eq. 6 from Choi & Shin (2021).
-
calc_e()
: computes.
is defined in eq. 9 from Choi & Shin (2021).
-
calc_Gamma()
: computes.
is defined in eq. 9 from Choi & Shin (2021).
-
calc_GammaINF()
: computes.
is the long run variance estimator, defined in eq. 9 from Choi & Shin (2021).
-
calc_L_And()
: computes.
is defined in Choi & Shin (2021, p 342). It also corresponds to
, eq 5.3 in Andrews (1991).
-
calc_D()
: computes.
is defined in Choi & Shin (2021, p 338).
-
calc_SE()
: computes.
The standard deviation of the time-varying correlation (
) is defined in eq. 8 from Choi & Shin (2021). It depends on
,
&
, themselves defined in Choi & Shin (2021, p 337 & 339). The
terms are all computed within the function since they all rely on the same components.
References
Choi, JE., Shin, D.W. Nonparametric estimation of time varying correlation coefficient. J. Korean Stat. Soc. 50, 333–353 (2021). doi:10.1007/s42952-020-00073-6
Andrews, D. W. K. Heteroskedasticity and autocorrelation consistent covariance matrix estimation. Econometrica: Journal of the Econometric Society, 817-858 (1991).
See Also
Examples
rho_obj <- with(na.omit(stockprice),
calc_rho(x = SP500, y = FTSE100, t = DateID, h = 20, kernel = "box"))
head(rho_obj)
## Computing \eqn{\hat{H_t}}
H <- calc_H(smoothed_obj = rho_obj)
H[, , 1:2] # H array for the first two time points
## Computing \eqn{\hat{e}_t}
e <- calc_e(smoothed_obj = rho_obj, H = H)
head(e) # e matrix for the first six time points
## Computing \eqn{\hat{\Gamma}_l}
calc_Gamma(e = e, l = 3)
## Computing \eqn{\hat{\Gamma}^\infty}
calc_GammaINF(e = e, L = 2)
## Computing \eqn{L_{And}}
calc_L_And(e = e)
sapply(c("yule-walker", "burg", "ols", "mle", "yw"),
function(m) calc_L_And(e = e, AR.method = m)) ## comparing AR.methods
## Computing \eqn{D_t}
D <- calc_D(smoothed_obj = rho_obj)
head(D) # D matrix for the first six time points
## Computing \eqn{se(\hat{\rho}_t(h))}
# nb: takes a few seconds to run
run <- FALSE ## change to TRUE to run the example
if (in_pkgdown() || run) {
SE <- calc_SE(smoothed_obj = rho_obj, h = 50)
head(SE) # SE vector for the first six time points
}