I'm running the following model (with sample data included):
model {
# likelihood
for (i in 1:nloci) {
a[i] <- ((1-theta)/theta)*x[i]
b[i] <- ((1-theta)/theta)*(1-x[i])
for (j in 1:npop) {
p[j,i] ~ dbeta(a[i], b[i])
y[j,i] <- p[j,i]*p[j,i] + f*p[j,i]*(1.0-p[j,i]) + 2.0*(1-f)*p[j,i]*(1.0-p[j,i])
k[j,i] ~ dbin(y[j,i], n[j])
}
}
# priors
theta ~ dbeta(1.0,1.0)
f ~ dbeta(1.0,1.0)
for (i in 1:nloci) {
x[i] ~ dbeta(1.0,1.0)
}
}
# data
list(k = structure(.Data = c(2, 0, 1, 3, 10, 6, 19, 9, 6, 23, 0, 16, 2, 0, 11,
16, 9, 16, 24, 11, 32, 0, 0, 7, 4, 47, 20, 9, 40, 46, 1, 9, 9, 38, 23,
28, 17, 7, 50, 25, 72, 48, 23, 7, 3, 42, 73, 66, 100, 100), .Dim = c(5,
10)), n = c(25, 25, 50, 50, 100), nloci=10, npop=5)
The model compiles without error, and I'm able to generate initial
values. However, when I try to update I am told that WinBUGS "can not
sample from slice from node p[2,3]". I assume this means that the
adaptive rejection sampler is at fault, and I think it's related to my
definition for y[j,i]. (A similar model using p[j,i] in dbin()
directly works without a hitch.) I've stared at this code for 45
minutes and I can't think of a different way to write it. It works
fine when nloci=1, by the way, so it may have something to do with the
common theta across loci. Is there a way around this problem, or will
I have to write my own Metropolis-Hastings sampler for this problem?
Kent
--
Kent E. Holsinger [log in to unmask]
http://darwin.eeb.uconn.edu
-- Department of Ecology & Evolutionary Biology
-- University of Connecticut, U-3043
-- Storrs, CT 06269-3043
|