The problem involves trying to characterize the probability:
P.f = Pd*Pr{t1 < t2}
using jags or WinBUGS. The issue is the last term where both t1 and t2 are random variables. A sample, stripped down, model using this is given below and hopefully provides insight into what I am trying to do. As expected, I get an error indicating that I am redefining the variable 'y'. Searching for a trick to get past this is proving difficult.
Any insight would be appreciated!
FWIW, I've also posted a similar question on the WinBUGS list, but cross-posted here with the hope of reaching a wider audience.
model {
for(j in 1:N) {
t.1[j] ~ dweib(alpha.1,lambda.1)
t.2[j] ~ dweib(alpha.2, lambda.2);
p.det[j] ~ dbeta(a,b);
y[j] <- step(t.2[j]-t.1[j]);
y[j] ~ dbern(py);
}
alpha.1 ~ dgamma(0.3,0.0001);
lambda.1 ~ dnorm(0., 10000.);
alpha.2 ~ dgamma(0.3,0.0001);
lambda.2 ~ dnorm(0., 10000.);
py ~ dbeta(0.3,0.3);
a ~ dgamma(1, 0.01)
b ~ dgamma(1, 0.01)
pd ~ dbeta(a,b)
p.f<- pd*py
}
Best Answer
In JAGS, you can't reuse, in your case,
y[j]
as you sometimes can in WinBUGS. Instead, you create "new" data out of the data that you pass to JAGS in a data block at the top of the code (i.e., before the model step):You can then use
y[j]
on the left hand side of distributions in the model step:This can't be done in WinBUGS, however, as there's no data block; instead, you should just pass a precalculated variable y to WinBUGS.