This function estimates the residuals of asset returns after removing the effect of factor-driven returns.
residuals(factors, loadings_list, returns)A matrix of residuals where each row corresponds to a time period and each column corresponds to an asset.
A matrix containing the step-ahead-factors of from the localPCA function.
A list where each element is a matrix of loadings corresponding to the factors for each time period.
A matrix of asset returns with rows representing time periods and columns representing assets.
For each time period \(t\), the function models the asset returns as: $$R_t = F_t \Lambda_t + \epsilon_t$$ where \(R_t\) is the vector of asset returns, \(F_t\) is the t'th row of the factor matrix, \(\Lambda_t\) is the loadings matrix, and \(\epsilon_t\) represents the residuals.
The residuals are computed as the difference between actual returns and the modeled returns.