Learn R Programming

imputeTS (version 3.3)

na.ma: Deprecated use na_ma instead.

Description

na.ma is replaced by na_ma. The functionality stays the same. The new name better fits modern R code style guidelines (which prefer _ over . in function names).

Usage

na.ma(x, k = 4, weighting = "exponential", maxgap = Inf, ...)

Arguments

x

Numeric Vector (vector) or Time Series (ts) object in which missing values shall be replaced

k

integer width of the moving average window. Expands to both sides of the center element e.g. k=2 means 4 observations (2 left, 2 right) are taken into account. If all observations in the current window are NA, the window size is automatically increased until there are at least 2 non-NA values present.

weighting

Weighting to be used. Accepts the following input:

  • "simple" - Simple Moving Average (SMA)

  • "linear" - Linear Weighted Moving Average (LWMA)

  • "exponential" - Exponential Weighted Moving Average (EWMA) (default choice)

maxgap

Maximum number of successive NAs to still perform imputation on. Default setting is to replace all NAs without restrictions. With this option set, consecutive NAs runs, that are longer than 'maxgap' will be left NA. This option mostly makes sense if you want to treat long runs of NA afterwards separately.