[R] FIML using lavaan returns zeroes for coefficients

yrosseel yrosseel at gmail.com
Sat Jul 21 18:59:56 CEST 2012

On 07/20/2012 10:35 PM, Andrew Miles wrote:
> Hello!
> I am trying to reproduce (for a publication) analyses that I ran
> several months ago using lavaan, I'm not sure which version, probably
> 0.4-12. A sample model is given below:
> pathmod='mh30days.log.w2 ~ mh30days.log + joingroup + leavegroup +
> alwaysgroup + grp.partic.w2 + black + age + bivoc + moved.conf +
> local.noretired + retired + ds + ministrytime + hrswork +
> nomoralescore.c + negint.c + cong.conflict.c + nomoraleXjoin +
> nomoraleXleave + nomoraleXalways + negintXjoin + negintXleave +
> negintXalways + conflictXjoin + conflictXleave + conflictXalways '
> mod1 = sem(pathmod, data=sampledat, missing="fiml", se="robust")
> At the time, the model ran fine.  Now, using version 0.4-14, the
> model returns all 0's for coefficients.

What happened is that since 0.4-14, lavaan tries to 'detect' models that 
are just univariate regression, and internally calls lm.fit, instead of 
the lavaan estimation engine, at least when the missing="ml" argument is 
NOT used. (BTW, I fail to understand why you would use lavaan if you 
just want to fit a univariate regression).

When missing="ml" is used, lavaan normally checks if you have fixed x 
covariates (which you do), and if fixed.x=TRUE (which is the default). 
In 0.4, lavaan internally switches to fixed.x=FALSE (which implicitly 
assumes that all your predictors are continuous, but I assume you would 
not using missing="ml" otherwise). Unfortunately, for the 'special' case 
of univariate regression, it fails to do this. This behavior will likely 
change in 0.5, where, by default, only endogenous/dependent variables 
will be handled by missing="ml", not exogenous 'x' covariates.

To fix it: simply add the fixed.x=FALSE argument, or revert to 0.4-12 to 
get the old behavior.

Hope this helps,


More information about the R-help mailing list