MyNixOS website logo
Description
Time Series Missing Value Imputation
Imputation (replacement) of missing values in univariate time series. Offers several imputation functions and missing data plots. Available imputation algorithms include: 'Mean', 'LOCF', 'Interpolation', 'Moving Average', 'Seasonal Decomposition', 'Kalman Smoothing on Structural Time Series models', 'Kalman Smoothing on ARIMA models'. Published in Moritz and Bartz-Beielstein (2017) <doi:10.32614/RJ-2017-009>.

Project Status: Active The project has reached a stable, usable state and is being actively developed. R-CMD-check Codecov test coverage CRAN Version CRAN Release CRAN Downloads

imputeTS: Time Series Missing Value Imputation imputeTS Logo

The imputeTS package specializes on (univariate) time series imputation. It offers several different imputation algorithm implementations. Beyond the imputation algorithms the package also provides plotting and printing functions of time series missing data statistics. Additionally three time series datasets for imputation experiments are included.

Installation

The imputeTS package can be found on CRAN. For installation execute in R:

 install.packages("imputeTS")

If you want to install the latest version from GitHub (can be unstable) run:

library(devtools)
install_github("SteffenMoritz/imputeTS")

Usage

  • Imputation

    To impute (fill all missing values) in a time series x, run the following command:

     na_interpolation(x)
    

    Output is the time series x with all NA's replaced by reasonable values.

    This is just one example for an imputation algorithm. In this case interpolation was the algorithm of choice for calculating the NA replacements. There are several other algorithms (see also under caption "Imputation Algorithms"). All imputation functions are named alike starting with na_ followed by a algorithm label e.g. na_mean, na_kalman, ...

  • Plotting

    To plot missing data statistics for a time series x, run the following command:

     ggplot_na_distribution(x)
    

    Example ggplot_na_distribution plot

This is also just one example for a plot. Overall there are four different types of missing data plots. (see also under caption "Missing Data Plots").

  • Printing

    To print statistics about the missing data in a time series x, run the following command:

     statsNA(x)
    
  • Datasets

    To load the 'heating' time series (with missing values) into a variable y and the 'heating' time series (without missing values) into a variable z, run:

     y <- tsHeating
     z <- tsHeatingComplete
    

    There are three datasets provided with the package, the 'tsHeating', the 'tsAirgap' and the 'tsNH4' time series. (see also under caption "Datasets").

Imputation Algorithms

Here is a table with available algorithms to choose from:

FunctionDescription
na_interpolationMissing Value Imputation by Interpolation
na_kalmanMissing Value Imputation by Kalman Smoothing
na_locfMissing Value Imputation by Last Observation Carried Forward
na_maMissing Value Imputation by Weighted Moving Average
na_meanMissing Value Imputation by Mean Value
na_randomMissing Value Imputation by Random Sample
na_removeRemove Missing Values
na_replaceReplace Missing Values by a Defined Value
na_seadecSeasonally Decomposed Missing Value Imputation
na_seasplitSeasonally Splitted Missing Value Imputation

This is a rather broad overview. The functions itself mostly offer more than just one algorithm. For example na_interpolation can be set to linear or spline interpolation.

More detailed information about the algorithms and their options can be found in the imputeTS reference manual.

Missing Data Plots

Here is a table with available plots to choose from:

FunctionDescription
ggplot_na_distributionVisualize Distribution of Missing Values
ggplot_na_distribution2Missing Values Summarized in Intervals
ggplot_na_gapsizeVisualize Distribution of NA Gapsizes
ggplot_na_imputationsVisualize Imputed Values

More detailed information about the plots can be found in the imputeTS reference manual.

Datasets

There are three datasets (each in two versions) available:

DatasetDescription
tsAirgapTime series of monthly airline passengers (with NAs)
tsAirgapCompleteTime series of monthly airline passengers (complete)
tsHeatingTime series of a heating systems supply temperature (with NAs)
tsHeatingCompleteTime series of a heating systems supply temperature (complete)
tsNH4Time series of NH4 concentration in a wastewater system (with NAs)
tsNH4CompleteTime series of NH4 concentration in a wastewater system (complete)

The tsAirgap, tsHeating and tsNH4 time series are with NAs. Their complete versions are without NAs. Except the missing values their versions are identical. The NAs for the time series were artifically inserted by simulating the missing data pattern observed in similar non-complete time series from the same domain. Having a complete and incomplete version of the same dataset is useful for conducting experiments of imputation functions.

More detailed information about the datasets can be found in the imputeTS reference manual.

Reference

You can cite imputeTS the following:

Moritz, Steffen, and Bartz-Beielstein, Thomas. "imputeTS: Time Series Missing Value Imputation in R." R Journal 9.1 (2017). doi: 10.32614/RJ-2017-009.

Need Help?

If you have general programming problems or need help using the package please ask your question on StackOverflow. By doing so all users will be able to benefit in the future from your question.

Don't forget to mark your question with the imputets tag on StackOverflow to get me notified

Support

If you found a bug or have suggestions, feel free to get in contact via steffen.moritz10 at gmail.com.

All feedback is welcome

Version

3.3

License

GPL-3

Metadata

Version

3.3

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows