error while obeying the batch file while trying to save winbugs code

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
yransome
Posts: 12
Joined: Wed Apr 22, 2015 12:07 pm

error while obeying the batch file while trying to save winbugs code

Post by yransome »

Hi all, I am running the following code, which works fine until i enter the savewinbugs syntax.
Even when I pause the analysis and manually try to save the winbugs output, I get the same error:
MCMC Error 0243: The 1th neighbouring unit for area 1 is not a known area

runmlwin alcohol cons year stdvar , ///
level3(zipcode: cons, carids(mmid1-mmid10) carweights(carweight1-carweight10)) ///
level2(zipcode: ) ///
level1(zipcode: ) ///
discrete(distribution(poisson) link(log) offset(logexp)) ///
mcmc( burnin (10000) chain(50000) refresh(500) rppriors(gamma(0.5, 0.0005))) initsprevious


** When I add savewinbugs, I get the error
runmlwin alcohol cons year stdvar , ///
level3(zipcode: cons, carids(mmid1-mmid10) carweights(carweight1-carweight10)) ///
level2(zipcode: ) ///
level1(zipcode: ) ///
discrete(distribution(poisson) link(log) offset(logexp)) ///
mcmc( burnin (10000) chain(50000) refresh(500) rppriors(gamma(0.5, 0.0005)) savewinbugs (model("car_model.txt", replace) inits("car_inits.txt", replace) data("car_data.txt", replace))) initsprevious

Thanks in advance for anyone who have an idea how to fix
Attachments
error.docx
(790.5 KiB) Downloaded 397 times
ChrisCharlton
Posts: 1351
Joined: Mon Oct 19, 2009 10:34 am

Re: error while obeying the batch file while trying to save winbugs code

Post by ChrisCharlton »

What is the ID code for the first value of your mmid1 column? If it is zero could you try renumbering it to see if that helps?
yransome
Posts: 12
Joined: Wed Apr 22, 2015 12:07 pm

Re: error while obeying the batch file while trying to save winbugs code

Post by yransome »

Hi Chris,
The ID is an integer and so does not start with zero.
Thanks for offering a suggestion!
ChrisCharlton
Posts: 1351
Joined: Mon Oct 19, 2009 10:34 am

Re: error while obeying the batch file while trying to save winbugs code

Post by ChrisCharlton »

Sorry, I probably could have worded that better. The question was really whether any of your IDs had a value of zero, not if they had a zero as a leading digit. The reason I ask is that the bugs conversion code currently omits such IDs when calculating the total set.
yransome
Posts: 12
Joined: Wed Apr 22, 2015 12:07 pm

Re: error while obeying the batch file while trying to save winbugs code

Post by yransome »

Thank you for the clarification!
Yes, several mmids have zero and mmid10 starts with zero.
So when you say renumbering, you are suggesting change from 0 to something like 0.1? These IDs are based on an adjacency matrix from Geobugs, and an R-function you wrote previously to create the variables in the format needed for runmlwin. I attached the code again.

Are there any other straightforward ways (besides in Geobugs) to use shapefiles to create the mmids and carweight variables to use in runmlwin? Perhaps with Stata new sp commands MlWin or another package, especially in cases where the number of neighborhoods is more than 100?

The textbooks and online examples typically include those variables in the practice datasets but do not mention how to create them.

Many thanks in advance!
Attachments
This code is to turn data generated by WInBUGS Geobugs for spatial weights matrix to use in runmlwin.docx
(16.92 KiB) Downloaded 400 times
ChrisCharlton
Posts: 1351
Joined: Mon Oct 19, 2009 10:34 am

Re: error while obeying the batch file while trying to save winbugs code

Post by ChrisCharlton »

The identifier codes would still have to be integer, so if this is the problem then you could do something like adding a one to all IDs (except those where the corresponding weight is zero, which should still have a value of zero).

Looking at the MLwiN code the other thing that occurs to me is that for CAR models all of the codes used for the carids should also appear in the ID column for that level (i.e. in your case the values in mmid1-mmid10 should all also be in zipcode). If that isn't the case then you would also get the message that you were seeing. What is odd is that it works normally for you but not when you are saving the BUGS code, as these should be doing the same checks.
ChrisCharlton
Posts: 1351
Joined: Mon Oct 19, 2009 10:34 am

Re: error while obeying the batch file while trying to save winbugs code

Post by ChrisCharlton »

In case it helps to track down the cause of the problem for you here are the checks that MLwiN should be doing:

Code: Select all

For each CAR ID:
    Is the ID zero?:
        If no, does it have a zero weight?:
            If yes, error: "ID is present, but has a zero weight"
            If no, is it in the list of level IDs?:
                If no, error: "ID is not a known area"
        If yes, does it has a zero weight?:
            If no, error: "The unit is absent, but has a positive weight"
It's possible that there is an error in the checking code, but I would probably need an example model with data to track this down as it works for the MLwiN MCMC manual examples.
yransome
Posts: 12
Joined: Wed Apr 22, 2015 12:07 pm

Re: error while obeying the batch file while trying to save winbugs code

Post by yransome »

Dear Dr. Chartlon,

Thank you for helping troubleshoot. The model worked when I changed "zipcode" to POLY_ID, because that variable contained the identifiers for the mmids and carids. When I used geobougs to generate the spatial weights matrix, I used the POLY_ID that was within the shapefile. I can always create a dataset with the posterior predictions that have both identifiers.

Regards,
Yusuf
Post Reply