我想使用 package 执行贝叶斯逻辑回归rjags
。不幸的是,我最终对错误消息感到沮丧
Error parsing model file: syntax error on line 9 near ")
我无法解释。任何人都可以帮忙。我是堆栈溢出的新手,如果我违反规则,请耐心等待。
我的代码是:
merged2<-read.csv("merged2.csv")
head(merged2,2)
####Defining values that will be used
N1<-length(merged2$V190)
####Preparing dat for JAGS
dat<-list("N1"=N1,"perinatal"=merged2$perinatal,"V025"=merged2$V025,"V190"=merged2$V190,"V106"=merged2$V106,"V212"=merged2$V212,"B11"=merged2$B11)
####Initial values
inits1.jags<-list(beta=0.0)
####Define the JAGS model
mod.jags<-"model{
#Likelihood
for (i in 1:N){
perinatal[i]~dbern(q[i])
logit(q[i])<-beta[1]+beta[2]*V190[i,1]+beta[3]*V212[i,2]+beta[4]*V106[i,3]+beta[5]*V025[i,4]+beta[6]*B11[i,5]
}
#Priors
for (j in 1:6){
beta[j]~dnorm(0.001,)
}
}"
####Set up the JAGS model
model<-jags.model(textConnection(mod.jags),data = dat,n.chains = 2,quiet = TRUE)