Known Sub-Sequence Algorithm

Implements the Known Sub-Sequence Algorithm , which helps to automatically identify and validate the best method for missing data imputation in a time series. Supports the comparison of multiple state-of-the-art algorithms.


kssa

R-CMD-check Lifecycle: experimental

This package implements the Known Sub-Sequence Algorithm <doi: 10.1016/j.aaf.2021.12.013> which helps to automatically compare, validate and identify the best methods for missing data imputation in time series. It compares the performance of 11 state-of-the-art's imputation methods avaliable from multiple CRAN packages and delivers a best method suited for each particular time series.

Installation

You can install the development version of kssa like so:

library(devtools)
install_github("pipeben/kssa")

Usage

You can run kssa like in the following example that plots the results obtained when applying kssa to the example time series tsAirgapComplete.

# Create 20% random missing data in tsAirgapComplete time series from imputeTS
set.seed(1234)
library("kssa")
library("imputeTS")
airgap_na <- missMethods::delete_MCAR(as.data.frame(tsAirgapComplete), 0.2)

# Convert co2_na to time series object
airgap_na_ts <- ts(airgap_na, start = c(1959, 1), end = c(1997, 12), frequency = 12)

# Apply the kssa algorithm with 5 segments,
# 10 iterations, 20% of missing data, and
# compare among all available methods in the package.
# Remember that percentmd must match with
# the real percentage of missing data in the
# input co2_na_ts time series

results_kssa <- kssa(airgap_na_ts,
  start_methods = "all",
  actual_methods = "all",
  segments = 5,
  iterations = 10,
  percentmd = 0.2
)

kssa_plot(results_kssa, type = "complete", metric = "rmse")

Example final plot

Conclusion: Since kssa_plot is ordered from lower to higher error (left to right), method 'linear_i' is the best to impute missing data in airgap_na_ts. Notice that method 'locf' is the worst

To obtain imputations with the best method, or any method of preference use function get_imputations().

Reference

You can cite kssa the following:

Ivan-Felipe Benavides, Steffen Moritz, Brayan-David Aroca-Gonzalez, Jhoana Romero, Marlon Santacruz and John-Josephraj Selvaraj (2025). kssa: Known Sub-Sequence Algorithm. R package version 0.0.2. https://github.com/pipeben/kssa

License

GPL-3

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("kssa")

0.0.5 by Iván Felipe Benavides, a year ago


https://github.com/steffenmoritz/kssa, https://steffenmoritz.github.io/kssa/


Report a bug at https://github.com/steffenmoritz/kssa/issues


Browse source code at https://github.com/cran/kssa


Authors: Iván Felipe Benavides [aut, cre, cph] (ORCID: , Steffen Moritz [aut] , Brayan-David Aroca-Gonzalez [aut] (ORCID: , Jhoana Romero [aut] , Marlon Santacruz [aut] , John-Josephraj Selvaraj [aut] (ORCID:


Documentation:   PDF Manual  


AGPL (>= 3) license


Imports magrittr, ggplot2, rlang, methods, forecast, imputeTS, stats, zoo, Metrics, dplyr, missMethods

Suggests covr, testthat


See at CRAN