Dear R and WinBUGS users,

First of all, sorry for the long email and questions...

I am new to Bayesian statistics so I am most likely making a very sily and
naive mistake. Anyway, I trying to build a hierachical model where in the
1st level I try to estimate the distributions mu.h derived from the
samples/data. On the "2nd level" I wish to apply a regression to that mu.h
in order to get a final distribution according to the influence of many
fixed and random effects (please see my attempt of model below).

My questions are:

1. When using WinBUGS the "first level" of my model works fine, however,
when using R with R2WinBUGS (as I did many times before) I get Error:
evaluation nested too deeply: infinite recursion /
options(expressions=)?!!". I thought it could be from my initial values but
I tried all possiblities and still doesn't work. Any ideas on what the
problem might be?

2. When including the "2nd level" (i am not sure if I can do this?) I get a
common error: array index is greater than array upper bound for b5. I tried
many things but the error persists. I thought it could be from one of the N
but this is done by finding the length in R so it is not possible that
there is a miscounting...

3. My final question, if not asking for too much, is more like a request for
statistical advice: is the link between my 1st and 2nd levels reasonable or
it shoud be modeled all at once? Meaning that I should only have one "mu"
that incorporates all the steps and in this case my 1st level should be part
(in some way) of my regression?


# # 1st level - Trying to estimate mu.h from data Aa, Bb and C (Aa and Bb
have error but not C)
model
{
for(i in 1:Nh)
{
 TD[i]~dnorm(mu.h[i],tau.h)
 mu.h[i]<- ( A[i] * B[i] ) - C[i]
}

for(i in 1:N)
{
A[i] ~ dnorm(Aa[i],tau.A)
Aa[i] ~ dnorm(34, tau.A)
}

for(i in 1:NB)
{
B[i] ~ dnorm(Bb[i],tau.B)
Bb[i] ~ dnorm(40,tau.B)
}

for(i in 1:NC)
{
C[i] ~ dnorm(753,100000)
}

sigma.h ~ dunif(0,100)
tau.h<- 1/(sigma.h*sigma.h)

sigma.A ~ dunif(0,100)
tau.A <- 1/(sigma.A*sigma.A)

sigma.B ~ dunif(0,100)
tau.B <- 1/(sigma.B*sigma.B)

## ok - so far it works fine in WinBUGS but not when using R2WinBUGS where I
get: "Error: evaluation nested too deeply: infinite recursion /
options(expressions=)?!!"

# 2nd level! - trying to estimate mu.t with b1-b5 as fixed effects, bc and y
as random effects and finally my mu.t should come from mu.h

for(i in 1:Nt)
{
 mu.h[i] ~ dnorm(mu.t[i],tau.t)
 mu.t[i] <- b0 + b1[m[i]] + b2[q[i]] + b3[p[i]] + b4[g[i]] + b5[v[i]] +
u[bc[i]] + w[y[i]]
}

b0 ~ dunif(0,1000000)

for(i in 1:Nm)
{
b1[i] ~ dunif(0,100000)
}

b2[1] <- 0
for(i in 2:Nq)
{
b2[i] ~ dunif(0,1000000)
}

for(i in 1:Np)
{
b3[i] ~ dunif(0,100000)
}

for(i in 1:Ng)
{
b4[i] ~ dunif(0,100000)
}

for(i in 1:Nv)
{
b5[i] ~ dunif(0,100000)
}

 # random effect parameters

for(i in 1:Nbc)
{
u[i] ~ dnorm(0,tau.bc)
}
sigma.bc ~ dunif(0,100)
tau.bc <- 1/(sigma.bc*sigma.bc)

for(i in 1:Ny)
{
w[i] ~ dnorm(0,tau.y)
}
sigma.y ~ dunif(0,100)
tau.y <- 1/(sigma.y*sigma.y)

 }


Is this too much?

Thank you very mucj for your help.

Best regards,

Mafalda

	[[alternative HTML version deleted]]

