Page 1 of 1

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

Posted: Thu Apr 26, 2018 6:00 pm
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

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

Posted: Fri Apr 27, 2018 3:22 pm
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?

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

Posted: Tue May 01, 2018 3:20 pm
by yransome
Hi Chris,
The ID is an integer and so does not start with zero.
Thanks for offering a suggestion!

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

Posted: Tue May 01, 2018 3:43 pm
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.

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

Posted: Tue May 01, 2018 10:05 pm
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!

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

Posted: Wed May 02, 2018 9:57 am
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.

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

Posted: Wed May 02, 2018 10:21 am
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.

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

Posted: Tue May 15, 2018 5:53 pm
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