Question
Asked 13 March 2022
  • Unisanté, Epalinges-Lausanne, Switzerland

How to write multilevel models in gsem that are identical to models in MIXED using STATA?

In gsem of STATA we can test random-intercept and random-slope models (multilevel) (see example38g in the manual). STATA MULTILEVEL MIXED-EFFECTS "me" deals with multilevel mixed-models, in particular MIXED for continuous outcomes.
I asked myself: Do I get the same results if I use gsem or MIXED? For the moment my answer is yes and no.....
In MIXED we have several options: we can use ML or REML estimation method; we can define different residual variance structures,....
I ran a gsem 2-level random-intercept model (id defines level 2 and session_coded defines level 1 nested within level 2) using own data
gsem (rd <- mpa_level i.session_coded i.order M1[id])
I found out that I get exactly the same results with the following mixed model
mixed rd c.mpa_level i.session_coded i.order ||id:, ml cformat(%9.4f)
However, using reml is prefarable; furthermore, an heterogenous residual variance better fits the specific data rather than the default. So the "best" MIXED model I would use is
mixed rd i.session_coded c.mpa_level i.order ||id:, reml residuals(ind, by(session_coded)) cformat(%9.4f)
With this model, the results are quite different.
My question: is it possible to write in gsem a model that is equivalent to this latter "more sophisticated" mixed model? Do you have any readings to suggest?
Why am I asking this question? Because in a second stage I would like to run multilevel-mediation analyses using gsem but ideally I would like to keep the level of "sophistication" that I have with MIXED (reml, residual variance, etc.).
Best regards,

All Answers (3)

Mehmet Mehmetoglu
Norwegian University of Science and Technology
Patrick Gomez, As you already have found out, the -gsem- command can produce the exact same results as those generated by the defaults of the -mixed- command. As far as I know, the -gsem- command has only ml available for the estimation of parameters. I think the same applies to specifying the structure of the residuals as well in that it by default assumes the restype of "independent". To be completely sure, you can send your -mixed- code to StataTech and see if they can replicate it using the -gsem- command, and let us know the outcome as well if you like. Thanks.
Bruce Weaver
Lakehead University
In addition to what Mehmet Mehmetoglu has suggested, you might consider posting your question to Statalist.
Patrick Gomez
Unisanté, Epalinges-Lausanne, Switzerland
The technical support of STATA wrote me:
Currently, we don't have a command to estimate generalized structural equation models via REML. Also, residuals in -gsem- are assumed to be i.i.d., there is not an option to change this.

Similar questions and discussions

Related Publications

Got a technical question?
Get high-quality answers from experts.