Suppose I have a dynamic linear model as defined in the dlm-package for R, see Petris 2009.

$y_t = F_t θ_t + ν_t, ν_t$~$N(0,V_t)$

$θ_t = G_t θ_{t-1}+ω_t,ω_t$~$N(0,W_t)$.

A random walk without drift would be specified as $F_t=G_t=1$, resulting in

$y_t = θ_t + ν_t, ν_t$~$N(0,V_t)$

$θ_t = θ_{t-1}+ω_t,ω_t$~$N(0,W_t)$.

A “random walk with drift DLM” I would think of as

$y_t = θ_t + ν_t, ν_t$~$N(0,V_t)$

$θ_t = θ_{t-1}+d +ω_t,ω_t$~$N(0,W_t)$.

Can that be represented in the DLM framework defined as above? If so, how?

Possibly related: Random walk with drift are differences white noise? , as perhaps a such-specifiable DLM may be obtained by differencing the data.


Yes, it is possible with two states. Use dlmModPoly() to form a dlm from a second order polinomial. This initializes a model with the following parametrization:

$ y_t = \begin{pmatrix} 1 & 0 \end{pmatrix} \space \theta_t + \nu_t, \nu_t \sim N(0,V_t) \\ \theta_t = \begin{pmatrix} 1 & 1 \\ 0 & 1 \end{pmatrix} \theta_{t−1} + ω_t, ω_t \sim N(0, W_t)$

where $\theta_t$ is a $2×1$ vector and $W_t$ is a $2×2$ covariance matrix.

Thenestimate the time-invariant $V_t = x_1 $, $W_t=\begin{pmatrix} x_2 & 0 \\ 0 & 0 \end{pmatrix}$ (as well as the starting values $m_0$ for both states $\theta_{1,2})$.

This works as follows. At the observation level, the first state $\theta_{1}$ plus a normal observation noise is returned.

The first state equals its previous value plus the second state plus the normal random walk step.

As the second state is time-invariant (fixed variance of zero and autoregressive coefficient of 1), its value is entirely determined by the initial value $m_0$, which dlm solves using maximum likelihood estimation. This second state serves as the fix trend $d$.

Here is the R-code:

dlmModPoly(order = 2, dV = exp(x[1]), dW = c(0,exp(x[2])))

  • $\begingroup$ I set up my model as your solution. I obtained Wzz = 0 (z corresponds to the drift) for the optimal model. However, when I use dlmFilter on the optimized model (i.e. dlmFilter(Y,modMLE)) the results for the drift state modMLE.filt$m are time-variant. Did it happen to you as well? $\endgroup$ – FerdinandC Mar 31 '16 at 1:54
  • 1
    $\begingroup$ Should the above R code not be, dlmModPoly(order = 2, dV = exp(x[1]), dW = c(exp(x[2]),0)) ? $\endgroup$ – user2338823 Oct 22 '18 at 6:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.