[R] Help with factanal and missing values
John Fox
jfox at mcmaster.ca
Tue Jul 13 18:12:53 CEST 2004
Dear Antonio,
> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of
> Antonio Prioglio
> Sent: Tuesday, July 13, 2004 9:32 AM
> To: r-help at stat.math.ethz.ch
> Subject: [R] Help with factanal and missing values
>
> Hi list,
>
> I'm performing a series of confirmatory factor analysis on
> different groupings of items from data collected with
> questionnaires. There are some missing values.
>
> For those sets with no missing values I call
> factanal(datamatrix,factors=n)
>
> where datamatrix is a table of all observations for the items
> under investigation.
>
> This call fails when there are missing values.
> help(factanal) does not give an example on calls with
> na.action and and mentiones a formula.
>
> (Venables and Ripley, 2002 give only one example on p. 323
> for a case where the covariance has already been calculated)
>
> Could someone give me an example on such a call for a simple CFA?
Two solutions are to use na.omit() to eliminate observations with missing
data -- factanal(na.omit(datamatrix), factors=n) -- or to use a formula
argument to factanal and pass the data as a data frame via the data argument
-- factanal(~ var1 + ... + vark, factors=n, data=as.data.frame(datamatrix)).
By the way, what factanal() does would conventionally be described as
exploratory, not confirmatory, factor analysis. For the latter, you might
try the sem package.
I hope that this helps,
John
More information about the R-help
mailing list