I run the factor analysis and generated 5 factors. Now, I want to add these factors in the original dataset to run regression keeping these factors using independent variables. Can anybody please tell me how how to do it? The code I used for factor analysis is the following:
result.1<-subset(result,select=c(17:27))
fa.parallel(result.1)
View(result.1)
result.2<-factanal(result.1,factors=5,rotation="promax")
print(result.2)
print(result.2, digits = 2, cutoff = .2, sort = TRUE)
colnames(result.2$loadings)<-c("Fac_1","Fac_2","Fac_3","Fac_4","Fac_5")
print(loadings(result.2), digits = 2, cutoff = .2, sort = TRUE)
I tried to use cbind to get the new variable columns of factors, but unfortunately it didn’t work.
result.fac<-cbind(result,result.2)
Regards,
Ari
You have to save the scores computed by factanal and
cbindthose to the original dataset. E.g.: