Factor variable and 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
garryand
Posts: 1
Joined: Wed Oct 16, 2013 5:07 am

Factor variable and MCMC

Post by garryand »

Hi,
I am using the bang.dta dataset
If I make urban a factor variable i.urban and do pql2 I obtain a coefficient.
If I then run with mcmc(on) initsprevious
a message appears "The model did not run properly in MLwiN. You most likely clicked the 'Abort Macro' button in MLwiN, rather than the 'Resume Macro' button."
This occurs after I first press Resume Macro

Code: Select all

use "http://www.bristol.ac.uk/cmm/media/runmlwin/bang.dta", clear

. runmlwin use cons i.urban,  ///
   level2(district: cons)  
   level1(woman:)   
   discrete(distribution(binomial) link(logit) denom(cons) pql2)

. runmlwin use cons i.urban,   
   level2(district: cons)  
   level1(woman:)   
   discrete(distribution(binomial) link(logit) denom(cons) ) 
   mcmc(on) initsprevious maxit(50)

The model did not run properly in MLwiN. You most likely clicked the 'Abort Macro' button in MLwiN, rather than the 'Resume Macro' button.

Code: Select all

r(198);
This is a demonstration. I have a factor variable with 11 levels, but the above prevents me from running MCMC.
I am using Windows XP SP3, MlWin 2.26 and runmlwin 31 Jul 2013

Kind regards, Garry
ChrisCharlton
Posts: 1384
Joined: Mon Oct 19, 2009 10:34 am

Re: Factor variable and MCMC

Post by ChrisCharlton »

MLwiN has a problem with the variables automatically generated by Stata's i. notation when using MCMC (the base category is added to the model as a column containing only zeros). This will be fixed in the next update to runmlwin, however in the mean time you can work around this by using Stata's older method of adding the xi: prefix to your command. For your examples the syntax would be:

Code: Select all

use "http://www.bristol.ac.uk/cmm/media/runmlwin/bang.dta", clear

xi: runmlwin use cons i.urban, level2(district: cons) level1(woman:) discrete(distribution(binomial) link(logit) denom(cons) pql2)

xi: runmlwin use cons i.urban, level2(district: cons) level1(woman:) discrete(distribution(binomial) link(logit) denom(cons) ) mcmc(on) initsprevious maxit(50)
Post Reply