CI: Internal functions for the computation of confidence...

CIR 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 calc_rho.

H

an object created with calc_H.

e

an object created with calc_e.

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 \hat{\gamma}_1 in L_{And} (see stats::ar for details).

h

a scalar indicating the bandwidth used by the smoothing function.

Value

  • calc_H() returns a 5 x 5 x t array of elements of class numeric, which corresponds to \hat{H_t} in Choi & Shin (2021).

  • calc_e() returns a t x 5 matrix of elements of class numeric storing the residuals, which corresponds to \hat{e}_t in Choi & Shin (2021).

  • calc_Gamma() returns a 5 x 5 matrix of elements of class numeric, which corresponds to \hat{\Gamma}_l in Choi & Shin (2021).

  • calc_GammaINF() returns a 5 x 5 matrix of elements of class numeric, which corresponds to \hat{\Gamma}^\infty in Choi & Shin (2021).

  • calc_L_And() returns a scalar of class numeric, which corresponds to L_{And} in Choi & Shin (2021).

  • calc_D() returns a t x 5 matrix of elements of class numeric storing the residuals, which corresponds to D_t in Choi & Shin (2021).

  • calc_SE() returns a vector of length t of elements of class numeric, which corresponds to se(\hat{\rho}_t(h)) in Choi & Shin (2021).

Functions

  • calc_H(): computes the \hat{H_t} array.

    \hat{H_t} is a component needed to compute confidence intervals; H_t is defined in eq. 6 from Choi & Shin (2021).

  • calc_e(): computes \hat{e}_t.

    \hat{e}_t is defined in eq. 9 from Choi & Shin (2021).

  • calc_Gamma(): computes \hat{\Gamma}_l.

    \hat{\Gamma}_l is defined in eq. 9 from Choi & Shin (2021).

  • calc_GammaINF(): computes \hat{\Gamma}^\infty.

    \hat{\Gamma}^\infty is the long run variance estimator, defined in eq. 9 from Choi & Shin (2021).

  • calc_L_And(): computes L_{And}.

    L_{And} is defined in Choi & Shin (2021, p 342). It also corresponds to S_T^*, eq 5.3 in Andrews (1991).

  • calc_D(): computes D_t.

    D_t is defined in Choi & Shin (2021, p 338).

  • calc_SE(): computes se(\hat{\rho}_t(h)).

    The standard deviation of the time-varying correlation (se(\hat{\rho}_t(h))) is defined in eq. 8 from Choi & Shin (2021). It depends on D_{Lt}, D_{Mt} & D_{Ut}, themselves defined in Choi & Shin (2021, p 337 & 339). The D_{Xt} 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). \Sexpr[results=rd]{tools:::Rd_expr_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

tcor()

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

}



timevarcorr documentation built on Nov. 8, 2023, 1:11 a.m.