# DLM implementation of the mean reverting model

I am trying to use DLM package in R to estimate a state space repersentation of the term structure model, where observation and state equation are as follows

$y(t )= F* x_t +e_t$
$x_t- \mu = G* (x_{t-1}-\mu) +n_t$

where $e_t$ and $n_t$ are Gaussian. Only modification with standard DLM representation in the R is the term $\mu$ (mean of the state variable) (which is also unknown) in the state equation. I am not sure how to use DLM package to estimate such models.

I would be extremely grateful for the any help in this regard.

It seems to me that your state equation can be writen as $$\pmatrix{x_t \\ \mu_t} = \pmatrix{G & I-G \\ 0 & I}\pmatrix{x_{t-1} \\\mu_{t-1}} + \pmatrix{n_t \\ 0}.$$ The extra element in the state vector will track after some iterations of the Kalman filter the fixed mean $\mu$.
• thanks a lot Tusell ...I got the idea...but I think modification should be $\pmatrix{G & I-G \\ 0 & I}$ .... – Sudarshan Jan 8 '18 at 14:49