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

luke-tierney at uiowa.edu luke-tierney at uiowa.edu
Fri Jul 13 18:09:37 CEST 2012


Apologies -- replied to the wrong message.

luke

On Fri, 13 Jul 2012, luke-tierney at uiowa.edu wrote:

> They look fine to me.
>
> luke
>
> On Fri, 13 Jul 2012, Joshua Wiley wrote:
>
>> Dear John,
>> 
>> Thanks very much for the reply.  Looking at the optimizers, I had
>> thought that the objectiveML did what I wanted.  I appreciate the
>> clarification.
>> 
>> I think that multiple imputation is more flexible in some ways because
>> you can easy create different models for every variable.  At the same
>> time, if the assumptions hold, FIML is equivalent to multiple
>> imputation, and considerably more convenient.  Further, I suspect that
>> in many circumstances, either option is equal to or better than
>> listwise deletion.
>> 
>> In my case, I am working on some tools primarily for data exploration,
>> in a SEM context (some characteristics of individual variables and
>> then covariance/correlation matrices, clustering, etc.) and hoped to
>> include listwise/pairwise/FIML as options.
>> 
>> I will check out the lavaan package.
>> 
>> Thanks again for your time,
>> 
>> Josh
>> 
>> On Thu, Jul 12, 2012 at 8:20 AM, John Fox <jfox at mcmaster.ca> wrote:
>>> Dear Joshua,
>>> 
>>> 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
>>> package.
>>> 
>>> 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
>>> multinormality.
>>> 
>>> Best,
>>>  John
>>> 
>>> --------------------------------
>>> John Fox
>>> Senator William McMaster
>>>   Professor of Social Statistics
>>> Department of Sociology
>>> McMaster University
>>> Hamilton, Ontario, Canada
>>> http://socserv.mcmaster.ca/jfox
>>> 
>>> 
>>> 
>>> 
>>>> -----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?
>>>> 
>>>> Hi,
>>>> 
>>>> 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 <-
>>>> as.data.frame(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).
>>>> 
>>>> Thanks!
>>>> 
>>>> Josh
>>>> 
>>>> 
>>>> --
>>>> 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
>>>> 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.
>>> 
>> 
>> 
>> 
>> 
>
>

-- 
Luke Tierney
Chair, Statistics and Actuarial Science
Ralph E. Wareham Professor of Mathematical Sciences
University of Iowa                  Phone:             319-335-3386
Department of Statistics and        Fax:               319-335-3017
    Actuarial Science
241 Schaeffer Hall                  email:   luke-tierney at uiowa.edu
Iowa City, IA 52242                 WWW:  http://www.stat.uiowa.edu



More information about the R-help mailing list