Regression Spline Functions and Classes

Constructs B-splines and its integral, monotone splines (M-splines) and its integral (I-splines), convex splines (C-splines), and their derivatives of given order. Piecewise constant basis is allowed for B-splines and M-splines. See De Boor (1978) , Ramsay (1988) , and Meyer (2008) for more information.

The R package splines2 is a supplementary package on splines providing functions constructing B-splines, integral of B-splines, monotone splines (M-splines) and its integral (I-splines), convex splines (C-splines), and their derivatives of given order. Piecewise constant basis is allowed for B-spline and M-spline basis.

Installation of CRAN Version

CRAN_Status_Badge Build Status codecov Downloads from the RStudio CRAN mirror

You can install the released version from CRAN.



Build Status codecov

The latest version of package is under development at GitHub in branch dev. If it is able to pass the building check by Travis CI, you may consider installing it with the help of remotes by

if (! require(remotes)) install.packages("remotes")
remotes::install_github("wenjie2wang/splines2", ref = "dev")

Getting Started

The package vignette provides a quick demonstration for the basic usage of the main functions.


The R package splines2 is free software: You can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version (at your option). See the GNU General Public License for details.

The R package splines2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


splines2 0.2.8

Bug fixes

  • Fixed inconsistency of argument df for piece-wise constant bases when knots = NULL.

splines2 0.2.7

Minor changes

  • Updated tests for R development version.

splines2 0.2.6

Minor changes

  • Added checks for any internal knot incorrectly placed outside of the boundary knots and added warnings for users' reference.

splines2 0.2.5

Minor changes

  • Added more tests and increased code coverage.

Bug fixes

  • Fixed evaluation of derivatives of M-splines for a single value. Thanks Ina Jazic for reporting the bug and providing possible fix.

  • Fixed deriv.cSpline method for derivatives of order greater than two when scale = TRUE.

splines2 0.2.4

New features

  • Added function dbs generating derivative of given order of B-splines. It is a similar function with splines::splineDesign. However, it provides a more user-friendly interface and more consistent handling on NA's.

  • Added deriv methods for derivatives of given order of any existing splines2 object that can be generated currently.

Major changes

  • Added argument derivs to function mSpline and iSpline for derivatives.

  • Changed all the classes of object generated for a better dispatching on methods.

Minor changes

  • Added tests for all major functions with the help of package testthat.

Bug fixes

  • Fixed the generation of splines without any internal knot.

splines2 0.2.3

Bug fixes

  • Fixed one-piece constant basis for M-splines.

splines2 0.2.2

Bug fixes

  • Fixed the NA's handling in all the functions constructing spline bases.

splines2 0.2.1

New features

  • Added function bSpline generating B-spline basis allowing zero degree or piecewise constant basis based on function bs in package splines.

  • Introduced function bSpline to allow M-splines of degree zero.

  • Added function cSpline constructing convex spline (C-spline) basis.

  • Added predict methods for bSpline2 object and cSpline object generated by bSpline and cSpline, respectively.

  • Added print methods for all splines2 objects developed so far.

Major changes

  • Improved the function iSpline to construct I-spline basis directly from B-spline basis instead of M-spline basis.

Minor changes

  • Updated all CRAN URL to a canonical form suggested.

splines2 0.1.0

New features

  • The first version of splines2 providing functions constructing M-spline, I-spline, and integral of B-spline basis.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


0.2.8 by Wenjie Wang, 2 years ago

Report a bug at

Browse source code at

Authors: Wenjie Wang [aut, cre] , Jun Yan [aut]

Documentation:   PDF Manual  

GPL (>= 3) license

Imports splines, stats

Suggests knitr, rmarkdown, testthat

Imported by CRFCSD, nonmem2R, reda.

Suggested by bamlss, brms, ivmte, momentuHMM.

See at CRAN