The implementation is naive in that it is a direct transcription of the equations of the filter and the smoother that can be found in many textbooks. A square root filter is not considered in order to deal with potential numerical problems that may arise in the original equations.
The package includes a wrapper function that links to functions from the following packages: dlm, dse, FKF, KFAS
and stats. The original interface provided by each package is recommended as they sometimes provide further capabilities or options. Nevertheless, the wrapper function provided in this package is useful for debugging and testing since it allows running different implementations of the filter through a unified interface.
A useful utility of the package is that it computes the analytical derivatives of some of the elements of the filter and the smoother with respect to the parameters of the model. In particular, the necessary elements to compute the analytical derivatives of the time domain log-likelihood function are returned. This is especially useful when it comes to maximizing the likelihood function.
In some models, the Kalman filter and the smoother are expected to converge to a steady state. Some optional parameters can be defined in order to assess at each iteration of the filter whether a steady state has been reached. When the steady state is reached, the values from the last iteration are used in the remaining iterations of the filter and smoother. Thus, the number of matrix operations can be reduced substantially.
Some parts of the code are implemented in the C language where the matrix operations are handled through the GNU Scientific Library.
The package stsm is a useful complement to easily create an object containing the matrices of the state space representation for the structural models defined in that package.