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
error while obeying the batch file while trying to save winbugs code
error while obeying the batch file while trying to save winbugs code
- Attachments
-
- error.docx
- (790.5 KiB) Downloaded 630 times
-
- Posts: 1384
- Joined: Mon Oct 19, 2009 10:34 am
Re: error while obeying the batch file while trying to save winbugs code
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
Hi Chris,
The ID is an integer and so does not start with zero.
Thanks for offering a suggestion!
The ID is an integer and so does not start with zero.
Thanks for offering a suggestion!
-
- Posts: 1384
- Joined: Mon Oct 19, 2009 10:34 am
Re: error while obeying the batch file while trying to save winbugs code
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
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!
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 596 times
-
- Posts: 1384
- Joined: Mon Oct 19, 2009 10:34 am
Re: error while obeying the batch file while trying to save winbugs code
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.
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.
-
- Posts: 1384
- Joined: Mon Oct 19, 2009 10:34 am
Re: error while obeying the batch file while trying to save winbugs code
In case it helps to track down the cause of the problem for you here are the checks that MLwiN should be doing:
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.
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"
Re: error while obeying the batch file while trying to save winbugs code
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
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