="section level3 unnumbered">
<h3>MA(2) Example</h3>
<p>An <span class="math inline">\(\mbox{MA}(2)\)</span> model can be coded in Stan as follows.</p>
<pre><code>data {
  int&lt;lower=3&gt; T;  // number of observations
  vector[T] y;     // observation at time T
}
parameters {
  real mu;              // mean
  real&lt;lower=0&gt; sigma;  // error scale
  vector[2] theta;      // lag coefficients
}
transformed parameters {
  vector[T] epsilon;    // error terms
  epsilon[1] = y[1] - mu;
  epsilon[2] = y[2]