Reputation: 11
I am trying to evaluate hierarchical models from R using the R2OpenBUGS library. I've already looked at the answers to similar questions, but nothing seemed to work. I'd be very pleased if someone could help.
The model is the following.
model{
for (i in 1:n) {
goals1[i] ~ dpois(lambda1[i])
goals2[i] ~ dpois(lambda2[i])
log(lambda1[i]) <- mu + home + a[ht[i]] + d[at[i]]
log(lambda2[i]) <- mu + a[at[i]] + d[ht[i]]
}
for (i in 1:np) {
pred[i, 1] ~ dpois(parh[i])
pred[i, 2] ~ dpois(para[i])
log(parh[i]) <- mu + home + a[pht[i]] + d[pat[i]]
log(para[i]) <- mu + a[pat[i]] + d[pht[i]]
}
mu ~ dnorm(pmu, 0.01)
home ~ dnorm(phome, 0.01)
for (i in 2:k) {
a[i] ~ dnorm(priora[i], 0.01)
d[i] ~ dnorm(priord[i], 0.01)
}
mua <- -sum(a[2:k])
mud <- -sum(d[2:k])
a[1] ~ dnorm(mua, 100)
d[1] ~ dnorm(mud, 100)}
In the log i get:
model is syntactically correct
expected the collection operator c error pos 7515
variable n is not defined
model must have been compiled but not updated to be able to change RN generator
BugsCmds:NoCompileInits
model must be compiled before generating initial values
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 DIC can be monitored
model must be initialized before updating
model must be initialized before monitors used
DIC monitor not set
The problem starts when i try to give the vector of prior means priora[] and priord[] to a[i] and d[i]. If i set those means to "0" the code works.
Upvotes: 1
Views: 261