mcmcsum error - model must be fitted with MCMC

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
RachaelHughes
Posts: 9
Joined: Thu Jun 13, 2019 10:33 am

mcmcsum error - model must be fitted with MCMC

Post by RachaelHughes »

Hi,

I am using version 17th June 2019 for runmlwin and mcmcsum. I've fitted a cross classified model using MCMC (with hierarchical centring) and saved the chains. When I run the command "mcmcsum FP1_constant_1" I get error message "The runmlwin model must be fitted using MCMC". mcmcsum worked with my previous version of runmlwin and mcmcsum. Interestingly, I get the same error message if I apply the latest version to chain data generated with an older version of runmlwin.

Thank you for your time
Rach
ChrisCharlton
Posts: 1351
Joined: Mon Oct 19, 2009 10:34 am

Re: mcmcsum error - model must be fitted with MCMC

Post by ChrisCharlton »

If you look at line 121 of mcmcsum:

https://bitbucket.org/cmm_stata/runmlwi ... cmcsum.ado

you will see that this error message is returned if the current model results do not have e(method) set to MCMC. You can check whether this is the case for your model by using the command:

Code: Select all

ereturn list
For the model that I tested (In Stata 15.1) this was still the case.

You mention running the command on chain data generated with an older version of runmlwin. If you're running the command on a data file of chains, rather than the most recently run model then you need to specify the variables option to tell mcmcsum to do this.
RachaelHughes
Posts: 9
Joined: Thu Jun 13, 2019 10:33 am

Re: mcmcsum error - model must be fitted with MCMC

Post by RachaelHughes »

Dear Chris,

Thank you for your reply. To be clear, this current problem is regarding a saved chain datafile generated using the latest runmlwin software.

I re-run the model and using ereturn I verified that the e(Method) was "MCMC". In the same Stata session I then opened the saved chains datafile and the mcmcsum command worked. However, if I opened the same data file in a new Stata session then the mcmcsum command gave the same error "Estimate results must come from runmlwin". I think this is a limitation since if you save results to a filename you would expect to be able to re-analyse those results at a later date without having to re-run the model first. I suppose one could always run a quick MCMC of a simple model such that e(Method) registers as "MCMC".

Thank for your help with this.
Rach
ChrisCharlton
Posts: 1351
Joined: Mon Oct 19, 2009 10:34 am

Re: mcmcsum error - model must be fitted with MCMC

Post by ChrisCharlton »

If you do not specify the variables option for mcmcsum then it will obtain the chains from the mata matrix referred to in the e(chains) value of the last stored model (see around lines 259 of https://bitbucket.org/cmm_stata/runmlwi ... cmcsum.ado). Neither this or the model results will persist if you close Stata.

If you want to save the chains to analysis in a later Stata session then you can convert the chains into a Stata dataset with the command:

Code: Select all

mcmcsum, getchains
This can then be saved and loaded back into a later Stata session. To use mcmcsum on this data you will need to use the command (adding any further options that you want to specify):

Code: Select all

mcmcsum, variables
Post Reply