Hi David, >> I am doing a factor analysis on survey data with missing values. ... Is >> there a way to subset >> from my original data set that will work with factanal() and preserve the >> original rows or that >> will allow me to append the factor scores back onto the original dataset >> with the proper >> rows and NAs where there could be no data?
The "trick" is to call factanal with the formula interface, and to specify na.action=na.exclude. This is documented under ?factanal &c and will put NAs in the right place(s) to pad out scores. ## Dummy T.fac <- factanal(~ SrvP+EdcT+EcnD+BdvP+EnvP, data=TTDat, factors=2, na.action=na.exclude, scores="regression") ?na.exclude Regards, Mark. David G. Tully wrote: > > I am sure there is a simple way to do the following, but i haven't been > able to find it. I am hoping a merciful soul on R-help could point me in > the right direction. > > I am doing a factor analysis on survey data with missing values. to do > this, I run: > > FA1<-factanal(na.omit(DATA), factors = X, rotation = 'oblimin', scores = > 'regression') > > Now that I have my factors and factor scores, I want to add those scores > back to my original dataset so I can plot factor scores by demographics. > However, when I try to add the scores back to the original data frame, > the variables are of different lengths. > > Is there a way to subset from my original data set that will work with > factanal() and preserve the original rows or that will allow me to > append the factor scores back onto the original dataset with the proper > rows and NAs where there could be no data? > > Again, I apologize if I am missing something basic. I am a self taught R > user and couldn't find an answer to this question. > > Thanks in advance, > David > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > > -- View this message in context: http://www.nabble.com/adding-factor-scores-back-to-an-incomplete-dataset...-tp25140959p25142328.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.