Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

crs

Bases for cubic regression splines (equivalent to "cr" in mgcv)


Description

Builds the design matrix and the penalty matrix for cubic regression splines.

Usage

crs(x, knots = NULL, df = 10, intercept = TRUE)

Arguments

x

Numeric vector

knots

Numeric vectors that specifies the knots of the splines (including boundaries); default is NULL

df

numeric value that indicates the number of knots desired (or degrees of freedom) if knots=NULL; default is 10

intercept

if FALSE, the intercept is excluded from the basis; default is TRUE

Details

See package mgcv and section 4.1.2 of Wood (2006) for more details about this basis

Value

List of three elements

bs

design matrix

pen

penalty matrix

knots

vector of knots (specified or calculated from df)

References

Wood, S. N. (2006), Generalized additive models: an introduction with R. London: Chapman & Hall/CRC.

Examples

x <- seq(1,10,length=100)
# natural cubic spline with 3 knots
crs(x,knots=c(1,5,10))

survPen

Multidimensional Penalized Splines for Survival and Net Survival Models

v1.5.1
GPL-3 | file LICENSE
Authors
Mathieu Fauvernier [aut, cre], Laurent Roche [aut], Laurent Remontet [aut], Zoe Uhry [ctb], Nadine Bossard [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.