I need help with HOW principal components can be used like regular variables in linear and logistic regression in R.
I am analyzing a dataset which has 10 variables (including the outcome variable). Originally, I was predicting the outcome variable using different algorithms but the accuracy was not good enough, so I ran a PCA. This is my code for the PCA:
dummies <- dummyVars(" ~ .", data = trainset) trainset_1 <- predict(dummies, newdata = trainset) fit <- princomp(trainset_1, scores = TRUE, cor = T) summary(fit)
I do not know how to use the principal components to predict my outcome in R Studio. My original code for multinomial logistic regression before the PCA for predicting was:
library(nnet) REGmodel <- multinom(Outcome ~ ., data = trainset) summary(REGmodel)
How can I modify the above code to use the variables from the principal component analysis to predict my outcome (which has 2 levels) in R Studio?