For the modeling process, we will use the following steps:
- Extract the components and determine the number to retain
- Rotate the retained components
- Interpret the rotated solution
- Create scores from the non-rotated components
- Use the scores as input variables for regression analysis with MARS and evaluate the performance on the test data
There are many different ways and packages used to conduct PCA in R, including what seems to be the most commonly used prcomp()
and princomp()
functions in base R. However, for my money, it seems that the psych
package is the most flexible with the best options.
To extract the components with the psych
package, you will use the principal()
function. The syntax will include the data and whether or not we want to rotate the components at this time:
> pca <- principal(train_scale, rotate = "none")
You can examine the components by calling the pca
object that we created. However, my primary intent is to determine what should be the...