title: Rjags Invalid parent value error with use of hyper prior
body: <p>I'm using rjags to calculate a species abundance using an N-mixture model and count data. To capture over dispersion of my data, I used hyperpriors. But I get an </p>
  
  <pre><code>"Error in node S[1,1,2] Invalid parent values"
  </code></pre>
  
  <p>My guess is that I have a problem in the dimension of my prior OR one of the prior is negative, null or NA which stops the calculation of node S.</p>
  
  <p>Any idea how to stop this problem ? Is it possible to initialize S?</p>
  
  <pre><code>model {
  ##  PRIORS ##
  
  lambda[1] ~ dunif(0, 500)
  lambda[2] ~ dunif(0, 500) 
  p[1] ~ dunif(0, 1)
  p[2] ~ dunif(0, 1)
  # surdispersion
  muepsomega1 ~ dnorm(0,0.0001)
  sigepsomega1 ~ dunif(0,100)
  iomega1 ~ dnorm(0,0.0001)
  tauepsomega1 &lt;- 1/(sigepsomega1*sigepsomega1) 
  omega2 ~ dunif(0, 1)
  
  ## LIKELIHOOD ##
  # Create a loop across all j sites
  for(j in 1:nSites) {
  
  # surdispersion sur omega 1
  omega1[j] &lt;- iomega1 + epsomega1[j]
  epsomega1[j] ~ dnorm(muepsomega1,tauepsomega1)
  
  N[1,j,1] ~ dpois(lambda[1]) 
  N[2,j,1] ~ dpois(lambda[2])
  
  for (i in 1:3) {    
    S[i,j,1] ~ dnegbin(2, 1) 
    } # end loop i
  for(t in 2:nYears) {
    # Estimate survivorship (between year survival)
    S[1,j,t] ~ dnegbin(omega1[j], N[1,j,t-1])  
    S[2,j,t] ~ dnegbin(omega2, N[2,j,t-1]) 
  
    N[1,j,t] &lt;- S[1,j,t] 
    N[2,j,t] &lt;- S[2,j,t] 
    } # end loop t in 2:years
  
  # Loop across sampling replicates to estimate detection
  for (t in 1:nYears){
    for(k in 1:nReps){
      n[1,j,k,t] ~ dnegbin(p[1], N[1,j,t]) 
      n[2,j,k,t] ~ dnegbin(p[2], N[2,j,t]) 
  
     } # end loop k nreps
    } # end loop j sites
  }
  </code></pre>
  
  <p>This is how I call the model:</p>
  
  <pre><code>#Model file
  modFile = "model/2016-07-12/model_Nmix.R"
  
  inits &lt;- function(){
  list('lambda' =c(1,1), 'p'= c(1,1),'omega2' = 1,'iomega1'=1, 'muepsomega1'= 1, 'sigepsomega1'= 1, 'epsomega1'=c(1,1,1,1,1,1,1)) } # size epsomega1 is length(nSites)=7
  
   # Compile the model
   require(rjags)
   abundance.out &lt;- jags.model(file=modFile, data=data,n.chains = 3, n.adapt = 3000)
  </code></pre>