Learn R Programming

vows (version 0.5)

vows-mgcv: Utility functions related to the mgcv package

Description

These internal functions are used by semipar.mix.mp (but can also be used more generally) to customize the implementation of B-spline smoothing by gam. Specifically, a B-spline smooth with equispaced knots can be incorporated in a call to gam using a term of the form s(x,bs="be"), whereas knots at equally spaced quantiles of the data can be specified by s(x,bs="bq").

Usage

"smooth.construct"(object, data, knots)
"smooth.construct"(object, data, knots)
"Predict.matrix"(object, data)

Arguments

object
a gam smooth specification object generated by a term such as s(x,bs="be") or s(x,bs="bq").
data
For smooth.construct.be.smooth.spec and smooth.construct.bq.smooth.spec, a list containing just the data (including any by variable) required by the given term, with names corresponding to object$term (and object$by). The by variable is the last element. For Predict.matrix.bspline.smooth, a data frame containing the values of the (named) covariates at which the smooth term is to be evaluated. Exact requirements are as for smooth.construct and smooth.construct2.
knots
a list containing any knots supplied for basis setup, in the same order and with the same names as data. If NULL, a default set of knots is used.

Value

Either smooth.construct.be.smooth.spec or smooth.construct.bq.smooth.spec produces an object of class "bspline.smooth"; see smooth.construct for the elements that this object will contain. Predict.matrix.bspline.smooth produces a matrix mapping the coefficients for the smooth term to its values at the supplied data values.

Details

These functions are not normally called directly. For further details, please see smooth.construct.ps.smooth.spec and Predict.matrix.cr.smooth.

Examples

Run this code

x. = rnorm(20)
smoo.be <- smooth.construct.be.smooth.spec(s(x), data.frame(x = x.), NULL)
smoo.bq <- smooth.construct.bq.smooth.spec(s(x), data.frame(x = x.), NULL)
Predict.matrix.bspline.smooth(smoo.bq, data.frame(x = seq(min(x.),max(x.),,100)))

Run the code above in your browser using DataLab