I want to create a temp variable in jags, but it doesn't work as it would work in R
for (cid in 1:CAMPAIGN_N) {
for (time in 1:DATE_N){
index <- time * CAMPAIGN_N + cid - 2
positives[index] ~ dbin( k[time]*ctr[cid], tries[index])
}
}
Gives error, because index
variable is being defined only once. So I had to write it the following ugly way:
for (cid in 1:CAMPAIGN_N) {
for (time in 1:DATE_N){
positives[time * CAMPAIGN_N + cid - 2]
~ dbin( k[time]*ctr[cid], tries[time * CAMPAIGN_N + cid - 2])
}
}
Is there a way I can create temp variable in jags?
You'd need to let
index
vary withtime
andcid
.