title: How can I find a syntax error in JAGS considering that the position indicated is not the real error position?
body: <p>I am trying to adjust a model in <code>jags</code>. I have a syntax error, but I've been trying to find it for hours. Please, any help is welcome. Here is the model</p>
  <pre><code>library(jagsUI)
  nyears&lt;-8
  
  ad&lt;-c(707,768,149,221,329, 222,869,445)
  an&lt;-c(327,257,18,10,49,56,323,211)
  
  # Specify model in BUGS language
  
  cat(file =&quot;recipm.bug&quot;,&quot;
  
  model {
  #-------------------------------------------------------------------------
  #            define the priors of the unknown parameters
  #-------------------------------------------------------------------------
      
    tau.juv &lt;- pow(sigma.y, -2)
    sigma.juv ~ dunif(0, 20)
    sigma2.juv &lt;- pow(sigma.an, 2)
  
  #initial population sizes
  Njuv ~ (300,0.0001) I (0,) #tamanio inicial de la poblacion de aniales
  Nad ~ (700, 0.0001)I(0,) #tamanio inicial de la poblacion de adultos
  
  #survival probabilities and productivity
    for (t in 1:(nyears-1)){
      sjuv[t] &lt;- mean.sjuv
      sad[t]  &lt;- mean.sad
      f[t]    &lt;- mean.fec
      }
  
  mean.sjuv ~ dunif(0, 0.6)
  mean.sad ~ dunif(0.85,0.95 )
  mean.fec ~ dunif(0, 1)
  
  
  #---------------------------------------------------------------------------
  #                           derived parameters
  #---------------------------------------------------------------------------
  
  # Population recruitment traditional way
  for (t in 1:(nyears-1)){
    rec [t]&lt;-an[t]/ad[t]*0.5
  }
  
  # ---------------------------------------------------------------------------
  #               The likelihoods of the single data sets
  # ---------------------------------------------------------------------------
  
  # 3.1. Likelihood for population population count data (state-space
  #model)
  
  # 3.1.1 System process
  
  for (t in 2:nyears){
    mean.juv[t] &lt;- f[t-1] / 2 * sjuv[t-1] * Nad[t]
    Njuv[t]  ~  dpois(mean1[t])
   }
  
  
  # 3.1.2 Observation process
  for (t in 1:nyears){
    an[t] ~ dpois (mean(Njuv))
    ad[t] ~ dbin(Nad[t], tauy)
   }
  }
  
  &quot;,fill = TRUE)
  
  
  
  # Bundle data
  bugs.data &lt;- list( ad=ad,an=an,nyears = 8)
  
  # Initial values
  inits &lt;- function(){list(mean.sjuv = runif(1, 0, 1), mean.sad = runif
                           (1, 0, 1), mean.fec = runif(1, 0, 10),
                           Njuv = rpois(1,5), Nad = rpois(1,20), sigma.juv = runif
                           (1, 0, 10))}
  
  parameters&lt;-c(&quot;mean.sjuv&quot;,&quot;mean.sad&quot;,&quot;mean.fec&quot;, &quot;N1&quot;,&quot;Njuv&quot;)
  
  # MCMC settings
  ni &lt;- 20000
  nt &lt;- 6
  nb &lt;- 5000
  nc &lt;- 3
  
  # Call jags from R
  ipm &lt;- jags(data = bugs.data, inits,  n.chains = nc,parameters.to.save = parameters,
              model.file = &quot;recipm.bug&quot;, n.thin = nt, n.iter = ni, n.burnin = nb)
  
  
  </code></pre>
  <p>I am getting the following error `</p>
  <pre><code>Error in jags.model(file = model.file, data = data, inits = inits, n.chains = n.chains,  : 
    
  Error parsing model file:
  syntax error on line 18 near &quot;(&quot;
  </code></pre>
  <p>I know that JAGS is a declarative language and consequently, to position indicated in the warning may not be the position of the error, any idea of strategies to find this kind of error?
  Regards</p>