How to use princomp result in Regression using R

1k Views Asked by At

I'm doing principal component analysis to reduce number of variables for my regression model with low number of data sets & high number of independent variables (around 40 independent variables). I'm using the function princomp to generate the principal component as I have correlations between independent variables.But I don't know how to use princomp output based on the number of PCA.I'm interested in using a subset of the Principal Components for prediction

Can you please help me?

Thanks in advance

1

There are 1 best solutions below

6
damian On
my_pca <- prcomp(data)
summary(my_pca)

Standard deviations in summary are the square roots of the eigenvalues. You can use Kaiser criterion: retain only factors/components with eigenvalues > 1.

pc1 <- my_pca$x[,1] # 1st component
pc2 <- my_pca$x[,2] # 2nd component
...