Winbugs/JAGS is not a procedural language, so you cannot use the construct like that. Use step
function. Quote from the manual:
step(e) ...... 1 if e >= 0; 0 otherwise
So you need a trick to change the condition:
X[i] > 0.5 <=>
X[i] - 0.5 > 0 <=>
!(X[i] - 0.5 <= 0) <=>
!(-(X[i] - 0.5) >= 0) <=>
!(step(-(X[i] - 0.5)) == 1) <=>
step(-(X[i] - 0.5)) == 0
and then use this for indexing trick:
# then branch
Z_branch[i, 1] ~ dcat(theta-gl[D[i], 1:K-gl])
W_branch[i, 1] ~ dcat(phi-gl[z[i], 1:V])
# else branch
Z_branch[i, 2] ~ dcat(theta-loc[D[i], 1:K-loc])
W_branch[i, 2] ~ dcat(phi-loc[z[i], 1:V])
# decision here
if_branch[i] <- 1 + step(-(X[i] - 0.5)) # 1 for "then" branch, 2 for "else" branch
Z[i] ~ Z_branch[i, if_branch[i]]
W[i] ~ W_branch[i, if_branch[i]]
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…