![](http://cache.soso.com/img/img/e100.gif)
程序如下,在数据导入之后,按compile按钮时,显示array index is grater than array upper boundy for y ,如果数据减少至20程序就可以运行,请高手指点!万分感谢{:soso_e100:}
model{
### likelihood: joint distribution of y
for(i in 1:n)
{p[i]<-1/exp(theta[i])
y[i]~dnorm(0,p[i])
}
### prior distributions*
phi1~dbeta(20,1.5)
phi<-2*phi1-1
mu~dnorm(0,0.01)
itau2~dgamma(2.5,0.025)
tau<-sqrt(1/itau2)
theta0~dnorm(mu,itau2)
thmean[1]<-mu+phi*(theta0-mu)
theta[1]~dnorm(thmean[1],itau2)
for(j in 2:n)
{thmean[j]<-mu+phi*(theta[j-1]-mu)
theta[j]~dnorm(thmean[j],itau2)
}
}
# DATA
list(n=76,y=c(-0.2352,
-3.7769,
-3.5341,
-1.8623,
4.3202,
2.8627,
0.9487,
1.1008,
-1.7228,
0.4690,
-0.9836,
-1.7980,
0.1213,
-0.8333,
0.0567,
-0.3118,
-1.7170,
-1.8562,
-8.6653,
0.1957,
-1.3342,
3.1475,
-1.6588,
-0.5408,
2.7101,
2.3157,
-2.4390,
0.1674,
-4.3934,
-0.5687,
0.9867,
-0.8954,
-1.4493,
3.3308,
-0.8124,
-1.8262,
-0.3651,
1.5883,
-1.3877,
2.5499,
0.2302,
4.4972,
-3.1278,
-2.4211,
-0.6497,
-0.5901,
-1.5454,
0.9628,
-2.5905,
-0.8705,
0.1471,
-1.2321,
0.5959,
-0.0432,
2.2637,
-0.5950,
-2.1195,
-0.5927,
-0.3382,
0.2680,
0.7632,
-1.3312,
-0.1155,
2.1279,
-1.0219,
-0.8355,
-0.9967,
0.3234,
0.1993,
0.2141,
0.0376,
1.4259,
-1.6190,
-0.0172,
1.6469,
3.0316))
Initial value list(phi1=0.975, mu=0, itau2=50)