> Date: Wed, 11 Apr 2012 09:12:06 -0400
> From: Robert Seyfarth <seyfarth@psych.upenn.edu>
> To: <r-sig-mac@stat.math.ethz.ch>
> Subject: [R-SIG-Mac] factor analysis problem
> Message-ID: <4F858326.8030703@psych.upenn.edu>
> Content-Type: text/plain
> 
> 
> 
> I have a dataset, d1, on which I'd like to perform a factor analysis. 
> Because there are some missing values that I don't want to lose or 
> interpolate, and because factanal is less tolerant of these in a dataset 
> than it is in a correlation matrix (it requires na.action=na.omit), I 
> calculated a correlation matrix as follows:
> 
> r.matrix<-cor(d1, use="pairwise.complete.obs")
> There are 44 cases in the dataset
> 
> However, when I type the command for factor analysis
> 
> Factor2<-factanal(d1,2,covmat=r.matrix,n.obs=44,scores="regression")
> 
> I get the error message
> 
> Error in factanal(d1, 2, covmat = r.matrix, n.obs = 44, scores = 
> "regression") : requested scores without an 'x' matrix
> 
> What am I doing wrong?
> 
> Thanks,  Robert Seyfarth

You're not doing anything wrong, other than expecting factanal to do something it can't.   If you want factor scores from factanal, you need to pass the matrix of indicator variables.   But as you've discovered, factanal doesn't like missing data, which can be short-circuited by passing factanal a covariance/correlation matrix computed pairwise (which may or may not be PD, depending on the nastiness of the missingness etc, but thats a different story).

So you're kind of stuck.   Factor scores presume the indicators are observed, or at least the two methods implemented in factanal require this.

All this suggests that if you really want factor scores as a "deliverable" from the factor analysis, you'll probably need to try one of the following:

(a) this is a bit ugly -- (1) estimate the factor analysis model with the correlation matrix computed with pairwise.complete.obs; (2) compute the factor scores "by hand" for rows of d1 that are completely observed.   You can look at the code for factanal to see how the factor scores are computed, or consult one of the many texts on the topic, for the formulas for Bartlett or regression scoring methods.   You'd then need to pull the necessary matrix objects out of the factanal object yourself, with is only a little bit of work.   Still, no factor scores for anything other than a completely observed case, but at least "all the cases" have contributed to the factor analysis per se.

(b) go ahead and run the analysis with listwise deletion, giving up on factor scores for anything other than completely observed cases, which you said you didn't want to do.

(c) patch/impute the missing data ahead of the factor analysis, which you said you didn't want to do; 

(d) assume MAR and run the factor analysis at the same time as you impute missingness, at which point I'd be reaching for tools beyond factanal and more like a DIY Bayesian setup in JAGS/BUGS etc (see Ch9 of Bayesian Analysis for the Social Sciences).    Now you're computing a posterior density over factor scores, missing indicators, factor analysis parameters (loadings, factor VC matrix, indicator m'ment error variance), given the observed indicators, which is a bit more complicated, to be sure.

"The problem with missing data is that it is missing"

Regards

-- Simon Jackman

Simon Jackman, Depts of Political Science & (by courtesy) Statistics, 
Stanford University, Stanford, CA 94305-6044, USA.
http://jackman.stanford.edu
Co-Principal Investigator, American National Election Studies






	[[alternative HTML version deleted]]

