R: Calculate the knot averages of a B-spline basis.
knotave
R Documentation
Calculate the knot averages of a B-spline basis.
Description
Calculates the knot averages of a B-spline basis.
Usage
knotave(knots, d)
Arguments
knots
Knot Vector (with d+1 coincident knots on the boundaries).
d
Degree of the B-spline basis.
Value
Numeric containing knot averages
Author(s)
Bjoern Bornkamp
References
Bornkamp, B. and Ickstadt, K. (2009). A Note on B-Splines for
Semiparametric Elicitation. The American Statistician,
63, 373–377
Dierckx, P. (1993), Curve and Surface
Fitting with Splines, Clarendon Press
See Also
SEL
Examples
## Example for calculation of a control polygon
knts <- c(rep(0, 4), rep(1, 4))
cf <- c(-1, -1, 1/2, 0)
sq <- seq(0, 1, length = 101)
N <- splineDesign(sq, knots = knts, ord = 4)
res <- colSums(t(N)*cf)
plot(sq, res, type = "l", ylim = c(-1, 0.6))
kntAv <- knotave(knts, 3)
lines(kntAv, cf, col = "red") # add control polygon
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(SEL)
Loading required package: splines
Loading required package: quadprog
Loading required package: lattice
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/SEL/knotave.Rd_%03d_medium.png", width=480, height=480)
> ### Name: knotave
> ### Title: Calculate the knot averages of a B-spline basis.
> ### Aliases: knotave
>
> ### ** Examples
>
> ## Example for calculation of a control polygon
> knts <- c(rep(0, 4), rep(1, 4))
> cf <- c(-1, -1, 1/2, 0)
> sq <- seq(0, 1, length = 101)
> N <- splineDesign(sq, knots = knts, ord = 4)
> res <- colSums(t(N)*cf)
> plot(sq, res, type = "l", ylim = c(-1, 0.6))
> kntAv <- knotave(knts, 3)
> lines(kntAv, cf, col = "red") # add control polygon
>
>
>
>
>
> dev.off()
null device
1
>