interpNA: Interpolate missing values in a Time Indexed Series

Description Usage Arguments Details Value See Also

View source: R/interpNA.R

Description

Calls approxfun or splinefun to interpolate missing values in a tis object.

Usage

1
interpNA(x, method = "constant", useTimes = F, offset = 1, rule = 2, f = 0, ...)

Arguments

x

a tis time series

method

One of c("constant", "linear", "fmm", "natural", "periodic"). Methods "constant" and "linear" call approxfun; the others call splinefun.

useTimes

if TRUE, use time(x, offset) (the decimal times of x) as the 'x' part of the (x, y) pairs used for interpolation. If FALSE (the default), use ti(x) (the integer time indices of x) as the 'x' part of the (x, y) pairs.

offset

if useTimes is TRUE, a number in the range [0,1] telling where in the periods represented by ti(x) to get the points for the 'x' parts of the (x, y) pairs. See the help for jul for a more detailed explanation of this parameter.

rule

For methods "constant" and "linear": an integer describing how interpolation is to take place outside the interval [min(x), max(x)]. If rule is 1 then NAs are returned for such points and if it is 2, the value at the closest data extreme is used.

f

For method="constant" a number between 0 and 1 inclusive, indicating a compromise between left- and right-continuous step functions. If y0 and y1 are the values to the left and right of the point then the value is y0*(1-f)+y1*f so that f=0 is right-continuous and f=1 is left-continuous.

...

Other arguments passed along to approxfun for methods "constant" and "linear".

Details

Depending on the method specified, a call to either approxfun or splinefun is constructed with appropriate arguments and executed for each column of x. In the call to approxfun or splinefun, the time indices ti(x) (or the decimal times returned by time(x, offset), if useTimes is TRUE) serve as the 'x' argument and the column values as the 'y' argument.

Value

A tis object like x with NA values filled in by interpolated values.

See Also

approxfun, splinefun, ti


tis documentation built on Sept. 29, 2021, 1:06 a.m.