I' trying to implement an Aster-type model in JAGS and am struggling
to understand how to estimate the unconditional effects of each
predictor variable on the terminal nodes. For example, considering a simple graphical model with three nodes (z1, z2, and y), where z1 is Bernoulli, z2 is also Bernoulli (conditional on z1 = 1) and y is zero-truncated Poison (conditional on z2 = 1), I have implemented the following model in JAGS:
model {
C <- 10000
## PRIORS
psi0 ~ dnorm(0, 0.0001)
psi ~ dnorm(0, 0.0001)
gamma0 ~ dnorm(0, 0.0001)
gamma ~ dnorm(0, 0.0001)
beta0 ~ dnorm(0, 0.0001)
beta ~ dnorm(0, 0.0001)
# Likelihoods
for(i in 1:N){
## Hurdle 1
logit(phi1[i]) <- psi0 + psi * X[i]
## Hurdle 2
logit(phi2[i]) <- gamma0 + gamma * X[i]
## Count model
count[i] <- (pow(mu[i], y[i]) * exp(-mu[i])) / (y_fact[i] * (1 - exp(-mu[i])))
log(mu[i]) <- beta0 + beta * X[i]
# Ones trick
p[i] <- Lik[i]/C
ones[i] ~ dbern(p[i])
# Full likelihood
Lik[i] <- (1 - phi1[i]) * (1 - z1[i]) +
(1 - phi2[i]) * phi1[i] * (1 - z2[i]) * z1[i] +
count[i] * phi2[i] * phi1[i] * z1[i] * z2[i]
}
} # Model
Using simulated data, this model does estimate psi, gamma, and beta (i.e. the conditional effect of X on z1, z2, and y). For example, when X is simulated to have a negative infuence on z1 (phi1) but no effect on z2 (phi2, conditional on z1 = 1) or y (f, conditional on z2 = 1), the model correctly estimates gamma and beta as 0.
However, even in this case, individuals with large values of X will have lower counts because they are more likely to have z1 = 0. Can anyone explain how to estimate the overall influence (i.e. unconditional effect) of X on the count process and how to implement those estimates in JAGS?
Data and code to run model:
### Function to generate counts from zero-truncated Poisson
rpoisson0 <- function(n, lambda){
U <- runif(n) # the uniform sample
t <- -log(1 - U*(1 - exp(-lambda))) # the "first" event-times
T1 <- (lambda - t) # the set of (T-t)
X <- rpois(n, T1) + 1 # the final truncated Poisson sample
return(X)
}
n <- 200
X <- rnorm(150)
psi0 <- -0.5
psi <- -2
exp.z1<- exp(psi0 + psi*X)/(1 + exp(psi0 + psi*X))
z1 <- rbinom(n = n, size = 1, prob = exp.z1)
gamma0 <- 1.5
gamma <- 0
exp.z2 <- exp(gamma0 + gamma*X)/(1 + exp(gamma0 + gamma*X))
z2 <- rbinom(n = n, size = 1, prob = exp.z2) * z1
beta0 <- 1.1
beta <- 0
exp.y <- exp(beta0 + beta * X)
y <- rpoisson0(n = n, lambda = exp.y) * z2
### Prepare data for JAGS
jags_data <- list(N = length(y), z1 = z1, z2 = z2, y = y, y_fact = factorial(y), ones = rep(1, length(y)), X = X)
### Parameters to monitor
jags_param <- c("psi", "gamma", "beta")