I try to implement a spatial intrinsic Gaussian Markov random field model (order = 1) in openBugs via the car.normal() distribution. For a regular 3x3 grid it works fine. But if I increase the sample size (say 4x4) I get an error. Why? I am grateful for hints...
Here is a minimal example, that does not work for 4x4 (but for 3x3 it does):
The file "model.txt":
model{
# likelihoood
for(i in 1:No){ Y[i] ~ dnorm(Z[i], tau) }
Z[1:No] ~ car.normal(adj[], weights[], num[], kappa)
for(k in 1:Nw) { weights[k] <- 1 }
# prior
kappa ~ dgamma(1, 1)
tau ~ dgamma(1, 1)
}
And the "data.txt" for a 4x4 grid:
list(No = 16,
Y = c(0.67,0.88,0.38,0.1,0.78,0.67,0.25,0.55,0.11,0.85,0.46,0.5,0.47,0.38,0.21,0.97),
adj = c(
5,2,
6,1,3,
7,2,4,
8,3,
1,9,6,
2,10,5,7,
6,14,9,11,
4,12,7,
5,13,10,
3,11,6,8,
7,15,10,12,
8,16,11,
9,14,
10,13,15,
11,14,16,
12,15),
num = c(2,3,3,2,3,4,4,3,3,4,4,3,2,3,3,2),
Nw = 48)
I run it in R (other options are possible):
require(R2OpenBUGS)
bugs(data="data.txt",
inits=function(){list(tau=10, kappa=100, Z = rep(c(-.5,.5),8))},
parameters=c("Z","tau","kappa"),
model.file="model.txt",
n.chains=1, n.iter=150, n.burnin=1)
The error is:
OpenBUGS version 3.2.2 rev 1063
model is syntactically correct
data loaded
model compiled
error for node Z[1] of type SpatialCARNormal.Node first argument Graph18 error pos 260 (error on line 1)
error for node Z[1] of type SpatialCARNormal.Node first argument Graph18
model must be initialized before updating
model must be initialized before monitors used
model must be initialized before monitors used
model must be initialized before monitors used
model must be initialized before monitors used
model must be initialized before monitors used
model must be initialized before monitors used
model must be initialized before monitors used
model must be initialized before monitors used
model must be initialized before DIC can be monitored
model must be initialized before updating
model must be initialized before monitors used
model must be initialized before monitors used
DIC monitor not set
-------------------------------------------------------------------
This list is for discussion of modelling issues and the BUGS software.
For help with crashes and error messages, first mail [log in to unmask]
To mail the BUGS list, mail to [log in to unmask]
Before mailing, please check the archive at www.jiscmail.ac.uk/lists/bugs.html
Please do not mail attachments to the list.
To leave the BUGS list, send LEAVE BUGS to [log in to unmask]
If this fails, mail [log in to unmask], NOT the whole list
|