21.7 Gaussian Dynamic Linear Models
A Gaussian Dynamic Linear model is defined as follows, For \(t \in 1, \dots, T\), \[ \begin{aligned}[t] y_{t} &\sim N(F' \theta_{t}, V) \\ \theta_{t} &\sim N(G \theta_{t - 1}, W) \\ \theta_{0} &\sim N(m_{0}, C_{0}) \end{aligned} \] where \(y\) is \(n \times T\) matrix where rows are variables and columns are observations. These functions calculate the log-likelihood of the observations marginalizing over the latent states (\(p(y | F, G, V, W, m_{0}, C_{0})\)). This log-likelihood is a system that is calculated using the Kalman Filter. If \(V\) is diagonal, then a more efficient algorithm which sequentially processes observations and avoids a matrix inversions can be used (Durbin and Koopman 2001, sec. 6.4).
21.7.1 Sampling Statement
y ~
gaussian_dlm_obs
(F, G, V, W, m0, C0)
Increment target log probability density with gaussian_dlm_obs_lpdf(y | F, G, V, W, m0, C0)
dropping constant additive terms.
21.7.2 Stan Functions
The following two functions differ in the type of their V, the first taking a full observation covariance matrix VĀ and the second a vector VĀ representing the diagonal of the observation covariance matrix. The sampling statement defined in the previous section works with either type of observation V.
real
gaussian_dlm_obs_lpdf
(matrix y | matrix F, matrix G, matrix V, matrix W, vector m0, matrix C0)
The log of the density of the Gaussian Dynamic Linear model with observation matrix y in which rows are variables and columns are observations, design matrix F, transition matrix G, observation covariance matrix V, system covariance matrix W, and the initial state is distributed normal with mean m0 and covariance C0.
real
gaussian_dlm_obs_lpdf
(matrix y | matrix F, matrix G, vector V, matrix W, vector m0, matrix C0)
The log of the density of the Gaussian Dynamic Linear model with observation matrix y in which rows are variables and columns are observations, design matrix F, transition matrix G, observation covariance matrix with diagonal V, system covariance matrix W, and the initial state is distributed normal with mean m0 and covariance C0.
References
Durbin, J., and S. J. Koopman. 2001. Time Series Analysis by State Space Methods. New York: Oxford University Press.