# Predicting in R using Principal Components [closed]

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?

## closed as off-topic by Michael Chernick, jbowman, Stephan Kolassa, mdewey, SilverfishFeb 22 '18 at 11:03

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question appears to be off-topic because EITHER it is not about statistics, machine learning, data analysis, data mining, or data visualization, OR it focuses on programming, debugging, or performing routine operations within a statistical computing platform. If the latter, you could try the support links we maintain." – Michael Chernick, jbowman, Stephan Kolassa, mdewey, Silverfish
If this question can be reworded to fit the rules in the help center, please edit the question.