Help understanding factor modeling, solving for residuals
I am trying to understand and implement a factor model, and I think I might be having some issues. I am trying to solve for the residuals in the equation:
$$ R_{i} = \sum_{A=1}^{K}\beta_{iA} f_{A} + \epsilon_{i} $$ where R is an N x 1 (i = 1, …, N) matrix, and there are K latent factors. I know the values inside the B (factor loadings) matrix and R (returns) matrices beforehand.
My understanding is that this equation gives the values the residuals matrix:
$$ \epsilon = (I_{N} - H)R $$ $$ H = \beta(\beta’\beta)^{-1}\beta' $$ Is this correct way to solve for the residuals?
You see $ (Y,X) $ , you want a relation ship between $ X $ and $ Y $ .
You will assume Linear regression
I.e you assume it exists $ \beta $ such that $ Y=X\beta + \epsilon $ and you want to find $ \beta $ .
Solution: $ \hat{\beta}=(X’X)^{-1}X’Y $ and $ \epsilon = Y-\hat{Y}=Y-X\hat{\beta}=(I-X(X’X)^{-1}X’)Y $
So if you apply to your case :
$ X\to B $
$ \beta \to f $
$ Y\to R $
$ \epsilon \to \epsilon $