Annotated Equations

A quick reference for the models introduced in the R Tutorial.

Baseline model: AR + covariate + Gaussian error

The same structure as the ARIMAX models from previous lessons: a covariate, an AR term, and Gaussian error.

\[ y_t = \underbrace{\color{#2b6cb0}{c}}_{\textstyle\color{#2b6cb0}{\text{constant}}} \;+\; \underbrace{\color{#319795}{\beta_1 x_{1,t}}}_{\textstyle\color{#319795}{\text{covariate}}} \;+\; \underbrace{\color{#c05621}{\beta_2 y_{t-1}}}_{\textstyle\color{#c05621}{\text{AR: lag-1}}} \;+\; \underbrace{\color{#718096}{\mathcal{N}(0,\sigma^2)}}_{\textstyle\color{#718096}{\text{Gaussian noise}}} \]

  • \(y_t\) — the observed value at time \(t\)
  • \(c\) — a constant
  • \(\beta_1 x_{1,t}\) — the covariate effect
  • \(\beta_2 y_{t-1}\) — AR: the effect of the previous value
  • \(\mathcal{N}(0,\sigma^2)\) — Gaussian noise with mean 0 and variance \(\sigma^2\)

In mvgam: the AR term is specified with trend_model = AR(p = 1) rather than in the model formula.

The same model, decomposed

The same model written as an observation distribution around a modeled mean.

\[ y_t = \mathcal{N}( \underbrace{\color{#d53f8c}{\mu_t}}_{\textstyle\color{#d53f8c}{\text{process mean}}},\sigma^2 ) \]

\[ \color{#d53f8c}{\mu_t} = \underbrace{\color{#2b6cb0}{c}}_{\textstyle\color{#2b6cb0}{\text{constant}}} \;+\; \underbrace{\color{#319795}{\beta_1 x_{1,t}}}_{\textstyle\color{#319795}{\text{covariate}}} \;+\; \underbrace{\color{#c05621}{\beta_2 y_{t-1}}}_{\textstyle\color{#c05621}{\text{AR: lag-1}}} \]

  • \(y_t\) — the observed value at time \(t\), drawn from a normal distribution
  • \(\mu_t\) — the process mean at time \(t\)
  • \(\sigma^2\) — the variance of the noise around that mean
  • \(c\), \(\beta_1 x_{1,t}\), \(\beta_2 y_{t-1}\) — the same terms as the baseline model, now determining \(\mu_t\)

Why rewrite it: separating the observation distribution from the model of \(\mu_t\) makes it easy to swap in a different distribution.

Modeling count data: Poisson error

Counts are non-negative integers, so we replace the normal distribution with a Poisson distribution.

\[ y_t = \mathrm{Pois}( \underbrace{\color{#d53f8c}{\lambda_t}}_{\textstyle\color{#d53f8c}{\text{rate parameter}}} ) \]

\[ \underbrace{\color{#d69e2e}{\log(\lambda_t)}}_{\textstyle\color{#d69e2e}{\text{log link}}} = \underbrace{\color{#2b6cb0}{c}}_{\textstyle\color{#2b6cb0}{\text{constant}}} \;+\; \underbrace{\color{#319795}{\beta_1 x_{1,t}}}_{\textstyle\color{#319795}{\text{covariate}}} \;+\; \underbrace{\color{#c05621}{\beta_2 y_{t-1}}}_{\textstyle\color{#c05621}{\text{AR: lag-1}}} \]

  • \(y_t\) — the observed count at time \(t\)
  • \(\lambda_t\) — the Poisson rate parameter: both the mean and the variance, so it must be positive
  • \(\log(\lambda_t)\) — the log link: modeling \(\log(\lambda_t)\) instead of \(\lambda_t\) keeps \(\lambda_t\) positive
  • \(c\), \(\beta_1 x_{1,t}\), \(\beta_2 y_{t-1}\) — the same terms as before, now predicting \(\log(\lambda_t)\)

Note: the model is linear on the log scale, so the covariate’s effect on untransformed abundance is exponential.