使用Rjags的贝叶斯Logistic回归

时间:2020-08-05 07:52:07

标签: r rjags

我想使用rjags软件包执行贝叶斯逻辑回归。不幸的是,我最终因错误msg感到沮丧

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)

0 个答案:

没有答案