Let's say that I've got a final component and its score derived from n number of stock returns (time-series data). I want to construct a stock market index using this component (having negative and positive values). There is a good approach to to this? Also, I want that this index to have a starting value of 1,000. Thank you.
I was able to recreate a simple example of creating an index from made up stock returns using the R
tidyverse. Check and see what you think.
options(tidyverse.quiet = TRUE) library(tidyverse) library(broom) set.seed(42) stocks <- tibble( time = as.Date('2009-01-01') + 0:99, X = rnorm(100, 0, 1), Y = rnorm(100, 0, 2), Z = rnorm(100, 0, 4))
This was what the fake returns looks like.
stocks %>% gather(stock, return, -time) %>% ggplot(aes(time, return)) + geom_line(aes(group = stock, color = stock))
stocks %>% gather(stock, return, -time) %>% group_by(time) %>% summarise(avg_ret = mean(return)) -> avg_return avg_return %>% ggplot(aes(time, avg_ret)) + geom_line()
And this is the average return looks like.
Now, this is how one can create an index from the PCA, treating each stock as a different variable.
stocks %>% select(-time) %>% as.matrix() %>% prcomp(.) -> pca pca_index <- augment(pca, data = stocks) %>% mutate( time, base_1000_index = (.fittedPC1*1000)/first(.fittedPC1)) pca_index %>% as.tibble() %>% ggplot(data = ., aes(x = time, y = base_1000_index )) + geom_line()
And this would be the base 1000 index. You can see how I built it from in the second line of the mutate block.
Now, to interpret such index is a bit difficult. The classical idea of a principal component is to to change the data such as you reduce the variability of it, by only having the directions of greater variance.
Using the first component projection o each data point, means that you are capturing the most variability of the stocks. I can't really wrap my head around what that could mean in the form of an index.