title: JAGS error message - Node inconsistent with parents
body: <p>The dataset contains ~11,000 rows so I have been scaling it back whilst checking that the code runs. All of the rows contain information extracted from Sentinel-2a images and a digital elevation map whilst a subset of 117 cells also contain habitat covariates recorded on a field trip. As such, some of the columns, including the response variable (S1), are characterised by a high proportion of NAs.</p>
  
  <p>The model seems to run OK when I limit K to 450 but I get the following error message when I increase it to 500:</p>
  
  <pre><code>Error in node S1[500]
  Node inconsistent with parents
  </code></pre>
  
  <p>I get a similar error message when I create a dataframe only including the 117 rows that contain remotely sensed data and data recorded in the field. There are a few NAs in this dataset as some plots were inaccessible but the majority of cells contain values.</p>
  
  <p>I tried removing the #inits# line after reading this thread:
  <a href="https://stackoverflow.com/questions/43290715/rjags-output-node-inconsistent-with-parents">RJAGS output Node inconsistent with parents</a>.
  This results in the model running. I think this suggests that the issue is with the initialisation?</p>
  
  <p>First five rows of full dataframe:</p>
  
  <pre><code>S1 Logit_tussac soil_moisture DEM_slope DEM_aspect DEM_elevation sentinel1 sentinel2 sentinel3 sentinel4 sentinel5 sentinel6 sentinel7 sentinel8 sentinel9 sentinel10
  NA           NA            NA  2.434239   168.5011   0.588606366    0.0413    0.0499    0.0531    0.1035    0.1862    0.1968    0.1808    0.1318    0.0400     0.0199
  NA           NA            NA  3.705001   178.1289   1.007037127    0.0966    0.1108    0.1212    0.0855    0.0917    0.1063    0.0937    0.1842    0.0341     0.0161
  NA           NA            NA  5.006181   180.0000   1.883010797    0.1309    0.1472    0.1361    0.0855    0.0917    0.1063    0.0937    0.1572    0.0341     0.0161
  NA           NA            NA  5.006181   180.0000   2.758984468    0.0542    0.0512    0.0472    0.0145    0.0127    0.0092    0.0166    0.0510    0.0148     0.0080
  NA           NA            NA  3.014719   161.5793   0.004048217    0.0224    0.0138    0.0223    0.1019    0.1209    0.1332    0.1504    0.0411    0.1099     0.0608
  NA           NA            NA  2.907236   170.7134   0.504032418    0.0470    0.0634    0.0544    0.1019    0.1209    0.1332    0.1504    0.0997    0.1099     0.0608
  </code></pre>
  
  <p>First five rows of dataframe only containing the cells that contain covariates measured in the field:</p>
  
  <pre><code>S1 Logit_tussac soil_moisture DEM_slope DEM_aspect DEM_elevation sentinel1 sentinel2 sentinel3 sentinel4 sentinel5 sentinel6 sentinel7 sentinel8 sentinel9 sentinel10
  NA          NA            NA 14.917334   256.1612      12.24432    0.0513    0.0588    0.0541    0.1145    0.1676    0.1988    0.1977    0.1658    0.1566     0.0770
  0    -9.210240             1 23.803741   225.1231      16.88028    0.1058    0.1370    0.2139    0.2387    0.2654    0.2933    0.3235    0.2928    0.3093     0.1601
  NA          NA            NA 20.789165   306.0945      18.52480    0.0287    0.0279    0.0271    0.0276    0.0290    0.0321    0.0346    0.0452    0.0475     0.0219
  NA   -9.210240             1  6.689442   287.9641      36.08975    0.0462    0.0679    0.1274    0.1535    0.1797    0.2201    0.2982    0.2545    0.4170     0.2252
  0    -9.210240             1 25.476444   203.0659      23.59964    0.0758    0.1041    0.1326    0.1571    0.2143    0.2486    0.2939    0.2536    0.3336     0.1937
  1    -1.385919             3  1.672511   270.0000      39.55215    0.0466    0.0716    0.1227    0.1482    0.2215    0.2715    0.3334    0.2903    0.3577     0.1957
  </code></pre>
  
  <p>soil_moisture is a factor whilst the other variables are numeric.</p>
  
  <p>The model:</p>
  
  <pre><code>model &lt;- "model{
  for(i in 1:K) {
  S1[i]~dpois(lambda1[i])
  lambda1[i]&lt;-exp(a0+ a1*DEM_aspect[i]+a2*DEM_slope[i]+a3*DEM_elevation[i]+
  a4*tussac[i]+a5*sentinel1[i]+a6*sentinel2[i]+a7*sentinel3[i]+a8*sentinel4[i]
  +a9*sentinel5[i]+a10*sentinel6[i]+a11*sentinel7[i]+a12*sentinel8[i]
  +a13*sentinel9[i]+a14*sentinel10[i])
  
  muLogit_tussac[i]&lt;-b0+b1*sentinel7[i]+b2*sentinel9[i]+b3*DEM_elevation[i]
  
  Logit_tussac[i]~dnorm(muLogit_tussac[i], tau) 
  logit(tussac[i])&lt;-Logit_tussac[i]
  }
  
  # Priors
  
  a0~dnorm(0, 10)
  a1~dnorm(0, 10)
  a2~dnorm(0, 10)
  a3~dnorm(0, 10)
  a4~dnorm(0, 10)
  a5~dnorm(0, 10)
  a6~dnorm(0, 10)
  a7~dnorm(0, 10)
  a8~dnorm(0, 10)
  a9~dnorm(0, 10)
  a10~dnorm(0, 10)
  a11~dnorm(0, 10)
  a12~dnorm(0, 10)
  a13~dnorm(0, 10)
  a14~dnorm(0, 10)
  
  b0~dnorm(0, 10)
  b1~dnorm(0, 10)
  b2~dnorm(0, 10)
  b3~dnorm(0, 10)
  
  tau~dgamma(0.001, 0.001)
  
  #data# S1, K, sentinel1, sentinel2, sentinel3, sentinel4, sentinel5, sentinel6, sentinel7, sentinel8, sentinel9, sentinel10, DEM_slope, DEM_aspect, DEM_elevation
  #inits# a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, b0, b1, b2, b3
  #monitor# a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, b0, b1, b2, b3, ped, dic
  }"
  </code></pre>
  
  <p>I’ve tried a range of different values for the priors including but not limited to (0, 5), (0, 0.5) (0, 0.001)</p>
  
  <p>I used the following information for running the code:</p>
  
  <pre><code># Initial values
  a0 &lt;- list(chain1=1, chain2=2)
  a1 &lt;- list(chain1=1, chain2=2)
  a2 &lt;- list(chain1=1, chain2=2)
  a3 &lt;- list(chain1=1, chain2=2)
  a4 &lt;- list(chain1=1, chain2=2)
  a5 &lt;- list(chain1=1, chain2=2)
  a6 &lt;- list(chain1=1, chain2=2)
  a7 &lt;- list(chain1=1, chain2=2)
  a8 &lt;- list(chain1=1, chain2=2)
  a9 &lt;- list(chain1=1, chain2=2)
  a10 &lt;- list(chain1=1, chain2=2)
  a11 &lt;- list(chain1=1, chain2=2)
  a12 &lt;- list(chain1=1, chain2=2)
  a13 &lt;- list(chain1=1, chain2=2)
  a14 &lt;- list(chain1=1, chain2=2)
  
  b0 &lt;- list(chain1=1, chain2=2)
  b1 &lt;- list(chain1=1, chain2=2)
  b2 &lt;- list(chain1=1, chain2=2)
  b3 &lt;- list(chain1=1, chain2=2)
  
  model &lt;- run.jags(model=model, burnin=1000, sample=10000, n.chains=2, modules="glm")
  </code></pre>
  
  <p>Any idea how to resolve the error, why it only appears with K of a certain size and why removing #inits# results in it running? </p>
  
  <p>Sorry for the wall of text and code. I thought it was best to include as much information as possible. I'm very new to JAGS so I'm still a bit unsure about what is relevant.</p>