Fitting a crossclassified model in Stata

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
jodavies87
Posts: 4
Joined: Tue Sep 10, 2019 2:10 pm

Fitting a crossclassified model in Stata

Post by jodavies87 »

Hello,

I’m hoping to use runmlwin to run some cross-classified models in Stata (data set too large for Stata to handle with normal cross-classified procedures) and was hoping that a user here may be able to help me with the syntax.

I have tried the following syntax (adapted from the runmlwin user guide) however the estimates produced are those as would be if the data followed a standard hierarchical 3-level structure. Can this syntax be adapted to tell Stata to treat the data as being cross-classified?

Null model, initial estimates:
runmlwin ELITE cons, ///
> level3(SCHOOL_ID: cons) ///
> level2(LSOA_ID: cons) ///
> level1(ID:) ///
> discrete(distribution(binomial) link(logit) denominator(cons) pql2) ///
> nopause

Further fitting by MCMC:
. runmlwin ELITE cons, ///
> level3(SCHOOL_ID: cons) ///
> level2(LSOA_ID: cons) ///
> level1(ID:) ///
> discrete(distribution(binomial) link(logit) denominator(cons)) ///
> mcmc(on) initsprevious nopause nogroup

I’d be grateful for any help! Thanks very much,

Jo
ChrisCharlton
Posts: 1351
Joined: Mon Oct 19, 2009 10:34 am

Re: Fitting a crossclassified model in Stata

Post by ChrisCharlton »

This should just be a case of setting the cc flag in the mcmc option so that the specified levels are treated as classifications. For examples of this see the MCMC guide chapter 15 replication materials on https://www.bristol.ac.uk/cmm/software/ ... /examples/.
jodavies87
Posts: 4
Joined: Tue Sep 10, 2019 2:10 pm

Re: Fitting a crossclassified model in Stata

Post by jodavies87 »

Thanks Chris! Shortly before your reply I did find the 'cc' flag and added that to my null model syntax, but didn't also add 'on'. This was my syntax, will it still have worked correctly?

runmlwin elite cons, ///
level3(schoolid: cons) ///
level2(lsoaid: cons) ///
level1(id:) ///
discrete(distribution(binomial) link(logit) denominator(cons)) ///
mcmc(cc burnin(1000) chain(30000) thinning(10)) initsprevious nopause nogroup

The model produced (please see attached) doesn't actually indicate anywhere about being 'cross-classified', is this normal? It also doesn't include a table with level variables and number of groups as the models in the link you shared do (before the burnin and chain info etc.) - do you know why this might be?

Sorry for all the questions! Thanks very much,

Jo
Attachments
Null cc model.docx
(2.74 MiB) Downloaded 341 times
ChrisCharlton
Posts: 1351
Joined: Mon Oct 19, 2009 10:34 am

Re: Fitting a crossclassified model in Stata

Post by ChrisCharlton »

Your syntax looks correct to me. If you remove the nogroup option from your command and then compare the extra grouping information provided between the IGLS and MCMC models you should see that the number of units within each group changes to match the cross-classification.
jodavies87
Posts: 4
Joined: Tue Sep 10, 2019 2:10 pm

Re: Fitting a crossclassified model in Stata

Post by jodavies87 »

Hi Chris,

Thank you for getting back to me and apologies to come back with another question…

As you will have seen from my syntax, I obtained the initial starting estimates from a pql2 estimate on a standard 3-level hierarchical model before using these for my cross-classified model fitted with MCMC.

This seems to be the process outlined in the MLwiN practical of the LEMMA chapter on cross-classified models, however I have seen a suggestion in another post on this forum as to manually inputting MCMC starting values rather than doing the latter. This query did relate to having received an error message about starting values for the MCMC estimation however – so I guess my question is, is it OK to proceed as I have done if no error presents or would I still be better advised inputting starting values?

Thanks very much,

Jo
ChrisCharlton
Posts: 1351
Joined: Mon Oct 19, 2009 10:34 am

Re: Fitting a crossclassified model in Stata

Post by ChrisCharlton »

The starting values from pql2 estimation would be based on the hierarchical model, which depending on how different the structure from the cross-classified version could be quite a different model. In some cases the hierarchical model could come up with some very different estimates (or even set some to zero) in which case the MCMC estimation cannot proceed without modifying the starting values.

To test how sensitive your model is to the starting values you could try a range of different starting values to see if the model always ends up in the same place. Obviously you would want to do the normal MCMC convergence tests to ensure that the model has converged to a stable distribution.
jodavies87
Posts: 4
Joined: Tue Sep 10, 2019 2:10 pm

Re: Fitting a crossclassified model in Stata

Post by jodavies87 »

Thanks again Chris.

Would it please be possible to provide me with some template code as to how I could set these starting values within stata - within the context of a null 3-level crossclassifed model say? I have run some separate 2-level analyses with each of the higher levels in my models (schools and LSOAs) so am guessing that estimates from these could be used? Would really appreciate any advice in any case as this is my first real experience of multilevel modelling so am not very confident as to how I would actually go about doing so.

Thanks very much,

Jo
ChrisCharlton
Posts: 1351
Joined: Mon Oct 19, 2009 10:34 am

Re: Fitting a crossclassified model in Stata

Post by ChrisCharlton »

Chapter five of the MCMC manual (https://www.bristol.ac.uk/cmm/software/ ... nuals.html) discusses setting starting values, and you can find the Stata code to replicate this at https://www.bristol.ac.uk/cmm/software/ ... /examples/. It may be that once you investigate these you find the starting values don't make much difference and your current ones are fine.
Post Reply