I am implementing a PCA using prcomp.
pcaunemp <- prcomp(rawtChange,center = TRUE, scale=FALSE)
I am using the lm function for regression like so:
reg <- lm(tr[5:365,1] ~ tr[1:361,1] + tr[2:362,1] + tr[3:363,1] + tr[4:364,1])
If I want to only use the first 8 components as independent variables for a regression, how do I extract the components?
I can extract first 8 PCs with:
Credits to 李哲源 who answered in the comments