adjust_known: Adjust for Known Drift

Description Usage Arguments Details Value Examples

View source: R/adjust.r

Description

Adjust a regular time series for a known drift over a known period. The drift is assumed to increase linearly in time from 0 at the beginning of the time series to the specified drift value at the end of the time series.

Usage

1
adjust_known(x, mask, drift)

Arguments

x

A vector of data with missing values.

mask

A logical mask that identifies a subgroup of x to correct for drift. Values outside the subgroup are ignored. If no mask is specified, no overall trend is assumed.

drift

The drift value to correct for. The drift is assumed to occur at the last element of the masked vector x and linearly shrink to zero at the first element of the masked vector x.

Details

This function assumes that mask specifies a contiguous block, and that the time series values are equally spaced. No consideration is given to noncontiguous masks or unequal-interval time series.

Value

The vector x with corrected values for the subgroup specified by mask.

Examples

1
2
3
4
5
6
x = rnorm(100, 10, 0.1) + 0.025 * (0:99)
newx = adjust_known(x, drift = 99*0.025)
if (interactive()) {
  plot(x, type = 'l')
  lines(newx, col = 'red')
}

mkoohafkan/wqptools documentation built on May 2, 2021, 8:12 p.m.