Generate a Basis for Polynomial Splines

DESCRIPTION:
Generate a basis matrix for polynomial splines.

USAGE:
bs(x, df, knots, degree=3, intercept=FALSE)

REQUIRED ARGUMENTS:
x:
the predictor variable.

OPTIONAL ARGUMENTS:
df:
degrees of freedom; one can specify df rather than knots; bs then chooses df-degree-1 knots at suitable quantiles of x.
knots:
the internal breakpoints that define the spline; the range of the data provide the boundary knots. The default is NULL, which results in a basis for ordinary polynomial regression. Typical values are the mean or median for one knot, quantiles for more knots.
degree:
degree of the piecewise polynomial---default is 3 for cubic splines.
intercept:
if TRUE, an intercept is included in the basis; default is FALSE.

VALUE:
a matrix of dimension length(x) * df, where either df was supplied or if knots were supplied, df = length(knots) + 3 + intercept.

DETAILS:
The bs function is based on the function spline.des. It generates a basis matrix for representing the family of piecewise polynomials with the specified interior knots and degree, evaluated at the values of x. A primary use is in modeling formulas to directly specify a piecewise polynomial term in a model.

REFERENCES:
de Boor, C. (1978). A Practical Guide to Splines. Berlin: Springer Verlag.

Cheney, W., Kincaid, D. (1985). Numerical Mathematics and Computing, Second edition. New York: Brooks/Cole Publishing Co.


SEE ALSO:
ns , poly , lo , s , smooth.spline .

EXAMPLES:
lm(y ~ bs(age, 4) + bs(income, 4)) # an additive model