localPCA {TVMVP} | R Documentation |
Perform Local PCA Over Time
Description
This function performs a local principal component analysis (PCA) on asset returns for each time
period, aggregating the results over time. It calls an internal function local_pca()
at each
time index to extract local factors, loadings, and one-step-ahead factor estimates, and stores these
results in lists. It uses previously computed factors to align the sign of the new factors.
Usage
localPCA(returns, bandwidth, m, kernel_func = epanechnikov_kernel)
Arguments
returns |
A numeric matrix of asset returns with dimensions |
bandwidth |
Numeric. The bandwidth parameter used in the kernel weighting for the local PCA. |
m |
Integer. The number of factors to extract. |
kernel_func |
Function. The kernel function used for weighting observations. Default is
|
Details
The function processes the input returns over T
time periods by iteratively calling the
local_pca()
function. For each time t_i
:
Kernel weights are computed using the specified
kernel_func
andbandwidth
.The returns are weighted by the square root of these kernel weights.
An eigen decomposition is performed on the weighted returns' covariance matrix to extract the top
m
eigenvectors, which are scaled by sqrt(T) to form the local factors.The signs of the new factors are aligned with those of the previous factors.
The factor loadings are computed by projecting the weighted returns onto the local factors, normalized by
T
.A second pass computes a one-step-ahead factor estimate for the current time period.
Value
A list with the following components:
-
factors
: A list of lengthT
, where each element is aT × m
matrix of local factors. -
loadings
: A list of lengthT
, where each element is ap × m
matrix of factor loadings. -
m
: The number of factors extracted. -
weights
: A list of lengthT
, where each element is a vector of kernel weights used at that time point. -
f_hat
: AT × m
matrix of one-step-ahead factor estimates.
References
Su, L., & Wang, X. (2017). On time-varying factor models: Estimation and testing. Journal of Econometrics, 198(1), 84–101.