Dear Stata listers,
I would like to fit a multilevel MIMIC model in gsem. To have an example, I would like to add a predictor to the model specified in the sem/gsem manual on page 318 (http://www.stata.com/manuals13/sem.pdf). The problem is that it refuses to converge. It is possible to use gllamm instead (and it converges), but it takes a long time, so it would be nice if there was a way of making gsem work even in this case.
Below I present the code I have used. The model of interest is M3. M1 and M2 is just for reference, since I want a combination of those two. M1 is a MIMIC model, ignoring the multilevel structure of the data. M2 is an ordinary multilevel version of the measurement model (directly copied from the sem/gsem manual). I have also included the syntax for the tree models using gllamm (including the correct starting values to increase speed for you, if you want to try).
I have tried to figure out why M3 won't converge in gsem. The things I have tried are:
- Change integration method using intmethod()
- Change the number of integration points from 3 to 15
- Try different starting values using init()
- Simulate a similar dataset with more observed variables (the data generating process was exactly the same as the model I would like to fit)
- Simulate a similar dataset with more clusters (100)
Does any of you have an idea? What am I doing wrong?
Best regards
Jonas
I would like to fit a multilevel MIMIC model in gsem. To have an example, I would like to add a predictor to the model specified in the sem/gsem manual on page 318 (http://www.stata.com/manuals13/sem.pdf). The problem is that it refuses to converge. It is possible to use gllamm instead (and it converges), but it takes a long time, so it would be nice if there was a way of making gsem work even in this case.
Below I present the code I have used. The model of interest is M3. M1 and M2 is just for reference, since I want a combination of those two. M1 is a MIMIC model, ignoring the multilevel structure of the data. M2 is an ordinary multilevel version of the measurement model (directly copied from the sem/gsem manual). I have also included the syntax for the tree models using gllamm (including the correct starting values to increase speed for you, if you want to try).
Code:
use http://www.stata-press.com/data/r13/gsem_cfa, clear ******************************************************* **gsem *M1: MIMIC, ignoring the two-level structure gsem (MathAb -> q1 q2 q3 q4 q5 q6 q7 q8, logit) (test1->MathAb) *M2: Multilevel, ignoring MIMIC gsem (MathAb M1[school] -> q1@1 q2@c2 q3@c3 q4@c4 q5@c5 q6@c6 q7@c7 q8@c8, logit) *M3: Multilevel MIMIC gsem (MathAb M1[school] -> q1@1 q2@c2 q3@c3 q4@c4 q5@c5 q6@c6 q7@c7 q8@c8, logit) (test1->MathAb) ******************************************************* **gllamm *Prepare data reshape long q, i(school id) j(item_nr) tab item_nr, gen(item) *M1: MIMIC, ignoring the two-level structure eq load: item1-item8 eq f1: test1 matrix startvalues = (-8.4074878, -3.8322998, -4.260515, -2.7827617, -6.9646923, -5.2550208, -7.2203986, -4.8198082, .39880205, .52284207, .29164475, .81889015, .58585508, .86782765, .56756038, 1.3144458, .11179224) gllamm q item1-item8, nocons link(logit) family(binomial) i(id) eqs(load) geqs(f1) nip(10) adapt from(startvalues) copy *M2: Multilevel, ignoring MIMIC eq load: item1-item8 generate zero = 0 eq idload: zero // Highest level latent variable not directly measured matrix b = (0,1\0,0) constraint define 1 [b1_2]_cons=1 matrix startvalues = (.03857517, -.46330917, .15333115, -.32468838, -.04904144, -.31353169, .10392782, -.0264091, .38765189, .48714771, .34073534, .8328015, .62678742, .76609757, .56012289, 1.436113, -.4145632) gllamm q item1-item8, nocons link(logit) family(binomial) i(id school) eqs(load idload) bmatrix(b) constr(1) nip(10) adapt from(startvalues) copy *M3: Multilevel MIMIC eq load: item1-item8 eq f1: test1 cap gen zero = 0 eq idload: zero // Highest level latent variable not directly measured matrix b = (0,1\0,0) constraint define 1 [b1_2]_cons=1 matrix startvalues = (-8.6569178, -4.001246, -4.2952046, -2.9533139, -7.0569356, -5.4135279, -7.0647268, -4.9809956, .40652907, .51173863, .3027107, .80597369, .58712371, .82476257, .56976233, 1.2862137, .33178491, .11511107) gllamm q item1-item8, nocons link(logit) family(binomial) i(id school) eqs(load idload) geqs(f1) bmatrix(b) constr(1) nip(10) adapt from(startvalues) copy
- Change integration method using intmethod()
- Change the number of integration points from 3 to 15
- Try different starting values using init()
- Simulate a similar dataset with more observed variables (the data generating process was exactly the same as the model I would like to fit)
- Simulate a similar dataset with more clusters (100)
Does any of you have an idea? What am I doing wrong?
Best regards
Jonas