winbugs code won't run

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/
pierrenadeau
Posts: 11
Joined: Sun Jan 06, 2013 12:57 am

winbugs code won't run

Post by pierrenadeau »

I have conducted a Bayesian analysis of 3-level models of venture capital investment in Stata whereby 2803 VC investment rounds are nested within 966 firms nested within 16 regions.

I used MLwiN (v2.26) on Stata for mcmc estimation (runmlwin) and got interesting results. I now wish to run further Bayesian analyses on WinBUGS from Stata. I downloaded/installed wbfiles from Leicester University site to run WinBUGS from Stata, and exported model files containing WinBUGS 1.4 code in .txt format generated by MLwiN (savewinbugs option) for the model, data and initial values.

I am having problems getting WinBUGS from Stata to produce any estimation results with the WinBUGS 1.4 code generated by MLwiN (nothing shows in the data editor other than raw data). I ran standalone WinBUGS (not from Stata) and was able to confirm that "the model is syntactically correct" the "data loaded" and the "model compiled" but had problems estimating the model with initial values provided by MLwiN. I never used WinBUGS before (let alone on Stata) and it is quite possible that I may be using the wrong syntax or simply have the wrong setup. I attach the three WinBUGS 1.4 files generated by MLwiN (runmlwin) for your reference.

I would appreciate if you would take a cursory look at these files to see if you can identify why I can't run the WinBUGS program with MLwiN-generated code. I look forward to your advice.
wbm.pdf
winbugs model
(11.04 KiB) Downloaded 501 times
wbd.pdf
winbugs data
(167.95 KiB) Downloaded 564 times
wbi.pdf
winbugs initial values
(18.56 KiB) Downloaded 545 times
pierrenadeau
Posts: 11
Joined: Sun Jan 06, 2013 12:57 am

Re: winbugs code won't run

Post by pierrenadeau »

P.S. Attached is the output from Stata (i.e. runmlwin, wbdecode, wbscript, wbrun).
Stata winbugs log 21Jan13.pdf
Stata winbugs log
(71.89 KiB) Downloaded 554 times
GeorgeLeckie
Site Admin
Posts: 432
Joined: Fri Apr 01, 2011 2:14 pm

Re: winbugs code won't run

Post by GeorgeLeckie »

Hi Pierre,

Thank you for your email. You say

"I ran standalone WinBUGS (not from Stata) and was able to confirm that "the model is syntactically correct" the "data loaded" and the "model compiled" but had problems estimating the model with initial values provided by MLwiN."

Sounds like the problem (if there is one) is an MLwiN problem or a problem with how you are going about using WinBUGS rather than a runmlwin one.

Before you do anything else, I recommend you read through Chapter 7 of the MLwiN MCMC manual and then replicate all the analysis. The chapter explains the MLwiN WinBUGS interface and how to operate WinBUGS using the files automatically generated by MLwiN.

http://www.bristol.ac.uk/cmm/software/m ... mc-web.pdf

Once you have done that, have another attempt using your own data and see whether you are still running into the same problem.

Best wishes

George
pierrenadeau
Posts: 11
Joined: Sun Jan 06, 2013 12:57 am

Re: winbugs code won't run

Post by pierrenadeau »

Dear George

Will do and get back to you shortly.

Pierre
ChrisCharlton
Posts: 1354
Joined: Mon Oct 19, 2009 10:34 am

Re: winbugs code won't run

Post by ChrisCharlton »

It appears as if MLwiN has made a number of mistakes generating the WinBUGS initial values file. It is missing a comma between the numbers -0.012991 and 0.064789 in the u2 parameter and has also only written 1869 values instead of the needed 1870. It has also capitalised Tau.u3 in the initial values file but not in the model. You could work around these problems by changing the capitalisation and then fixing the initial u2 values by either removing all the initial values for this parameter and letting WinBUGS generate its own, or by adding the missing comma and adding an extra value at the end of the list.

I will look at the MLwiN BUGS generation code to see whether there is an obvious reason why it may have gone wrong in your case.
ChrisCharlton
Posts: 1354
Joined: Mon Oct 19, 2009 10:34 am

Re: winbugs code won't run

Post by ChrisCharlton »

I have now had a look at the WinBUGS initial values generation code. I believe that the incorrect definition for the u2 parameter that you are seeing could occur if there are missing values in the generated residuals. This could happen if there are numeric errors when performing the calculations, or in older versions of runmlwin this would happen if the residual values are close to zero. I would suggest that you make sure that your copy of runmlwin is up to date to eliminate the latter possibility.

I can't see anywhere that would cause the Tau.u3 to become capitalised, so it's possible that this was changed by the text editor that you used to view the file.
pierrenadeau
Posts: 11
Joined: Sun Jan 06, 2013 12:57 am

Re: winbugs code won't run

Post by pierrenadeau »

Dear Chris

I corrected the syntax in the initial values text file as you suggested. WinBUGS has accepted initial values and it is now running smoothly albeit slowly. Results are similar to those produced by MLwiN. I am not quite sure why this happened but I will update runmlwin to avoid further problems in the future. Also I am still unable to run Winbugs from Stata (i.e. Leicester's wbdecode, wbscript, wbrun, etc) with the WinBUGS 1.4 code (model, data and initial values) generated by runmlwin. Is this something you can help with?

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

Re: winbugs code won't run

Post by GeorgeLeckie »

Hi Pierre,

Great that it is now working

In terms of running WinBUGS from within Stata see the following for an example.

http://www.bristol.ac.uk/cmm/media/runm ... n_MLwiN.do
http://www.bristol.ac.uk/cmm/media/runm ... _MLwiN.log

For specific questions about running WinBUGS from within Stata you are best off contacting the authors of that winbugs command

http://www2.le.ac.uk/departments/health ... s_main.pdf

Best wishes

George
pierrenadeau
Posts: 11
Joined: Sun Jan 06, 2013 12:57 am

Re: winbugs code won't run

Post by pierrenadeau »

Dear Chris, George

This is to confirm that the latest version of runmlwin was installed a couple of weeks ago.

P
ChrisCharlton
Posts: 1354
Joined: Mon Oct 19, 2009 10:34 am

Re: winbugs code won't run

Post by ChrisCharlton »

In that case would it be possible for you to check my suspicion about there being missing values in the residuals by bringing them back to Stata with the

Code: Select all

residuals()
runmlwin random part option?

If there are missing values then the only reasons I can think of for these been there are that either you have entire higher level units missing or that there has been an error in their calculation.
Post Reply