The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

Title: Integration for B-Spline
Version: 0.1.0
Maintainer: Yue Bai <bai42@wisc.edu>
Description: Integrated B-spline function.
Depends: R (≥ 3.0.2)
License: GPL-2
LazyData: true
RoxygenNote: 5.0.1
NeedsCompilation: no
Packaged: 2016-06-26 14:03:37 UTC; dudupiggy
Author: Yue Bai [aut, cre]
Repository: CRAN
Date/Publication: 2016-06-27 06:59:52

Integration for B-splines

Description

Calculate the integral of a B-spline function.

Usage

ibs(x, knots = NULL, ord = 4, coef = rep(1, length(knots) - ord))

Arguments

x

Numerical value or vector. The value(s) at which to evaluate the integral of the B-spline; must be in the bewteen min(knots) and max(knots).

knots

A numeric vector of knot positions.

ord

An integer >=1. The order of the B-spline integrand function to be integrated. Equals degree plus 1.

coef

A numerical vector. The coefficients (de Boor points) defining the B-spline integrand function.

Details

The function returns the integral(s) of the B-spline function specified by knots knots, order ord, and coefficients coef, from the minimum knot position to each x value. The evaluation is based on a closed form expression of the integral in terms of higher order B-splines, given on page 128 of de Boor (2001).

Value

A numerical equal to the integral(s).

References

de Boor, C (2001) A Practical Guide to Splines. New York: Springer.

Examples

library(splines)
f <- function(x) x + 2 * x^2 - 3 * x^3 
n <- 200
set.seed(123)
x <- runif(n)
y <- f(x) + rnorm(n, sd = 0.1)
kns <- c(rep(0, 4), 1:4 * 0.2, rep(1, 4))
bs.c <- splineDesign(kns, x, 4)
coeff <- as.matrix(lm(y ~ bs.c-1)$coefficients)
f.b <- function(x, coeff) splineDesign(kns, x, 4) %*% coeff
integrate(f.b, 0, 1, coeff)
ibs(1,kns,4,coeff)
integrate(f, 0, 1)
plot(x,y)
curve(f(x), add = TRUE)
points(x,fitted(lm(y~bs.c-1)),col="blue",lty=1)

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.