Computes the B-spline basis matrix for a given polynomial spline.
bscpp(
x = NA_real_,
df = NA_integer_,
knots = NA_real_,
degree = 3L,
intercept = 0L,
boundary_knots = NA_real_,
warn_outside = 1L
)
A matrix with dimensions c(length(x), df)
. If
df
is provided, the matrix will have df
columns.
Alternatively, if knots
are supplied, the number of columns
will be length(knots) + degree + intercept
. The matrix
contains attributes that correspond to the arguments
passed to the bscpp
function.
A numeric vector representing the predictor variable.
Degrees of freedom, specifying the number of columns in the
basis matrix. If df
is provided, the function automatically
selects df - degree - intercept
internal knots based on
appropriate quantiles of x
, ignoring any missing values.
A numeric vector specifying the internal breakpoints
that define the spline. If not provided, df
must be specified.
An integer specifying the degree of the piecewise
polynomial. The default value is 3
, which corresponds to
cubic splines.
A logical value indicating whether to include an
intercept in the basis. The default is FALSE
.
A numeric vector of length 2 specifying the
boundary points where the B-spline basis should be anchored.
If not supplied, the default is the range of non-missing values
in x
.
A logical value indicating whether a warning
should be issued if any values of x
fall outside the
specified boundary knots.
Kaifeng Lu, kaifenglu@gmail.com