stan-dev / stan-dev/docs

Problem in the documentation for the autoregressive moving average model

Open
#884 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TeX
Stars
43
Forks
133
Avg merge
11h 32m
Merged PRs (30d)
4

Description

I'm sorry if i'm wrong, but it looks like an error to me. This is the code shown in the documentation which i link here

data {
  int<lower=1> T;            // num observations
  array[T] real y;                 // observed outputs
}
parameters {
  real mu;                   // mean coeff
  real phi;                  // autoregression coeff
  real theta;                // moving avg coeff
  real<lower=0> sigma;       // noise scale
}
model {
  vector[T] nu;              // prediction for time t
  vector[T] err;             // error for time t
  nu[1] = mu + phi * mu;     // assume err[0] == 0
  err[1] = y[1] - nu[1];
  for (t in 2:T) {
    nu[t] = mu + phi * y[t - 1] + theta * err[t - 1];
    err[t] = y[t] - nu[t];
  }
  mu ~ normal(0, 10);        // priors
  phi ~ normal(0, 2);
  theta ~ normal(0, 2);
  sigma ~ cauchy(0, 5);
  err ~ normal(0, sigma);    // error model
}

in the code nu_1 is set to mu + phi * mu. This is already cryptic to me. If we assume for semplicity that y_0 and err_0 begin at their respective mean, nu[1] should be equal simply to mu. For the same reason the assignment nu[t] = mu + phi * y[t - 1] + theta * err[t - 1]; feels wrong to me. it should be
nu[t] = mu + phi * (y[t - 1] - mu) + theta * err[t - 1]: in the ARMA(1, 1) process and in general in every ARMA(p, q) it should be the sequenze y_t = x_t - mu that follows y_t = phi * y_t-1 + z_t + theta z_t-1.

Beside the above problem that i find most important, i found some inconsistency in the documentation. In the section for the autoregressive model it's suggested to leave unconstrained the parameter phi in order to assess stationarity. But in the ARMA section it's suggested that if there's no suspect of a non stationary time series to constrain the parameters phi. In the documentation it's not clear by the way what should be the constraint for higer order ARMA since constraining them in (-1, 1) it's probably not sufficient, and i don't even know if there's a constrain on the parameters in closed form

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read the linked moving-average-models section and compare it with the autoregressive section, focusing on the displayed ARMA equations and the discussion of stationarity constraints. Check whether the initial condition, mean adjustment, and higher-order parameter constraints are consistent, then update the documentation so the intended equations and constraints are explicit.

Written by the indexing model from the issue text.

Assessment

Tech stack
tex
Domain
documentation
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.