trends | R Documentation |
Generates a basis matrix for piecewise linear modeling of trends.
trends(x, breaks, boundary.breaks = c(FALSE, FALSE), steps)
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
|
steps |
a vector indicating any step trends. |
A matrix of dimension length of x by number of linear trend and step trends. The breaks are included as an attribute.
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.
floor
, ceiling
, curvi
# 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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.