问题描述
所以我正在尝试做这个贝叶斯数据建模项目,我回到了我的 rjags 贝叶斯统计课上的笔记,我的教授在那里研究了一个非常相似的模型。我能够毫无问题地运行它,但是当我将它调整到我的模型时,我的输出出现错误。
这是我的代码:
library(rjags)
set.seed(12196)
# Number of bear reports
Y <- black_bears$Y # Number of surveys saying there was a reported bear sighting
N <- black_bears$N # Number of surveys submitted on whether a bear was seen or not
q <- Y/N # proportion of the non-bear sightings submitted
n <- length(Y)
X <- log(q)-log(1-q) # X = logit(q)
data <- list(Y=Y,N=N,X=X)
params <- c("beta")
model_string <- textConnection("model{
# Likelihood
for (i in 1:n){
Y[i] ~ dbinom(p[i],N[i])
logit(p[i] <- beta[1] + beta[2]*X[i])
}
# Priors
beta[1] ~ dnorm(0,0.01)
beta[2] ~ dnorm(0,0.01)
}")
model <- jags.model(model_string,data = data,n.chains=2,quiet=TRUE)
update(model,10000,progress.bar="none")
samples1 <- coda.samples(model,variable.names=params,thin=5,n.iter=20000,progress.bar="none")
plot(samples1)
我收到了这个错误:
感谢任何和所有帮助。谢谢!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)