gsl.bs
generates the Bspline basis matrix for a
polynomial spline and (optionally) the Bspline basis matrix
derivative of a specified order with respect to each predictor
1 2 3 4 5 6 7 8 9 10 11 
x 
the predictor variable. Missing values are not allowed 
degree 
degree of the piecewise polynomial  default is ‘3’ (cubic spline) 
nbreak 
number of breaks in each interval  default is ‘2’ 
deriv 
the order of the derivative to be computeddefault if

x.min 
the lower bound on which to construct the spline 
defaults to 
x.max 
the upper bound on which to construct the spline 
defaults to 
intercept 
if ‘TRUE’, an intercept is included in the basis; default is ‘FALSE’ 
knots 
a vector (default 
... 
optional arguments 
Typical usages are (see below for a list of options and also the examples at the end of this help file)
1 2  B < gsl.bs(x,degree=10)

gsl.bs
returns a gsl.bs
object. A matrix of dimension
‘c(length(x), degree+nbreak1)’.
A primary use is in modelling formulas to directly specify a piecewise polynomial term in a model. See http://www.gnu.org/software/gsl/ for further details.
Jeffrey S. Racine racinej@mcmaster.ca
Li, Q. and J.S. Racine (2007), Nonparametric Econometrics: Theory and Practice, Princeton University Press.
Ma, S. and J.S. Racine and L. Yang (under revision), “Spline Regression in the Presence of Categorical Predictors,” Journal of Applied Econometrics.
Ma, S. and J.S. Racine (2013), “Additive Regression Splines with Irrelevant Categorical and Continuous Regressors,” Statistica Sinica, Volume 23, 515541.
1 2 3 4 5 6 7 8 9 10 11 12  ## Plot the spline bases and their first order derivatives
x < seq(0,1,length=100)
matplot(x,gsl.bs(x,degree=5),type="l")
matplot(x,gsl.bs(x,degree=5,deriv=1),type="l")
## Regression example
n < 1000
x < sort(runif(n))
y < cos(2*pi*x) + rnorm(n,sd=.25)
B < gsl.bs(x,degree=5,intercept=FALSE)
plot(x,y,cex=.5,col="grey")
lines(x,fitted(lm(y~B)))

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.
Please suggest features or report bugs with the GitHub issue tracker.
All documentation is copyright its authors; we didn't write any of that.