Helpers for a two-dimensional (2D) AR1 process, with separable correlation
across years and ages. TAM uses these helpers only for process = "ar1";
IID processes use Normal densities and draws directly.
dprocess_ar1()returns the log-density contribution for a given matrixx.rprocess_ar1()generates a matrix draw with the requested dependence structure.
Arguments
- x
A numeric matrix (\(n_y \times n_a\)) of process residuals for
dprocess_ar1().- phi
Length-2 numeric vector
c(phi_age, phi_year)with values in \((-1, 1)\) for AR(1); zero gives independence.- sd
Positive innovation-scale SD \(\sigma\); the marginal SD is \(\sigma/\sqrt{(1-\phi_\text{age}^2)(1-\phi_\text{year}^2)}\).
- ny, na
Positive integers: numbers of years and ages for
rprocess_ar1().
Value
dprocess_ar1(): a single numeric log-density value.rprocess_ar1(): a numeric matrix of dimension \(n_y \times n_a\).
Details
Separable AR1 process: density and simulation
Let \(X \in \mathbb{R}^{n_y \times n_a}\) denote the process on year (\(y\)) and age (\(a\)) indices. It follows a stationary separable AR(1) in both dimensions with correlations \(\phi_\text{age}\) (columns) and \(\phi_\text{year}\) (rows), satisfying \(|\phi|<1\).
The implied covariance is $$\mathrm{Cov}\{\mathrm{vec}(X)\} = \frac{\sigma^2}{(1-\phi_\text{age}^2)(1-\phi_\text{year}^2)} \; \Sigma_\text{age} \otimes \Sigma_\text{year},$$
where \(\Sigma_\cdot\) are AR(1) correlation matrices with entries \(\phi^{|i-j|}\).