I have a state space model of the form

\begin{align} x_{t+1} &= Ax_t + Bu_t + w_t\\ y_t &= Cx_t + Du_t + v_t \end{align} where $u$ is the exogenous input. Also, $ w_t \sim N(0, Q)$ and $v_t \sim N(0, R)$. My goal is to estimate the parameters $A, B, C, D, Q$ and $R$ together with the hidden state $x$.

The R package dlm doesn't allow exogenous input. So I thought of first fitting this model \begin{align} x_{t+1} &= Ax_t + \varepsilon_t\\ y_t &= Cx_t + \eta_t \end{align} and then fitting the covariates \begin{align} \varepsilon_t &= Bu_t + w_t\\ \eta_t &= Du_t + v_t \end{align} But I'm afraid this trick might be too simplistic. Is there a theoretical reason why this is right or wrong?

  • $\begingroup$ Hi: if exogenous input is known and so are $B$ and $D$, can you just subtract them from both sides of the two equations, and then you'll have a new state space model without exogenous input ? I could be missing something obvious here. $\endgroup$ – mlofton Aug 16 '18 at 5:59
  • $\begingroup$ Sorry for not being clear. The parameters $A, B, C, D$ as well as the variance $Q$ of $w$ and $R$ of $v$ are all unknown and must be estimated. Only $u$ is known. I plan to use the EM algorithm as presented in this paper which I believe is how dlm is implemented. But the paper and dlm both don't include exogenous inputs. $\endgroup$ – Drumy Aug 16 '18 at 6:09
  • $\begingroup$ Oh Okay. In the more standard kalman filter-state space model framework, A and C are known. You've got a different problem there for sure that I'm not familiar with. Note though that dlm package in R does not solve the problem in the paper you refer to. The dlm package in R assumes A and C are known and it estimates state x_t and the respective covariance matrices using a bayesian framework or harvey's classical structural framework ( maybe both. I forget ). There are other KF packages in R that may deal with the problem that you're considering. Good luck. $\endgroup$ – mlofton Aug 16 '18 at 17:22
  • $\begingroup$ Thanks. Maybe I can write the code from the paper myself, but still I want to know if I can use this trick. $\endgroup$ – Drumy Aug 17 '18 at 8:33
  • $\begingroup$ I've worked with the Kalman filter but not with those matrices unknown so I can't say and hopefully someone else can answer. If not, maybe ask the authors of the paper. $\endgroup$ – mlofton Aug 17 '18 at 21:22

One way to do this is to move the coefficient of the exogenous process into the state, make it constant, and treat $u_t$ as a (known) time-varying coefficient.

As a simple example, assume both the state and the observation are one-dimensional:

\begin{align} x_t &= a x_{t-1} + b u_{t-1} + w_t\\ y_t &= c x_t + d u_{t} + v_t \end{align}

Define the new state vector $z_t=[x_t, b_t, d_t]^T$, and the corresponding state equations:

\begin{align} x_t &= a x_{t-1} + u_{t-1}b_{t-1} + w_t\\ b_t &= b_{t-1}\\ d_t &= d_{t-1} \end{align}

The measurement equation becomes: $$y_t = [c, 0, u_t]z_t + v_t$$

This is then a standard linear state-space model with 3 state variables, and some time-varying coefficients.

This is actually the methodology used by dlm::dlmModReg to define a regression model. dlm does indeed allow for fitting unknown parameters of linear Gaussian state space models (by MLE), and it allows for time-varying parameters as well (you will have to adjust the parameters JGG and JFF to have time-varying transition/observation matrices).

| cite | improve this answer | |
  • $\begingroup$ Thanks! This makes sense. Apart from setting the parameters to time varying, I also have to set them to be partially fixed. I'll see how I can do that. Meanwhile, could you tell me why is my trick wrong? $\endgroup$ – Drumy Aug 20 '18 at 23:15
  • 1
    $\begingroup$ @Drumy Could you expand on your trick? It looks like you first assume $\varepsilon_t$ is mean zero when fitting the first step, and then that its mean is $Bu_t$ in the second. This would bias the estimates of $A$, for example. $\endgroup$ – Chris Haug Aug 21 '18 at 0:41
  • $\begingroup$ Ahh, I see! Thank you @ChrisHaug for clarifying. I had a hunch that the trick was too simplistic and should be wrong but couldn't pin-point it. Now I realize it's the assumptions behind. $\endgroup$ – Drumy Aug 21 '18 at 8:22

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.