Learn R Programming

imputeTS (version 1.5)

na.interpolation: Missing Value Imputation by Interpolation

Description

Uses either linear or spline interpolation to replace missing values.

Usage

na.interpolation(x, option = "linear", ...)

Arguments

x
Numeric Vector (vector) or Time Series (ts) object in which missing values shall be replaced
option
Algorithm to be used. Accepts the following input:
  • "linear" - for linear interpolation usingapprox
"spline" - for spline interpolation using spline

Value

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

item

...

link

spline

Details

Missing values get replaced by values of a approx or spline interpolation. Both functions are thereby called with their default parameters (except for parameter rule at approx, which is set to 2) If more flexibility in parameter settings is needed, na.approx / na.spline from the zoo package can be a option.

See Also

na.kalman, na.locf, na.ma, na.mean, na.random, na.replace, na.seadec, na.seasplit

Examples

Run this code
#Prerequisite: Create Time series with missing values
x <- ts(c(2,3,4,5,6,NA,7,8))

#Example 1: Perform linear interpolation
na.interpolation(x)

#Example 2: Perform spline interpolation
na.interpolation(x, option ="spline")

#Example 3: Perform stine interpolation
na.interpolation(x, option ="stine")

Run the code above in your browser using DataLab