View source: R/get_imputations.R
get_imputations | R Documentation |
Function to get imputations from methods compared by kssa
get_imputations(x_ts, methods = "all", seed = 1234)
x_ts |
A ts object with missing data to be imputed |
methods |
A string or string vector indicating the method or methods You can choose between the following:
For further details on these imputation methods please check packages |
seed |
Numeric. Any number |
A list of imputed time series with the selected methods
# 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) # 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.