JAGS随机效应模型预测 [英] JAGS Random Effects Model Prediction

查看:66
本文介绍了JAGS随机效应模型预测的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用索引作为响应(D47),温度作为预测变量(Temp)并考虑离散变量的随机效应(材料)对贝叶斯回归建模.我发现了关于非层次回归的非常好的信息,一些帖子甚至包括这些模型的预测策略.尽管如此,在预测模型中的D47值时,我还是发现了一个引人注目的问题,主要是由于随机拦截.

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.

在预测JAGS回归期间,有什么方法可以应对随机截距?

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

感谢您的回答,

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)
}

然后跟踪D47_pred作为参数.

And then track D47_pred as a parameter.

此外,您需要更改为随机拦截指定先验的方式.这将需要几个步骤(此处是注释的更新代码).

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).

您将需要在数据列表中添加一个新常数,该常数代表矢量Mat中唯一组的数量.在这种情况下,我已将其标记为M(例如Mat中的4个组,M = 4)

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 (e.g. 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

这篇关于JAGS随机效应模型预测的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆