title: "Error: variable "real" does not exist in the model block" in Stan
body: <p>I am following the example code using Stan in Python but it is not compiled because of the syntax error: </p>
  
  <pre><code>ValueError: Failed to parse Stan model 'anon_model_ad43313e8b4b0b001a1a5d32da64a34e'. Error message:
  SYNTAX ERROR, MESSAGE(S) FROM PARSER:
  
  variable "real" does not exist.
    error in 'unknown file name' at line 20, column 9
    -------------------------------------------------
      18: }
      19: model{
      20:     real l1;
                  ^
      21:     real l2;   
    -------------------------------------------------
  </code></pre>
  
  <p>And this is the stan code:</p>
  
  <pre><code>import numpy as np
  import statsmodels.api as sm
  import pystan
  from scipy.stats import uniform, invgauss
  
  stan_code = """
  data{
      int&lt;lower=0&gt; N;
      vector[N] Y;
      vector[N] x1;
  }
  parameters{
      real beta0;
      real beta1;
      real&lt;lower=0&gt; lambda;
  }
  transformed parameters{
      vector[N] exb;
      vector[N] xb;
  
      for (i in 1:N) xb[i] = beta0 + beta1 * x1[i];
      for (i in 1:N) exb[i] = exp(xb[i]);
  }
  model{
      real l1;
      real l2;   
      vector[N] loglike;
  
      lambda ~ uniform(0.0001, 100);
  
      for (i in 1:N){
          l1 = 0.5 * (log(lambda) - log(2 * pi() * pow(Y[i], 3)));
          l2 = -lambda*pow(Y[i] - exb[i], 2)/(2 * pow(exb[i], 2) * Y[i]);
          loglike[i] = l1 + l2;
      }
      target += loglike;
  }
  """
  
  fit = pystan.stan(model_code=stan_code, data= stan_data, iter=5000, chains=3, warmup=2500, n_jobs=3)
  </code></pre>
  
  <p>Is there any something wrong? I also defined <code>stan_data</code> before implementing <code>stan</code> function.
  I read the Stan manual about the model block and it says it is allowed to declare local variables in the model block...
  Please let me know the problems above. </p>