imputeTS (version 3.0)

na_seadec: Seasonally Decomposed Missing Value Imputation

Description

Removes the seasonal component from the time series, performs imputation on the deseasonalized series and afterwards adds the seasonal component again.

Usage

na_seadec(x, algorithm = "interpolation", find_frequency = FALSE,
  maxgap = Inf, ...)

Arguments

x

Numeric Vector (vector) or Time Series (ts) object in which missing values shall be replaced

algorithm

Algorithm to be used after decomposition. Accepts the following input:

  • "interpolation" - Imputation by Interpolation

  • "locf" - Imputation by Last Observation Carried Forward

  • "mean" - Imputation by Mean Value

  • "random" - Imputation by Random Sample

  • "kalman" - Imputation by Kalman Smoothing and State Space Models

  • "ma" - Imputation by Weighted Moving Average

find_frequency

If TRUE the algorithm will try to estimate the frequency of the time-series automatically.

maxgap

Maximum number of successive NAs to still perform imputation on. Default setting is to replace all NAs without restrictions. With this option set, consecutive NAs runs, that are longer than 'maxgap' will be left NA. This option mostly makes sense if you want to treat long runs of NA afterwards separately.

...

Additional parameters for these algorithms that can be passed through. Look at na_interpolation, na_locf, na_random, na_mean for parameter options.

Value

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

See Also

na_interpolation, na_kalman, na_locf, na_ma, na_mean, na_random, na_replace, na_seasplit

Examples

Run this code
# NOT RUN {
# Example 1: Perform seasonal imputation using algorithm = "interpolation"
na_seadec(tsAirgap, algorithm = "interpolation")

# Example 2: Perform seasonal imputation using algorithm = "mean"
na_seadec(tsAirgap, algorithm = "mean")

# Example 3: Same as example 1, just written with pipe operator
tsAirgap %>% na_seadec(algorithm = "interpolation")
# }

Run the code above in your browser using DataLab