我在运行WinBUGS程序时遇到了麻烦

时间:2015-07-25 02:55:59

标签: winbugs

我在运行WinBUGS程序时遇到了麻烦。该模型在语法上是正确的,但是一旦加载了数据,我就无法编译,因为错误'求和函数的向量参数包含未定义的组件'。

 model;
         const
         pprime = 8, # number of regression coefficients including an               intercept
         n = 106, # sample size
         T =3;
         var
        beta[pprime] , y[n,T] , b[n,T] , p[n, T], z1star[n] , z1[n] , z2[n,T] , tau , b.c , x1star[n,T] , x2star[n,T] , x3star[n,T] , x4star[n,T] ,                        x1[n,T] , x2[n,T] , x3[n,T] , x4[n,T] , alpha2[7] , alpha3[8] , g2[n] , g3[n] ;
        DATA y in "y .dat", x1 in "x1 .dat" , x2 in "x2 .dat" ,
       x3 in "x3 .dat" , x4 in "x4 .dat" , z1 in "z1 .dat", T in "time.dat" , z2 in "z2 .dat" ; 
       {
               beta[1] ~ dnorm(0,1.0E-6);
               beta[2] ~ dnorm(0,1.0E-6);
               beta[3] ~ dnorm(0,1.0E-6);
               beta[4] ~ dnorm(0,1.0E-6);
               beta[5] ~ dnorm(0, 1.0E-6);
               beta[6] ~ dnorm(0, 1.0E-6);
               beta[7] ~ dnorm(0, 1.0E-6);
               beta[8] ~ dnorm(0, 1.0E-6);
               beta[9] ~ dnorm(0, 1.0E-6);
               alpha2[1]~ dnorm(0,1.0E-6);
               alpha2[2]~ dnorm(0,1.0E-6);
               alpha2[3]~ dnorm(0,1.0E-6);
               alpha2[4]~ dnorm(0,1.0E-6);
               alpha2[5]~ dnorm(0,1.0E-6);
               alpha2[6]~ dnorm(0,1.0E-6);
               alpha2[7]~ dnorm(0,1.0E-6);
               alpha3[1]~ dnorm(0,1.0E-6);
               alpha3[2]~ dnorm(0,1.0E-6);
               alpha3[3]~ dnorm(0,1.0E-6);
               alpha3[4]~ dnorm(0,1.0E-6);
               alpha3[5]~ dnorm(0,1.0E-6);
               alpha3[6]~ dnorm(0,1.0E-6);
               alpha3[7]~ dnorm(0,1.0E-6);
               alpha3[8]~ dnorm(0,1.0E-6);
               tau ~ dgamma(2, 1.0E-3); 
                                 b.c ~ dnorm(0, 1.0E-6);         
               for (i in 1:n) {
                 z1star[i]<- (z1[i]-mean(z1[]))/sd(z1[]);
                 x1star[i,1]<- (x1[i,1]-mean(x1[,1]))/sd(x1[,1]);
                 x1star[i,2]<- (x1[i,2]-mean(x1[,2]))/sd(x1[,2]);
                 x1star[i,3]<- (x1[i,3]-mean(x1[,3]))/sd(x1[,3]);
                 x2star[i,1]<- (x2[i,1]-mean(x2[,1]))/sd(x2[,1]);
                 x2star[i,2]<- (x2[i,2]-mean(x2[,2]))/sd(x2[,2]);
                 x2star[i,3]<- (x2[i,3]-mean(x2[,3]))/sd(x2[,3]);
                 x3star[i,1]<- (x3[i,1]-mean(x3[,1]))/sd(x3[,1]);
                 x3star[i,2]<- (x3[i,2]-mean(x3[,2]))/sd(x3[,2]);
                 x3star[i,3]<- (x3[i,3]-mean(x3[,3]))/sd(x3[,3]);
                 x4star[i,1]<- (x4[i,1]-mean(x4[,1]))/sd(x4[,1]);
                 x4star[i,2]<- (x4[i,2]-mean(x4[,2]))/sd(x4[,2]);
                 x4star[i,3]<- (x4[i,3]-mean(x4[,3]))/sd(x4[,3]); 
               for (j in 1:T) {
               y[i,j]~ dbin (p[i,j], 1);
               logit(p[i,j])<- beta[1] + beta[2]*x1star[i,j] + beta[3]*x2star[i,j] +beta[4]*x3star[i,j]+beta[5]*x4star[i,j] +beta[6]*z1star[i]+ b[i,j] ;
               b[i,j]~dnorm(0,tau);
                }
                  z2[i,2]~ dbin(g2[i],1);
                 z2[i,3]~ dbin(g3[i],1);
                logit(g2[i]) <- alpha2[1] + alpha2[2]*z2[i,1]+ alpha2[3]*x1star[i,2] + alpha2[4]*x2star[i,2] + alpha2[5]*x3star[i,2]+alpha2[6]*x4star[i,2] + alpha2[7]*z1star[i] ;
               logit(g3[i]) <- alpha3[1] +alpha3[2]*z2[i,2]+ alpha3[3]*z2[i,3] + alpha3[4]*x1star[i,3] + alpha3[5]*x2star[i,3] + alpha3[6]*x3star[i,3]+alpha3[7]*x4star[i,3] + alpha3[8]*z1star[i]
                }
                }

0 个答案:

没有答案