Description Usage Arguments Value See Also Examples
Calculate basis splines (B-Splines) for use in P-splines
1 | GetSplines(x.i, x0 = NULL, I = 2.5, degree = 3)
|
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 |
A list containing: a matrix of B-spline values; and a vector of knot locations.
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)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.