# JAGS: unobserved parents and intialization

I have a very simple multinomial logistic regression problem; it's a simplified version of the alligator lake/food/size BUGS example. In my case I have (effectively) lake/food and have just stripped down the alli.bug example to handle two dimensional information: worker and IP address. There are 18 categories of 'worker' and 23 categories of 'IP address'.

Unfortunately I am getting an error

  Error in node X[1,1:23] Observed node inconsistent with
unobserved parents at initialization


Granted, there is a strong possibility I've more than one bug, but I understand that this is typically associated with an initialization problem. Unfortunately, my initialization matrices are rather large. A shotgun approach to finding appropriate values seems unlikely to succeed within a reasonable period of time.

Any hints or suggestions about possible next steps would be greatly appreciated.

EDIT: Here's the code. As I mentioned, it's just a stripped down version of the Alligator example. I've also fiddled with the subscripts on X[i,] a bit so the error message may be slightly different (will refer to node X[1,1] rather than X[1,1:23]).

var
X[I,K],      # observations I=no of workers=18, K=no of jobs=23
n[I],        # total for each covariate pattern
E[I,K],      # fitted values
OlogOE[I,K], # O log O/E
G2,            # goodness-of-fit statistic
phi[I,K],    # exp (beta[k] ' x[i,j])
p[I,K],      # fitted probabilities
alpha[K],      # factor for jobs = 2,...,23
beta[I,K],     # factor for workers = 2,...,18  for each job
b[I,K];         # factor for workers = 2,..,,18, relative to job 1, centred
model {
# PRIORS
alpha[1] <- 0;       # zero contrast for baseline workers
for (k in 2:K){
alpha[k] ~ dnorm(0,0.001);  # vague priors
}
# Loop around jobs:
for (k in 1:K){
beta[1,k] <- 0;   # corner-point contrast with first worker
}
for (i in 2:I) {
beta[i,1] <- 0;   # zero contrast for baseline worker
for (k in 2:K) {
beta[i,k] ~ dnorm(0,0.001); # vague priors
}
}

# LIKELIHOOD

for (i in 1:I) {                 # loop around workers
for (k in 1:K) {           # loop around jobs
# Multinomial response
X[i,k] ~ dmulti(p[i,k] , n[i]);
p[i,k]        <- phi[i,k] / sum(phi[i,]);
log(phi[i,k]) <- alpha[k] + beta[i,k];
}
}

# FITTED VALUES
for (i in 1:I) {     # loop around worker
for (k in 1:K) {     # loop around jobs
E[i,k] <- p[i,k] * n[i];
OlogOE[i,k] <- X[i,k] * log( X[i,k] / E[i,k] );
}
}
G2 <- 2 * sum( OlogOE[,] );
}

• Try not initializing the parameters for that node (which may be all the parameters in the model) and let JAGS pick the initial values for you; if it fails, we can think of something else. – jbowman May 16 '12 at 15:48
• Sorry, I should have mentioned that I tried that. I also tried a few different SEED values. Finally, I'm not sure how relevant it is, but I should mention that my data matrix X[,] is very sparse (mostly 0's) - which may give me problems later. – Aengus May 16 '12 at 15:53
• If your code isn't too long, could you post it? – jbowman May 16 '12 at 18:24
• is the etiquette to add it as an edit to the original post or to post it in comments? – Aengus May 16 '12 at 21:40
• stats.stackexchange.com/q/17121/5509 – Curious Apr 27 '14 at 20:54