Learn R Programming

imputeTS (version 1.5)

na.kalman: Missing Value Imputation by Kalman Smoothing and State Space Models

Description

Uses Kalman Smoothing on structural time series models (or on the state space representation of an arima model) for imputation.

Usage

na.kalman(x, model = "StructTS", smooth = T, nit = -1, ...)

Arguments

x
Numeric Vector (vector) or Time Series (ts) object in which missing values shall be replaced
model
Model to be used. With this parameter the State Space Model (on which KalmanSmooth is performed) can be choosen. Accepts the following input:
  • "auto.arima" - For using the state space representation of arima model (using

Value

  • Vector (vector) or Time Series (ts) object (dependent on given input at parameter x)

item

  • smooth
  • nit
  • ...

Details

The KalmanSmoother used in this function is KalmanSmooth. It operates either on a Basic Structural Model obtained by StructTS or the state space representation of a ARMA model obtained by auto.arima. For an detailed explanation of Kalman Filtering and Space Space Models the following literature is a good starting point:
  • G. Welch, G. Bishop, An Introduction to the Kalman Filter. SIGGRAPH 2001 Course 8, 1995
Harvey, Andrew C. Forecasting, structural time series models and the Kalman filter. Cambridge university press, 1990 Grewal, Mohinder S. Kalman filtering. Springer Berlin Heidelberg, 2011

See Also

na.interpolation, na.locf, na.ma, na.mean, na.random, na.replace, na.seadec, na.seasplit

Examples

Run this code
#Prerequisite: Load a time series with missing values
x <- tsAirgap

#Example 1: Perform imputation with KalmanSmoother and state space representation of arima model
na.kalman(x)

#Example 2: Perform imputation with KalmanRun and state space representation of arima model
na.kalman(x, smooth = FALSE)

#Example 3: Perform imputation with KalmanSmooth and StructTS model
na.kalman(x, model ="StructTS", smooth = TRUE) 

#Example 4: Perform imputation with KalmanSmooth and StructTS model with additional parameters 
na.kalman(x, model ="StructTS", smooth = TRUE, type ="trend") 

#Example 5:  Perform imputation with KalmanSmooth and user created model
usermodel <- arima(x,order = c(1,0,1))$model
na.kalman(x,model = usermodel)

Run the code above in your browser using DataLab