| Type: | Package |
| Title: | Exact Observation Weights for the Kalman Filter and Smoother |
| Version: | 0.1.1 |
| Maintainer: | Tim Ginker <timginker@gmail.com> |
| 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. |
| License: | MIT + file LICENSE |
| Encoding: | UTF-8 |
| Imports: | FKF, KFAS |
| LazyData: | true |
| URL: | https://github.com/timginker/wex |
| BugReports: | https://github.com/timginker/wex/issues |
| RoxygenNote: | 7.3.3 |
| NeedsCompilation: | no |
| Packaged: | 2026-04-03 17:51:51 UTC; timgi |
| Author: | Tim Ginker |
| Depends: | R (≥ 3.5.0) |
| Repository: | CRAN |
| Date/Publication: | 2026-04-04 05:20:02 UTC |
Sample Data with 10 Economic Indicators
Description
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.
Usage
indicators
Format
A data frame with 263 rows and 11 variables:
- date
Date values (format: YYYY-MM-DD)
- total_production
Total industrial production in Israel
- retail_revenue
Trade revenue
- services_revenue
Service revenue
- employment
Employment (excluding absent workers)
- export_services
Exports of services
- building_starts
Building starts
- import_consumer_goods
Imports of consumer goods
- import_production_inputs
Imports of production inputs
- export_goods
Exports of goods
- job_openings
Job openings
Source
Public data from various sources
Exact observation weights for the Kalman filter and smoother
Description
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.
Usage
wex(a0 = NULL, P0 = NULL, Tt, Zt, HHt, GGt, yt, t, package = "FKF")
Arguments
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 ( |
Details
State space form
\alpha_{t+1} = T_t \alpha_t + H_t \eta_t,
y_t = Z_t \alpha_t + G_t \epsilon_t,
where y_t represents the observed data (possibly with NA's),
and \alpha_t is the state vector.
Value
A list with two components:
-
Wt: An array of filtering weights with dimensionsm \times d \times n, , wheremis the state dimension,dis the observation dimension, andnis the number of time points. -
WtT: An array of smoothing weights with the same dimensions asWt.
Author(s)
Tim Ginker
References
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.
Examples
# 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)