trend | R Documentation |
The function is used to set up the trend component used in ptrend formulas.
trend(var, tempRE = FALSE, type = "smooth", by = NA, k = -1, fx = FALSE)
var |
A numeric time variable over which a trend or index will be computed. |
tempRE |
If TRUE, this will set up random time effects. The random effects will be constructed by converting the var argument to a factor. Note that this yields a random effect level for each unique value in var. If this is not appropriate, an alternative is to set tempRE to false and manually add temporal random effects in the trend formula (using s(..., bs = "re")). Temporal random effects cannot be used with index estimation. |
type |
The type of trend to be estimated. One of "smooth", "loglinear" or "index". |
by |
Currently ignored. |
k |
The dimension of the basis for the cubic regression spline of smooth trend fits. |
fx |
If true, automatic selection of degrees of freedom are used for smooth trends. |
The function extracts information about the trend component of a formula supplied to ptrend.
It returns a list containing variable names, information, and s
components as strings used in subsequent calls to gam.
A list containing information to set up the trend.
Jonas Knape
## Simulate a data set with 15 sites and 25 years
data = simTrend(15, 25)
## Fit a smooth trend with fixed site effects, but no random time effects,
## and fixed degrees of freedom
trFit = ptrend(count ~ trend(year, tempRE = FALSE, k = 8, fx = FALSE, type = "smooth") +
site, data = data)
plot(trFit)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.