Learn R Programming

tvReg (version 0.5.9)

tvCor: Time-varying Correlation Estimation

Description

Estimation of a time-varying/functional coefficients correlation matrix using the local constant or the local linear kernel smoothing methodologies.

Usage

tvCor(
  x,
  z = NULL,
  ez = NULL,
  bw = NULL,
  cv.block = 0,
  est = c("lc", "ll"),
  tkernel = c("Triweight", "Epa", "Gaussian")
)

Value

A matrix of dimension obs x neq x neq.

Arguments

x

A matrix.

z

A vector with the variable over which coefficients are smooth over.

ez

(optional) A scalar or vector with the smoothing values. If values are not included then the vector z is used instead.

bw

(optional) A scalar.

cv.block

A positive scalar with the size of the block in leave-one block-out cross-validation. By default 'cv.block=0' meaning leave-one-out cross-validation.

est

A character, either "lc" or "ll" for local constant or local linear.

tkernel

A character, either "Triweight, "Epa" or "Gaussian" kernel functions.

See Also

tvCov

Examples

Run this code
##Generate two independent (uncorrelated series)
y <- cbind(rnorm(100, sd = 4), rnorm(100, sd = 1))

##Estimation variance-variance matrix. If the bandwidth is unknown, it can
##calculated with function bwCov()
Rho.hat <-  tvCor(y, bw = 1.4)

##The first time estimate
print(Rho.hat[,,1])
##The mean over time of all estimates
print(apply(Rho.hat, 1:2, mean))
##Generate two dependent variables
y <- MASS::mvrnorm(n = 100, mu = c(0,0), Sigma = cbind(c(1, -0.5), c(-0.5, 4)))

##Estimation variance-variance matrix
Rho.hat <-  tvCor(y, bw = 3.2)
##The first time estimate
print(Rho.hat[,,1])

Run the code above in your browser using DataLab