I'm working on a simulated data set, trying to find a difference in plant size (Tamanho, in Portuguese) in different regions in Brazil (Região, in Portuguese).

Here is my prior:

modelo="

model{

for(i in 1:N){

y

*~dnorm(mu*

*,tau[x**])*

mumu

*<-a0+a[x**]*

}

sigma~dunif(0,20)

a0~dnorm(0,0.001)

for(j in 1:Lvs){

a[j]~dnorm(0.0,atau)

tau[j]~dgamma(sG,rG)

}

atau<-1/pow(aSD,2)

sG<-pow(m,2)/pow(d,2)

rG<-m/pow(d,2)

m~dgamma(1,0.222)

d~dgamma(1,0.222)

aSD<-abs(aSDunabs)+0.1

aSDunabs~dt(0,0.001,2)

}

"

...

here is my chains initialization command:

if(F){

modelGenInits()

}else{

a0=mean(Tamanho)

a=aggregate(Tamanho,list(Região),mean)[,2]-a0

tau=1/(aggregate(Tamanho,list(Região),sd)[,2])^2

genInitList<-function(){

return(

list(

a0=a0,

a=a,

tau=tau,

m=mean(tau),

d=sd(tau),

aSDunabs=sd(a)

)

)

}

}

However, when I try to initialize my model, I keep on receiving this message:

modelInits(bugsInits(genInitList))

Initializing chain 1:

initial values loaded but chain contain uninitialized variables

I am aware that I should provide initial values for my model, but I believe they are there in my initialization command! I'm sure I'm following all the recommendations in chapter 18 of Kruschke's book!

Could someone tell me where I went wrong?

Thanks a lot}

sigma~dunif(0,20)

a0~dnorm(0,0.001)

for(j in 1:Lvs){

a[j]~dnorm(0.0,atau)

tau[j]~dgamma(sG,rG)

}

atau<-1/pow(aSD,2)

sG<-pow(m,2)/pow(d,2)

rG<-m/pow(d,2)

m~dgamma(1,0.222)

d~dgamma(1,0.222)

aSD<-abs(aSDunabs)+0.1

aSDunabs~dt(0,0.001,2)

}

"

...

here is my chains initialization command:

if(F){

modelGenInits()

}else{

a0=mean(Tamanho)

a=aggregate(Tamanho,list(Região),mean)[,2]-a0

tau=1/(aggregate(Tamanho,list(Região),sd)[,2])^2

genInitList<-function(){

return(

list(

a0=a0,

a=a,

tau=tau,

m=mean(tau),

d=sd(tau),

aSDunabs=sd(a)

)

)

}

}

However, when I try to initialize my model, I keep on receiving this message:

modelInits(bugsInits(genInitList))

Initializing chain 1:

initial values loaded but chain contain uninitialized variables

I am aware that I should provide initial values for my model, but I believe they are there in my initialization command! I'm sure I'm following all the recommendations in chapter 18 of Kruschke's book!

Could someone tell me where I went wrong?

Thanks a lot