Autoregressive node
The AR node (also exported as Autoregressive) encodes a Bayesian autoregressive process of order p:
\[y_t \sim \mathcal{N}(\theta^\top x_t, \, \gamma^{-1})\]
where yₜ is the current observation, xₜ = (yₜ₋₁, …, yₜ₋ₚ) is the vector of p lagged values, θ is the vector of AR coefficients, and γ is the observation precision.
This node is the natural building block for time series models such as AR(p), latent AR processes, and state-space models with autoregressive dynamics.
Interfaces
| Interface | Alias | Role |
|---|---|---|
y | out | Current observation yₜ |
x | — | Lagged state vector (yₜ₋₁, …, yₜ₋ₚ) |
θ | — | AR coefficient vector (length p) |
γ | — | Observation precision (scalar) |
Metadata
ARMeta is required and must be passed explicitly — the node has no default meta:
y[t] ~ AR(x[t], θ, γ) where { meta = ARMeta(Multivariate, order, ARsafe()) }The constructor takes:
UnivariateorMultivariate— variate form (determines howxandyare interpreted).order— the AR orderp(must equal 1 forUnivariate).ARsafe()orARunsafe()— numerical stability mode (ARsafeadds a small regularization to avoid singular matrices;ARunsafeis faster but may be numerically fragile).
Univariate vs multivariate
ARMeta{Univariate} treats y and the first element of x as scalars, with order forced to 1. This is an AR(1) model.
ARMeta{Multivariate} uses the full companion-matrix representation to handle AR(p) for p > 1. The state vector x has length p, and the AR process is embedded as a linear state-space model. See CompanionMatrix for the underlying algebraic structure.
State vector slicing
The ReactiveMP.ar_unit and ReactiveMP.ar_slice utilities extract specific parts of the joint state vector in the multivariate setting:
ReactiveMP.ar_unit— returns an appropriately shaped zero vector or matrix for initializing accumulators.ReactiveMP.ar_slice— extracts a subvector or submatrix from a joint mean/covariance. This is used inside rules to separate theypart from thexpart of the joint Gaussianq(y, x).
These are internal helpers that surface when writing custom rules for AR-based models.
ReactiveMP.ar_unit — Function
ar_unit(::T, order)Returns [ 1.0, 0.0 ... 0.0 ] with length equal to order in case if T is Multivariate, and 1.0 in case if T is Univariate
ReactiveMP.ar_slice — Function
ar_slice(::T, array, ranges...)Returns array[ranges...] in case if T is Multivariate, and first(array[ranges...]) in case if T is Univariate