trends: Basis for Piecewise Linear Trends

View source: R/trends.R

trendsR Documentation

Basis for Piecewise Linear Trends

Description

Generates a basis matrix for piecewise linear modeling of trends.

Usage

trends(x, breaks, boundary.breaks = c(FALSE, FALSE), steps)

Arguments

x

a vector of dates/times, assumed to be in dectime format. Missing values are permitted and result in corresponding missing values in the output.

breaks

a vector of breakpoints in the linear trends.

boundary.breaks

a logical vector of length 2, indicating whether the breaks include the range of the data. If the first is TRUE, then the first break denotes the beginning of a trend. If the last is TRUE, then the last break denotes the end of a trend. Otherwise, the trends begin at the floor of the first value of x and end at the ceiling of the last value of x.

steps

a vector indicating any step trends.

Value

A matrix of dimension length of x by number of linear trend and step trends. The breaks are included as an attribute.

Note

Each trend is 0 prior to the break, and then increases at the rate of 1 per unit and maintain that maximum value after the break. The regression coefficient then reprents the trend as a rate. A step trend is 0 before the step and 1 after it.

See Also

floor, ceiling, curvi

Examples

# model two piecewise linear trends from 2000 to 2004, with a break at 2001 and 2003
trends(2000 + seq(0,20)/5, breaks=c(2001, 2003))

USGS-R/smwrStats documentation built on Oct. 11, 2022, 6:15 a.m.