bs
B-Spline Basis for Polynomial Splines

Description

Generates the B-spline basis matrix for a polynomial spline.

Usage

bs(x, df = NULL, knots = NULL, degree = 3, intercept = FALSE,
    Boundary.knots = range(x))

Arguments

x a numeric vector specifying the values to evaluate the basis matrix. NAs are accepted.
df an integer specifying the degrees of freedom. If df is specified and knots is not specified, then the function chooses df - degree or df - degree -1(if there is an intercept) knots from quantiles of x(NAs in x will be ignored)
knots a numeric vector specifying the knots position to define a spline. The default is numeric(0) if df is not specified, otherwise the quantiles of x. See also df.
degree a positive integer specifying the degree of the polynomial spline. The default is 3 (for cubic splines).
intercept a logical value. If TRUE, an intercept is contained in the basis matrix. The default is FALSE.
Boundary.knots a length-2 numeric vector specifying the boundary of knots. The default is the range of x. If it is specified, the x values could be outside of it.

Details

The bs function uses the function splineDesign to generates a basis matrix for a polynomial spline with the specified knots and degree, evaluated at the values of x.
Value
The matrix has the class name "bs","basis", "matrix" and the attributes "knots", "degree", "Boundary.knots" and "intercept" containing the arguments for the bs function.
The row names of the matrix are copied from the names of x, and the column names are the string representation of 1:ncol(matrix).
Differences between Spotfire Enterprise Runtime for R and Open-source R
When the number of non-missing values in x is less than 2, Spotfire Enterprise Runtime for R and Open-source R currently give different results, neither of which is very useful.
See Also
splineDesign, ns
Examples
bs(1:10, df=4)
lm(ozone ~ bs(wind, df=4), data=Sdatasets::air)
Package splines version 6.1.2-7
Package Index