gpt4 book ai didi

r - OpenBUGS 中出现“预期逗号”错误

转载 作者:行者123 更新时间:2023-12-02 13:59:16 36 4
gpt4 key购买 nike

我正在尝试使用 OpenBUGS 拟合模型。这是代码:

model {
# N observations
for (i in 1:N) {
y[i] ~ dbin(p.bound[i],1)
p.bound[i]<-max(0,min(1,p[i]))
logit(p[i])<-Xbeta[i]
Xbeta[i] <- a[sp[i]]-0.5*pow(((X1[i]-opt1[sp[i]])/tol1[sp[i]])+((X2[i]-opt2[sp[i]])/tol2[sp[i]])+((X3[i]-opt3[sp[i]])/tol3[sp[i]]))
}
for (j in 1:n.sp) {
a[j] ~ dnorm(a.hat[j],tau.a)
a.hat[j]<-mu.a

opt1[j] ~ dnorm(opt.hat1[j],tau.opt1)
opt.hat1[j]<-mu.opt1

tol1[j] ~ dnorm(tol.hat1[j],tau.tol1)
tol.hat1[j]<-mu.tol1

opt2[j] ~ dnorm(opt.hat2[j],tau.opt2)
opt.hat2[j]<-mu.opt2

tol2[j] ~ dnorm(tol.hat2[j],tau.tol2)
tol.hat2[j]<-mu.tol2

opt3[j] ~ dnorm(opt.hat3[j],tau.opt3)
opt.hat3[j]<-mu.opt3
tol3[j] ~ dnorm(tol.hat3[j],tau.tol3)
tol.hat3[j]<-mu.tol3

}
mu.a~dnorm(0,0.0001)
mu.opt1~dnorm(0,0.0001)
mu.tol1~dunif(0.04,37)

mu.opt2~dnorm(0,0.0001)
mu.tol2~dunif(0.04,37)

mu.opt3~dnorm(0,0.0001)
mu.tol3~dunif(0.04,37)


tau.a<-pow(sigma.a,-2)
sigma.a~dunif(0,100)
tau.opt1<-pow(sigma.opt1,-2)
sigma.opt1~dunif(0,100)
tau.opt2<-pow(sigma.opt2,-2)
sigma.opt2~dunif(0,100)

tau.opt3<-pow(sigma.opt3,-2)
sigma.opt3~dunif(0,100)

tau.tol1<-pow(sigma.tol1,-2)
sigma.tol1~dunif(0,100)


tau.tol2<-pow(sigma.tol2,-2)
sigma.to2~dunif(0,100)

tau.tol3<-pow(sigma.tol3,-2)
sigma.tol3~dunif(0,100)


}

但是,当我运行此代码时,我收到错误“需要逗号”。如果有人能帮助我解决这个问题,那就太好了。

最佳答案

错误出现在幂函数中。来自 BUGS manual. ..

pow(e1, e2) e1^e2

目前您只有 e1 ;

Xbeta[i] <- a[sp[i]]-0.5*pow(e1)

哪里e1 = ((X1[i]-opt1[sp[i]])/...

关于r - OpenBUGS 中出现“预期逗号”错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31606361/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com