GetSplines: Calculate Basis Splines

Description Usage Arguments Value See Also Examples

View source: R/getsplines.R

Description

Calculate basis splines (B-Splines) for use in P-splines

Usage

1
GetSplines(x.i, x0 = NULL, I = 2.5, degree = 3)

Arguments

x.i

vector of x-values (without NAs) for which splines need to be calculated (determines the number of rows of B.ik)

x0

x-value which determines knot placement. By default, knot is placed half-interval before last observation

I

interval length between two knots during observation period

degree

degree of splines used. Currently tested only with degree 3

Value

A list containing: a matrix of B-spline values; and a vector of knot locations.

See Also

GetPSplines

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## visualize
x.i <- seq(1, 55, 0.025)
res <- GetSplines(x.i, I = 2.5)
dim(res$B.ik)
K <- length(res$knots.k); K
plot(res$B.ik[,1] ~ x.i, type= "n", xlab = "time", ylim = c(0,1), ylab = "Splines", xlim = range(x.i))
abline(v=res$knots.k, col = seq(1, K), lwd = 1)
for (k in 1:K){
 lines(res$B.ik[,k]~ x.i, type= "l", col = k, lwd = 1)
 }

MJAlexander/distortr documentation built on July 17, 2020, 4:06 p.m.