Description Usage Arguments Value Examples
Adjust a regular time series for an assumed linear drift over a known period while maintaining an assumed linear trend over the entire period.
1 | adjust_linear(x, mask)
|
x |
A vector of data with missing values. |
mask |
A logical mask that identifies a subgroup of |
The vector x
with corrected values for the subgroup
specified by mask
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | # no trend, only drift
x = rnorm(100, 10) + 0.1 * (1:100)
newx = adjust_linear(x)
if (interactive()) {
plot(x, type = 'l')
lines(newx, col = 'red')
}
# trend and drift
x = rnorm(100, 10) - 0.05 * (1:100)
mask = seq_along(x) %in% 20:80
x[mask] = x[mask] - 0.1 * cumsum(mask)[mask]
newx = adjust_linear(x, mask)
if (interactive()) {
plot(x, type = 'l')
lines(newx, col = 'red')
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.