Last chance! 50% off unlimited learning
Sale ends in
Generate the B-spline basis matrix for a cubic spline with the first and last columns dropped.
b_spline(x, df=NULL, knots=NULL, Boundary.knots = range(x))
the predictor variable. Missing values are allowed.
degrees of freedom; one can specify df
rather than knots
; the function chooses df-2
inner knots at suitable quantile of x
(which will ignore missing values). The default, NULL
, corresponds to one inner knots, i.e. df=3
.
the internal breakpoints that define the spline. The default is NULL
, which corresponds the median for one knot, quantiles for more knots.
boundary points at which to anchor the B-spline basis (default the range of the non-NA data).
Hastie, T. J. (1992) Generalized additive models. Chapter 7 of Statistical Models in S eds J. M. Chambers and T. J. Hastie, Wadsworth & Brooks/Cole.
# NOT RUN {
require(stats)
basis <- b_spline(women$height, df = 5)
newX <- seq(58, 72, length.out = 51)
# evaluate the basis at the new data
predict(basis, newX)
# }
Run the code above in your browser using DataLab