In JAGS I'd like to define a Poisson distribution for parameter w[i] which is also truncated (greater than or equal to 2) if another parameter, e[i], is greater than 0.
Essentially I want it to represent:
w[i] ~ ifelse( e[i] > 0, dpois(mu) T(2,) , dpois(mu) )
I've tried using the step function by adapting the code that was given in response to someone else's post which was requesting something similar: Choosing Different Distributions based on if - else condition in WinBugs/JAGS
But this doesn't seem to work?
Thank you
Maybe something like this?
pois1 ~ dpois(mu) T(2,)
pois2 ~ dpois(mu)
for(i in 1:N){
indicator1[i] <- ifelse(e[i] > 0, 1, 0)
indicator2[i] <- ifelse(e[i] <= 0, 1, 0)
w[i] <- (pois1 * indicator1[i]) + (pois2 * indicator2[i])
}
When e[i]
is greater than 1 w[i]
takes the value from pois1
. If it is not w[i]
takes the value from pois2
.
EDIT: Or, you could define only one indicator variable and do it like this.
pois1 ~ dpois(mu) T(2,)
pois2 ~ dpois(mu)
for(i in 1:N){
indicator[i] <- ifelse(e[i] > 0, 1, 0)
w[i] <- (pois1 * indicator[i]) + (pois2 * (1 - indicator[i]))
}