melogit verse runmlwin

Welcome to the forum for runmlwin users. Feel free to post your question about runmlwin here. The Centre for Multilevel Modelling take no responsibility for the accuracy of these posts, we are unable to monitor them closely. Do go ahead and post your question and thank you in advance if you find the time to post any answers!

Go to runmlwin: Running MLwiN from within Stata >> http://www.bristol.ac.uk/cmm/software/runmlwin/
Post Reply
jessica07
Posts: 2
Joined: Wed Feb 23, 2022 4:25 pm

melogit verse runmlwin

Post 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!)
ChrisCharlton
Posts: 1354
Joined: Mon Oct 19, 2009 10:34 am

Re: melogit verse runmlwin

Post 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
jessica07
Posts: 2
Joined: Wed Feb 23, 2022 4:25 pm

Re: melogit verse runmlwin

Post 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
------------------------------------------------------------------------------
ChrisCharlton
Posts: 1354
Joined: Mon Oct 19, 2009 10:34 am

Re: melogit verse runmlwin

Post 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.
plopblurt
Posts: 9
Joined: Tue Jan 03, 2023 4:59 am

Re: melogit verse runmlwin

Post by plopblurt »

Since in MLwiN turning green indicates that the parameters have converged to a single value, which is not the case in this situation, the estimates won't turn green. Do the parameter estimates change if you run the model using your original data file with missing values (which would turn green geometry dash world) and then perform the imputation analysis?
Post Reply