[R] CFA with lavaan or with SEM

John Fox jfox at mcmaster.ca
Wed Jan 23 14:59:30 CET 2013


Dear David,

On Wed, 23 Jan 2013 11:19:09 +0000
 David Purves <David.Purves at glasgow.ac.uk> wrote:
> Hi
> 
> Sorry for the rather long message.
> 

. . .

> 
> I have tried the analysis using John Fox's SEM package / command.
> 
> I calculate the correlation matrix with smoothing
> 
> my.cor<-hetcor(north.dat.sub,use="pairwise.complete.obs")$correlations
> 
> This returns the warning indicating that the correlation matrix was adjusted to make it positive definite. However the following sem model does not run, with the error message that the matrix is non-invertible.
> 
> mod1<-sem::sem(sem .model.1, S=my.cor, 300)
> 
> Should the smoothing not allow it to be inverted?
> 

If the input correlation matrix is really positive definite, then it has an inverse. You could check directly, e.g., by looking at the eignevalues of the tetrachoric correlation matrix. There's very little here to go on, not even the error message produced by sem(). By the way, I assume that you didn't really call sem in the sem package as sem::sem in a session in which lavann was loaded. I'm not sure what would happen if you did that.

Best,
 John

------------------------------------------------
John Fox
Sen. William McMaster Prof. of Social Statistics
Department of Sociology
McMaster University
Hamilton, Ontario, Canada
http://socserv.mcmaster.ca/jfox/

> 
> ______________________________________________
> R-help at 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.



More information about the R-help mailing list