Methods for the generic function knots
from the stats package
to obtain internal or boundary knots from the objects produced by this
package.
Usage
# S3 method for splines2
knots(Fn, type = c("internal", "boundary"), ...)
Arguments
- Fn
An
splines2
object produced by this package.- type
A character vector of length one indicating the type of knots to return. The available choices are
"internal"
for internal knots and"Boundary"
for boundary knots.- ...
Optional arguments that are not used now.
Examples
library(splines2)
set.seed(123)
x <- rnorm(100)
## B-spline basis
bsMat <- bSpline(x, df = 8, degree = 3)
## extract internal knots placed based on the quantile of x
(internal_knots <- knots(bsMat))
#> [1] -0.69135780 -0.32593159 0.06175631 0.43518149 0.99962119
## extract boundary knots placed based on the range of x
boundary_knots <- knots(bsMat, type = "boundary")
all.equal(boundary_knots, range(x))
#> [1] TRUE