[R] easy way to fit saturated model in sem package?

yrosseel yrosseel at gmail.com
Mon Jul 23 10:41:51 CEST 2012


> I will check out the lavaan package.

Dear Joshua,

The lavaan package may help you. The FIML estimator typically starts 
with the EM algorithm to estimate the moments of the unrestricted model. 
There is no 'one-shot' function for it, at the moment, but if you only 
need those moments, you can do something like this:

Suppose your data is a data.frame called 'HS.missing', then the 
following commands can be used to get the estimated moments:

library(lavaan)

Data <- lavaan:::lavData(HS.missing, ov.names=names(HS.missing), 
missing="fiml")

# we assume only 1 group
Missing <- lavaan:::getMissingPatternStats(X = Data at X[[1L]], Mp = 
Data at Mp[[1L]])

# compute moments using EM algorithm
Moments <- lavaan:::estimate.moments.EM(X=Data at X[[1L]], M=Missing, 
verbose=TRUE)

# estimated covariance matrix
Moments$sigma

# estimated mean vector
Moments$mu


Hope this helps,

Yves Rosseel
http://lavaan.org



More information about the R-help mailing list