An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20120720/8f2d243e/attachment.pl>
FIML using lavaan returns zeroes for coefficients
5 messages · Andrew Miles, yrosseel, ya +1 more
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, Yves. http://lavaan.org
1 day later
Thanks for the helpful explanation. As to your question, I sometimes use lavaan to fit univariate regressions simply because it can handle missing data using FIML rather than listwise deletion. Are there reasons to avoid this? BTW, thanks for the update in the development version. Andrew Miles
On Jul 21, 2012, at 12:59 PM, yrosseel wrote:
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, Yves. http://lavaan.org
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20120723/ae9701a2/attachment.pl>
Hi Andrew, I do not think there is a reason to avoid it for univariate regression other than: 1) as was stated the predictors must be continuous 2) it will be slower (non issue for a handful of regressions on a few thousand cases but for people doing thousands of regression on millions of observations, a big concern) In the next month or so, I may have a beta version of a package primarily providing helper functions for fitting SEM models, but could also include an lm()ish wrapper to lavaan. It would use the traditional formula interface, but issue a warning if factor variables or variables with insufficient unique values were used (as either predictors or outcomes). If anyone would be interested in beta testing, feel free to email me. Once I have a basic package working, it will go up on github. Cheers, Josh
On Mon, Jul 23, 2012 at 6:07 AM, Andrew Miles <rstuff.miles at gmail.com> wrote:
Thanks for the helpful explanation. As to your question, I sometimes use lavaan to fit univariate regressions simply because it can handle missing data using FIML rather than listwise deletion. Are there reasons to avoid this? BTW, thanks for the update in the development version. Andrew Miles On Jul 21, 2012, at 12:59 PM, yrosseel wrote:
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, Yves. http://lavaan.org
______________________________________________ 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.
Joshua Wiley Ph.D. Student, Health Psychology Programmer Analyst II, Statistical Consulting Group University of California, Los Angeles https://joshuawiley.com/