简体   繁体   中英

JAGS Random Effects Model Prediction

I'm trying to model a bayesian regression using an index as response (D47), temperature as predictor (Temp) and considering the random effects of a discrete variable (Material). I've found really good information regarding non-hierarchical regressions, some posts including even a prediction strategy for these models. Despite this, I've found a remarkable problem when predicting D47 values in my model, mostly because of the random intercept.

Is there any way to deal with a random intercept during the prediction of a JAGS regression?

Thanks for your answer,

model1<-"model {
# Priors
mu_int~dnorm(0, 0.0001) # Mean hyperparameter for random intercepts
sigma_int~dunif(0, 100) # SD hyperparameter for random intercepts
tau_int <- 1/(sigma_int*sigma_int)
for (i in 1:n) {
alpha[i]~dnorm(mu_int, tau_int) # Random intercepts
}
beta~dnorm(0, 0.01) # Common slope
sigma_res~dunif(0, 100) # Residual standard deviation
tau_res <- 1/(sigma_res*sigma_res)
# Likelihood
for (i in 1:n) {
mu[i] <- alpha[Mat[i]]+beta*Temp[i] # Expectation
D47[i]~dnorm(mu[i], tau_res) # The actual (random) responses
}
}"

Sure, you can make predictions with the random intercepts, all you need to do is specify it as some sort of derived quantity.

Try adding something like this to the model.

for(i in 1:(n)){
D47_pred[i] <- dnorm(mu[i], tau_res)
}

And then track D47_pred as a parameter.

edit:

Also, you need to change how you specify the prior for the random intercept. This will take a couple steps (updated code here from comments).

You will need to add a new constant to your data list, which represents the number of unique groups in vector Mat. I have labeled it M in this case (eg 4 groups in Mat, M = 4)

for (j in 1:(M)){ 
alpha[j] ~ dnorm(mu_int, tau_int) # Random intercepts
}

This specification just makes the correct number of random intercepts for your model

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM