| Title: | Exact Observation Weights for the Kalman Filter and Smoother |
|---|---|
| Description: | Computes exact observation weights for the Kalman filter and smoother, following Koopman and Harvey (2003) <www.sciencedirect.com/science/article/pii/S0165188902000611>. The package provides tools for analyzing linear Gaussian state-space models, allowing users to quantify the contribution of individual observations to filtered and smoothed state estimates. These weights can be used for interpretation, decomposition, and diagnostic analysis in time series models, including applications such as dynamic factor models. See the README for examples. |
| Authors: | Tim Ginker [aut, cre, cph] (ORCID: <https://orcid.org/0000-0002-7138-5417>) |
| Maintainer: | Tim Ginker <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.1 |
| Built: | 2026-06-03 08:29:03 UTC |
| Source: | https://github.com/timginker/wex |
A dataset containing 10 monthly economic indicators, covering the period from January 2000 to November 2021. All variables have been log-differenced, when necessary, to achieve stationarity.
indicatorsindicators
A data frame with 263 rows and 11 variables:
Date values (format: YYYY-MM-DD)
Total industrial production in Israel
Trade revenue
Service revenue
Employment (excluding absent workers)
Exports of services
Building starts
Imports of consumer goods
Imports of production inputs
Exports of goods
Job openings
Public data from various sources
Computes the exact observation weights for the Kalman filter and smoother,
following Koopman and Harvey (2003). The implementation in wex
builds on the functionality provided by the FKF and KFAS
packages. These packages rely on different computational approaches:
FKF uses routines from BLAS and LAPACK, whereas KFAS uses
sequential processing, which allows the prediction error variance matrices
to be singular.
wex(a0 = NULL, P0 = NULL, Tt, Zt, HHt, GGt, yt, t, package = "FKF")wex(a0 = NULL, P0 = NULL, Tt, Zt, HHt, GGt, yt, t, package = "FKF")
a0 |
A numeric vector specifying the initial state estimate. Defaults to a vector of zeros. |
P0 |
A numeric matrix specifying the covariance matrix of the initial state. Defaults to a diagonal matrix with large values (e.g., 1e6) on the diagonal. |
Tt |
An array specifying the transition matrix of the state equation (see Details). |
Zt |
An array specifying the observation matrix of the measurement equation (see Details). |
HHt |
An array specifying the covariance matrix of the state disturbances (see Details). |
GGt |
An array specifying the covariance matrix of the observation disturbances (see Details). |
yt |
An |
t |
An integer specifying the time index for which the observation weights are evaluated. |
package |
A character string indicating which backend to use ( |
State space form
where represents the observed data (possibly with NA's),
and is the state vector.
A list with two components:
Wt: An array of filtering weights with dimensions , , where is the state
dimension, is the observation dimension, and is the number of time points.
WtT: An array of smoothing weights with the same dimensions as Wt.
Tim Ginker
Koopman, S. J., and Harvey, A. (2003). Computing observation weights for signal extraction and filtering. Journal of Economic Dynamics and Control, 27(7), 1317-1333.
Helske, J. (2017). KFAS: Exponential family state space models in R. Journal of Statistical Software, 78, 1-39.
# Decompose a local level model (Nile data set) data(Nile) y <- Nile wts <- wex(Tt=matrix(1), Zt=matrix(1), HHt = matrix(1385.066), GGt = matrix(15124.13), yt = t(y), t=50)# Decompose a local level model (Nile data set) data(Nile) y <- Nile wts <- wex(Tt=matrix(1), Zt=matrix(1), HHt = matrix(1385.066), GGt = matrix(15124.13), yt = t(y), t=50)