[R] state-space models and kalman filter

Paul Gilbert pgilbert at bank-banque-canada.ca
Thu Nov 9 16:28:11 CET 2000

>Does anyone know if one can easily estimate state-space models
>using ML and the kalman filter using R?  I would be especially
>interested in a relatively flexible function that would allow for
>estimation of hyperparameters, or could be made to do so.

My DSE library is on CRAN and a users guide is available at
<http://www.bank-banque-canada.ca/pgilbert>.  It handles multivariate ARMA and
state-space models. Both the Kalman filter  and the smoothed state estimates can
be estimated by the state-space models.

The ML estimation is (I believe) superficially broken at present but I hope to
get a chance to fix it in a few weeks. I don't really recommend ML estimation of
state-space models (at least not multivariate ones) because of know problems
with convergence. This appears to be related to parameter effects cuvature. You
will generally have much better  luck doing ML estimation with the equivalent
ARMA representation and then converting back to state-space form once you have
convergence (if you really want a state-space model). The DSE library has
methods for converting between representations.

EM estimation would be relatively straight forward to implement but, after
hearing Stoffer at a 1993 conference say he had switched back to ML because of
poor performance of EM (for time series model estimation), I have been in no
rush to do that. In any case, the convergence problems related to curvature
would apply equally for EM estimation.

With respect to hyperparameters, it depends on how much you care about the
structure of the model. If you are happy with  "black box" models then I would
recommend a procedure I called "brute force technique" in  a 1995 paper
"Combining VAR Estimation and State Space Model Reduction for Simple Good
Predictions" J. of Forecasting: Special Issue on VAR Modelling. 14:229-250. It
is implemented in bft() in the DSE library. The technique results in a linear
time-invariant model by a combination of VAR estimation and balanced state-space
reduction using a technique of S. Mittnik. (BTW another reduction technique
proposed by Aoki does not work.) Even though it uses VAR estimation the
resulting state-space model may have only an ARMA equivalent (not a VAR
equivalent) because the reduction attempts to find a parsimonious
representation. I have studied lots of estimation techniques for multivariate
time series models and bft is still my perferred starting point. You can do
better, but you can do a lot worse.

In addition to linear time-invariant ARMA and state-space models the DSE library
implements many tools for doing multivariate time series modeling. In the S/R
code I have not implemented time varying models (as in your first post) but
there are many tools in the library that would help do that. There is, however,
some overhead and I would not necessarily recommend it if you are only
interested in univariate models.

Paul Gilbert

r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch

More information about the R-help mailing list