Errors in estimating 2-level model with random slopes

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
Jacqueline
Posts: 10
Joined: Wed Nov 23, 2011 3:33 pm

Errors in estimating 2-level model with random slopes

Post by Jacqueline »

Dear runmlwin users,

I am trying to explain variability in length of hospital stay using a multilevel Poisson model (at the moment, I am interested in two levels – patients clustered within hospitals – but I would like to extend this to incorporate other levels and non-hierarchical structures). I am estimating separate models for three medical conditions, but there is some commonality across models as each contains patient-level variables relating to socio-demographics, stay-related characteristics and clinical characteristics (some of which are specific to the condition under study).

I am particularly interested in ascertaining whether the relationship between length of stay and a categorical variable (containing four categories, included in the models as three dummy variables with the fourth category as the reference) differs across hospitals. So, I am trying to estimate a 2-level Poisson model with random slopes for the three dummy variables. However, when I run this model, I receive the following error message for one of the conditions:

**
Error detected by MLN
error while obeying batch file C:\Program Files (x86)\MLwiN v2.25\discrete\pre at line number 65:
calc 'F~(H)' = expo('H')

281 numeric errors in calculate command, first 20 affected entries listed.
Affected entries replaced with system missing..See output window for details.
**

and this error message for another condition:

**
Run-time error '6':
Overflow
**

Frustratingly, the model seems to work for the third medical condition!

I would really appreciate any guidance on how I might rectify these errors.

Many thanks,

Jacqueline
GeorgeLeckie
Site Admin
Posts: 432
Joined: Fri Apr 01, 2011 2:14 pm

Re: Errors in estimating 2-level model with random slopes

Post by GeorgeLeckie »

Hi Jacqueline,

Good to hear from you

For complex models its is sensible to build the model up to your model of interest gradually by fitting a sequence of increasingly complex models
For each model in this sequence, use the parameter estimates from the previous model to estimate the current model.
Suggest doing all of this using MQL1 (as opposed to PQL2).
Once you have your model of interest estimated using MQL1 you can then move over to PQL2 or ideally MCMC making sure to use the MQL1 estiamtes as the starting values in each case.

So in terms of your analyses, you might fit five models to build up to your model of interest

Model 1 - First fit the two-level variance components model (i.e. the two-level random intercept model with no covariates)
Model 2 - Then gradually add in the covariates to the fixed part of the model
Model 3 - Then add the random coefficient on the biggest group
Model 4 - Then add the random coefficient on the second biggest group
Model 5 - Then add the random coefficient on the final group

For each model use the initsprevious option to use the parameter estimates from the previous model as starting values for fitting the current model.

In terms of your specific problem, you should check that the distribution of patients across the four groups of your categorical variable and then examine how this varies across the level-2 units.

Try all of this, I hope it helps, otherwise get back to us on the forum

Best wishes

George
Jacqueline
Posts: 10
Joined: Wed Nov 23, 2011 3:33 pm

Re: Errors in estimating 2-level model with random slopes

Post by Jacqueline »

Hi George,

Many thanks for your response and your suggestions – much appreciated.

I have followed your suggested strategy on building up the model gradually and using the results from the previous model as the starting values. However, unfortunately, I am still getting error messages on the addition of some of the random coefficients. For the first medical condition, there seems to be a specific problem when trying to add the random coefficient for the second group (the model seems to work fine when the random coefficients for the third and fourth groups are included). The following error message appears when the random coefficient for the second group is added to a model that already includes the random coefficients for the third and fourth groups:

**
error while obeying batch file C:\Program Files (x86)\MLwiN v2.25\discrete\pre at line number 65:
calc 'F~(H)' = expo('H')
281 numeric errors in calculate command, first 20 affected entries listed.
Affected entries replaced with system missing.
**

To try to shed some more light, I have estimated a very basic model with the groups included as the only explanatory variables in the fixed part and the random coefficients associated with these groups for this medical condition. In this model, the random coefficient for the second group is estimated as zero. Perhaps this could be the reason for the difficulties with the more complicated model?

For the second medical condition, the problem seems to be adding a third random coefficient to a model that already includes two random coefficients (the group to which this random coefficient applies does not seem to matter). The following error message appears:

**
error while obeying batch file C:\Program Files (x86)\MLwiN v2.25\discrete\pre at line number 65:
calc 'F~(H)' = expo('H')
459 numeric errors in calculate command, first 20 affected entries listed.
Affected entries replaced with system missing.
**

Could these messages mean that the random coefficient models are asking too much of the data? The data are highly concentrated in group 1 – approximately 93% for the first medical condition and 80% for the second medical condition. Perhaps this means that there is insufficient variation in the data?

Thanks also for your advice regarding checking the distribution of patients with each group. The groups indicate different categories of patient complexity (group 1 containing less complex patients than group 2, and so on). Therefore, I would expect hospital stays to be longer for group 2 compared to group 1, and for group 3 compared to group 2. However, having looked at the mean length of stay by group by hospital, this expected ordering does not hold across all hospitals. Hence the reason for trying to estimate random coefficients models.

Once again, many thanks for your very helpful suggestions and advice.

Kind regards,

Jacqueline
GeorgeLeckie
Site Admin
Posts: 432
Joined: Fri Apr 01, 2011 2:14 pm

Re: Errors in estimating 2-level model with random slopes

Post by GeorgeLeckie »

Hi Jacqueline,

Yes it does sound like you are asking a lot from your data. A discrete response model with a random intercept and four random coefficients is quite computationally demanding.

The patients are also very unevenly distributed across groups. Your groups 2, 3 and 4 have low proportions of patients. In some hospitals the number of patients in these groups might be very low making it hard to identify the hospital specific coefficients and therefore random coefficient variances.

Some suggestions

You could pool groups 2 and 3 in the random part of the model. So the fixed part would have four effects, one for each group while the random part would have three effects one for group 1 one for group 2 and 3 combined and one for group 4. This model is an intermediate one between the random intercept one and the one where you make all four groups have random coefficients.

Given that you would want to fit the final model by MCMC, you could bypass the quasilikelihood estimation stage by manually specify the starting values for the random part of the model and then fit the model in MCMC. Note, still use the quasilikelihood estimates for the fixed part starting values.

If you observe the underlying continuous complexity variable from which your four groups are defined you could instead enter that in the model as a flexible polynomial with random coefficients on the linear and perhaps quadratic terms

Best wishes

George
Post Reply