predict.bs
Evaluate a Spline Basis
Description
Evaluate value of B-Spline Basis or Natural Cubic Spline at New Values of newx.
Usage
## S3 method for class 'bs':
predict(object, newx, ..., derivs)
## S3 method for class 'ns':
predict(object, newx, ..., derivs)
Arguments
object |
any object inherits from class ns or bs.
|
newx |
a numeric vector specifying the values at which to evaluate the basis matrix.
|
... |
additional arguments to be passed to or from future functions.
|
Details
In these methods, the attributes knots, Boundary.knots,
intercept, and, for predict.bs, degree of object
along with x=newx are used
in a call to bs or ns to evaluate the spline
basis functions encoded in object at points of newx.
Value
Returns a matrix of of the same class as it input object
containing the spline basis functions in it evaluated at the points
in object.
See Also
Examples
nso <- ns(1:6)
bso <- bs(11:20, degree=5)
predict(nso, newx = seq(0, 7, by=1/4))
predict(bso, 14:16) # same as bso[4:6]