【问题标题】:'expected a comma' error in OpenBUGSOpenBUGS 中的“预期逗号”错误
【发布时间】:2015-10-14 21:07:29
【问题描述】:

我正在尝试使用 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)


   }

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

【问题讨论】:

    标签: r bayesian-networks winbugs r2winbugs openbugs


    【解决方案1】:

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

    pow(e1, e2)e1^e2

    目前你只有e1;

    Xbeta[i] &lt;- a[sp[i]]-0.5*pow(e1)

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-07-21
      • 2021-11-04
      • 2022-08-09
      • 2021-04-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多