rcs: Generate restricted cubic spline (rcs) basis matrix

View source: R/rcs.R

rcsR Documentation

Generate restricted cubic spline (rcs) basis matrix

Description

Takes a numeric vector and a sequence of knots to generate restricted cubic splines basis columns based on a truncated power series (as described in section 2.4.5 of the second edition of Regression Modeling Strategies by Frank E. Harrrell, Jr).

Usage

rcs(x, knots = stats::quantile(x, probs = c(0, 0.1, 0.5, 0.9, 1)))

Arguments

x

numeric vector

knots

numeric vector including at least 3 unique knot locations of increasing order, with the outer ones indicating the boundary knots.

Value

matrix of basis columns

Examples

rcs(1:25)

jeroenhoogland/regsurv documentation built on March 20, 2023, 3:37 a.m.