# NOT RUN {
# Example 1: Get imputed values for airgap_na_ts with the methods of
library("imputeTS")
library("kssa")
# Create 20% random missing data in tsAirgapComplete time series from imputeTS
airgap_na <- missMethods::delete_MCAR(as.data.frame(tsAirgapComplete), 0.2)
# Convert to time series object
airgap_na_ts <- ts(airgap_na, start = c(1959, 1), end = c(1997, 12), frequency = 12)
my_imputations <- get_imputations(airgap_na_ts, methods = "all")
# my_imputations contains the imputed time series with all methods.
# Access it and choose the one from the best method for your purposes
my_imputations$seadec
plot.ts(my_imputations$seadec)
# }
# NOT RUN {
# Example 2: Get imputed values for airgap_na_ts using only a subset of algorithms
library("imputeTS")
library("kssa")
# Create 20% random missing data in tsAirgapComplete time series from imputeTS
airgap_na <- missMethods::delete_MCAR(as.data.frame(tsAirgapComplete), 0.2)
# Convert to time series object
airgap_na_ts <- ts(airgap_na, start = c(1959, 1), end = c(1997, 12), frequency = 12)
my_imputations <- get_imputations(airgap_na_ts, methods = c("linear_i", "locf"))
# my_imputations contains the imputed time series with all applied
# methods (locf and linear interpolation).
# Access it and choose the one from the best method for your purposes
my_imputations$locf
plot.ts(my_imputations$locf)
# }
Run the code above in your browser using DataLab