localPCA | R Documentation |
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.
localPCA(returns, bandwidth, m, kernel_func = epanechnikov_kernel)
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
|
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
and bandwidth
.
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.
A list with the following components:
factors
: A list of length T
, where each element is a T × m
matrix of local factors.
loadings
: A list of length T
, where each element is a p × m
matrix of factor loadings.
m
: The number of factors extracted.
weights
: A list of length T
, where each element is a vector of kernel weights used at that time point.
f_hat
: A T × m
matrix of one-step-ahead factor estimates.
Su, L., & Wang, X. (2017). On time-varying factor models: Estimation and testing. Journal of Econometrics, 198(1), 84–101.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.