time_varying_cov | R Documentation |
This function estimates a time-varying covariance matrix using local principal component analysis and the soft thresholding for residual shrinkage. By default, only the total covariance matrix is returned. Optionally, the user can retrieve all intermediate components of the estimation process. The procedure is available either as a stand-alone function or as a method in the 'TVMVP' R6 class.
time_varying_cov(
obj,
max_factors = 3,
kernel_func = epanechnikov_kernel,
M0 = 10,
rho_grid = seq(0.005, 2, length.out = 30),
floor_value = 1e-12,
epsilon2 = 1e-06,
full_output = FALSE
)
obj |
An object of class TVMVP with the data. |
max_factors |
The number of factors to use in local PCA. |
kernel_func |
The kernel function to use (default is |
M0 |
Integer. The number of observations to leave out between the two sub-samples in the adaptive thresholding procedure. Default is 10. |
rho_grid |
A numeric vector of candidate shrinkage parameters |
floor_value |
A small positive number specifying the lower bound for eigenvalues in the final positive semidefinite repair. Default is |
epsilon2 |
A small positive tuning parameter for the adaptive thresholding. Default is |
full_output |
Logical; if |
The function estimates a time-varying covariance matrix using Local PCA:
\hat{\Sigma}_{r,t}=\hat{\Lambda}_t \hat{\Sigma}_F \hat{\Lambda}_t' + \tilde{\Sigma}_e
Where \hat{\Lambda}_t
is the factor loadings at time t, \hat{\Sigma}_F
is the factor covariance matrix, and \tilde{\Sigma}_e
is regularized covariance matrix of the idiosyncratic errors.
Two usage styles:
# Function interface tv <- TVMVP$new() tv$set_data(returns) cov <- time_varying_cov(tv, m = 5) # R6 method interface tv$determine_factors(max_m = 5) cov <- tv$time_varying_cov()
By default, a covariance matrix. If full_output = TRUE
, a list containing:
total_cov
– the estimated covariance matrix,
residual_cov
– the residual (idiosyncratic) covariance,
loadings
– estimated factor loadings,
best_rho
– optimal shrinkage parameter,
naive_resid_cov
– residual covariance before shrinkage
Lillrank, E. (2025). A Time-Varying Factor Approach to Covariance Estimation
Chen, J., Li, D., & Linton, O. (2019). A new semiparametric estimation approach for large dynamic covariance matrices with multiple conditioning variables. Journal of Econometrics, 212(1), 155–176.
Fan, Q., Wu, R., Yang, Y., & Zhong, W. (2024). Time-varying minimum variance portfolio. Journal of Econometrics, 239(2), 105339.
set.seed(123)
returns <- matrix(rnorm(100 * 30), nrow = 100, ncol = 30)
# Initialize object
tv <- TVMVP$new()
tv$set_data(returns)
# Using function interface
time_varying_cov(obj = tv, m = 3)
# Or using R6 method
tv$time_varying_cov(m=3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.