Page 1 of 1

melogit verse runmlwin

Posted: Wed Feb 23, 2022 4:39 pm
by jessica07
Hi there,

I have been trying to run a multilevel model using a binary outcome that includes a random coefficient for age:
runmlwin depression cons age10, level2(mcsid: cons) level1(age:cons) discrete(distribution(binomial) link(logit) denominator(cons)) nopause

However, I get an error message saying "You cannot make covariates random at level 1 when using the binomial response distribution". I have since managed to run the following which gives me a random coefficient for age:
melogit depression age10 || mcsid:age10

I just wanted to check that this is an appropriate alternative or whether there is something in the first runmlwin model that I can change?

Any advice on how to also add a random coefficient for sex to the model would also be great (struggling to do this using both methods!)

Re: melogit verse runmlwin

Posted: Thu Feb 24, 2022 1:10 pm
by ChrisCharlton
You should be able to get this to work if you remove the predictors from the level-1 specification, i.e.:

Code: Select all

generate id = _n
runmlwin depression cons age10, level2(mcsid: cons) level1(id:) discrete(distribution(binomial) link(logit) denominator(cons)) nopause
You can find examples of this and other models in Chapter 9 of the MLwiN manual replication examples.

To add the random coefficient you just need to add the required variable to the level that you want it for, i.e.

Code: Select all

runmlwin depression cons age10, level2(mcsid: cons age10) level1(id:) discrete(distribution(binomial) link(logit) denominator(cons)) nopause

Re: melogit verse runmlwin

Posted: Fri Feb 25, 2022 1:20 pm
by jessica07
Thank you for your response!

When I run the above, I just get zeros for the random coefficients:

runmlwin depression cons age10, level2(mcsid: cons age10) level1(id) discrete(distribution(binomial) link(logit) denominator(cons)) nopause

MLwiN 3.05 multilevel model Number of obs = 64676
Binomial logit response model
Estimation algorithm: IGLS, MQL1

-----------------------------------------------------------
| No. of Observations per Group
Level Variable | Groups Minimum Average Maximum
----------------+------------------------------------------
mcsid | 13310 2 4.9 6
-----------------------------------------------------------

Run time (seconds) = 6.93
Number of iterations = 8
------------------------------------------------------------------------------
depression | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
cons | -3.627076 .0287638 -126.10 0.000 -3.683452 -3.5707
age10 | .1247121 .0054789 22.76 0.000 .1139737 .1354504
------------------------------------------------------------------------------

------------------------------------------------------------------------------
Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval]
-----------------------------+------------------------------------------------
Level 2: mcsid |
var(cons) | 1.979849 .1154474 1.753576 2.206121
cov(cons,age10) | 0 0 0 0
var(age10) | 0 0 0 0
------------------------------------------------------------------------------

Re: melogit verse runmlwin

Posted: Fri Feb 25, 2022 1:41 pm
by ChrisCharlton
I asked George if he could think of an explanation for this and he suggested running the model with PQL2 instead of MQL1, as MQL1 variances are biased downwards.