我在运行OpenBUGS程序时遇到问题。该模型在语法上是正确的,但是一旦加载了数据,我就无法编译,因为错误“数组索引大于数组上限”发生。我一直在检查一切,但似乎无法找到错误。
model
{
#priors
Sbeta ~ dunif(0,20);
variancebeta<-pow(Sbeta,2);
taubeta<-1/variancebeta;
Salpha ~ dunif(0,20);
variancealpha<-pow(Salpha,2);
taualpha<-1/variancealpha
lambda ~ dnorm(0,5)
gamma ~ dnorm(0,5)
t3Dref ~ dnorm(0,1)
zT ~ dnorm(10,3)
a<-1/zT
zP ~ dunif(0,100)
c<-1/zP
#étude e
for(e in 1:Netude){
alpha[e] ~ dnorm(0,taualpha);
} #end etude e
#espèce i
for(i in 1:Nespece){
beta[i] ~ dnorm(0,taubeta);
} #end espece i
#courbe n
for(n in 1:Ncourbe){
logt3Dref[n]<-(log(t3Dref)+alpha[etude[n]]+beta[espece[n]]+(gamma*Matrice[n])+(lambda*Phase[n]))/log(10);
Mlogt3D[n]<-logt3Dref[n]+(Tref-Tempe[n])*a+(Pref-Press[n])*c;
variancet3D[n]<-pow(sigmat3D[n],2)
taut3D[n]<-1/variancet3D[n]
logt3D ~ dnorm(Mlogt3D[n],taut3D[n]);
} #end courbe n
}
#Data
list(Ncourbe=40, Nespece=2, Netude=3, espece=c(3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,6,6,6,6,6,6,6,6,6,6),
etude=c(1,1,1,1,1,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4), Matrice=c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),
Phase=c(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), Press=c(500,500,500,500,500,500,300,300,300,300,270,270,600,600,600,600,600,600,270,270,270,270,270,270,400,400,400,400,400,400,600,600,600,600,600,600,600,600,600,600),
Tempe=c(20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20), sigmat3D=c(19.246,22.12,63.38,61.24,90.74,148.125,2.495714286,20.95714286,17.2,15.74285714,25.24285714,10.41428571,31.66666667,33.53333333,35.11666667,66.6,38.5,50.6,57.88571429,57.75714286,57.22857143,57.18571429,58.17142857,56.51428571,22.32857143,16.08571429,75.64285714,18.6,45.28571429,9.944285714,128.26,75.84,92.44,128.88,127.64,126.68,123.6,110.04,97.58,157),
Tref=20, Pref=459)
答案 0 :(得分:1)
你只为beta [1]和beta [2]定义了先验,因为Nespece = 2,但你对logt3Dref [n]的定义使用beta [espece [n]],其中espece [n]取值因此它不知道beta [3]和beta [6]是什么。在错误消息中,3或6的“数组索引”大于2的“数组上限”。