Skip to content

Problem in the documentation for the autoregressive moving average model #884

@Sghizzus

Description

@Sghizzus

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions