This is an old version, view current version.

23.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).

23.7.1 Sampling statement

y ~ gaussian_dlm_obs(F, G, V, W, m0, C0)

Increment target log probability density with gaussian_dlm_obs_lupdf(y | F, G, V, W, m0, C0).
Available since 2.0

23.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.
Available since 2.12

real gaussian_dlm_obs_lupdf(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. This function drops constant additive terms.
Available since 2.25

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.
Available since 2.12

real gaussian_dlm_obs_lupdf(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. This function drops constant additive terms.
Available since 2.25

References

Durbin, J., and S. J. Koopman. 2001. Time Series Analysis by State Space Methods. New York: Oxford University Press.