Page 1 of 1

Factor variable and MCMC

Posted: Wed Oct 16, 2013 5:49 am
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

Re: Factor variable and MCMC

Posted: Wed Oct 16, 2013 9:11 am
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)