Create a matrix that includes an index and the constituents: for example S&P500 and its constituents daily returns for the past 5 years.
A typical momentum strategy can be implemented using the following tweaks:
- Estimate the principle components (in R use library stats and function princomp).
- Regress each stock against the n most significant principal components.
- Use the residuals to get a z-score or any other normalize metric for each stock.
- Set a threshold for the z-score to select stocks to trade (trading trigger).
- Select the weights based on z-score.
This is a relatively complex strategy since it involves the implementation of principal components analysis, so we are going to present a few frequent questions below:
1. Do you include SPX and 500 constituents and run a PCA or is SPX supposed to be excluded?
2. Is the PCA applied on returns or prices?
3. Then we regress the returns of each stock for our lookback period againsts the n principal components. How do we specify what is the cutpoint and how many principal components to include?
1) SPX should be included.
2) Returns are more meaningful since they’re closer to be stationary than levels.
3) Plotting the cumulative sum of eigenvalues can actually be very useful. The plot will provide a good indication of when most variation is explained.