[R] easy way to fit saturated model in sem package?
jfox at mcmaster.ca
Thu Jul 12 17:20:58 CEST 2012
If I understand correctly what you want to do, the sem package won't do it.
That is, the sem() function won't do what often is called FIML estimation
for models with missing data. I've been thinking about implementing this
feature, and don't think that it would be too difficult, but I can't promise
when and if I'll get to it. You might also take a look at the lavaan
As well, I must admit to some skepticism about the FIML estimator, as
opposed to approaches such as multiple imputation of missing data. I suspect
that the former is more sensitive than the latter to the assumption of
Senator William McMaster
Professor of Social Statistics
Department of Sociology
Hamilton, Ontario, Canada
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Joshua Wiley
> Sent: July-12-12 2:53 AM
> To: r-help at r-project.org
> Cc: John Fox
> Subject: [R] easy way to fit saturated model in sem package?
> I am wondering if anyone knows of an easy way to fit a saturated model
> using the sem package on raw data? Say the data were:
> mtcars[, c("mpg", "hp", "wt")]
> The model would estimate the three means (intercepts) of c("mpg", "hp",
> "wt"). The variances of c("mpg", "hp", "wt"). The covariance of mpg
> with hp and wt and the covariance of hp with wt.
> I am interested in this because I want to obtain the MLE mean vector
> and covariance matrix when there is missing data (i.e., the sum of the
> case wise likelihoods or so-called full information maximum
> likelihood). Here is exemplary missing data:
> dat <- as.matrix(mtcars[, c("mpg", "hp", "wt")])
> dat[sample(length(dat), length(dat) * .25)] <- NA dat <-
> It is not too difficult to write a wrapper that does this in the OpenMx
> package because you can easily define paths using vectors and get all
> pairwise combinations using:
> combn(c("mpg", "hp", "wt"), 2)
> but I would prefer to use the sem package, because OpenMx does not work
> on 64 bit versions of R for Windows x64 and is not available from CRAN
> presently. Obviously it is not difficult to write out the model, but I
> am hoping to bundle this in a function that for some arbitrary data,
> will return the FIML estimated covariance (and correlation matrix).
> Alternately, if there are any functions/packages that just return FIML
> estimates of a covariance matrix from raw data, that would be great
> (but googling and using findFn() from the sos package did not turn up
> good results).
> Joshua Wiley
> Ph.D. Student, Health Psychology
> Programmer Analyst II, Statistical Consulting Group University of
> California, Los Angeles https://joshuawiley.com/
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help