Learn R Programming

fame (version 1.13)

interpNA: Interpolate missing values in a Time Indexed Series

Description

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

Usage

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
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
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
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
...
Other arguments passed along to approxfun for methods "constant" and "linear".

Value

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

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.

See Also

approxfun, splinefun, ti