Generate the B-spline basis matrix for a polynomial spline, applicable for both univariate basis and bivariate basis systems.

1 2 |

`tp` |
timepoint vector in the time direction; must be sorted |

`cp` |
covariate vector in the covariate direction; must be sorted |

`nknots.tp` |
number of knots for the time direction; See 'Details' |

`nknots.cp` |
number of knots for the covariate direction; See 'Details' |

`sub.case` |
indicator for univariate ( |

`degree.poly` |
degree of polynomials for B-spline basis system; default is |

kpbb is built based on the function `bs`

. For the time direction, the generated basis matrix has the dimension `length(tp)`

by
`nknots.tp + degree.poly + 1`

, regardless whehter the number of knots is negative or not.
When `sub.case = 2`

, the generated basis matrix is the kronecker product of the two basis matrices.

A basis matrix, with attributes which are for the future use of `predict.kpbb`

.

[1]. Meng Li, Ana-Maria Staicu and Howard D. Bondell (2013), Incorporating Covariates in Skewed Functional Data Models. http://www.stat.ncsu.edu/information/library/papers/mimeo2654_Li.pdf.

`bs`

, `predict.kpbb`

, `data.simulation`

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | ```
data(data.simulation) # load benchmark data
y <- DST$obs # matrix of observation
# generate bivariate basis using 3 knots for each direction
basis <- kpbb(DST$tp, DST$cp, nknots.tp = 3, nknots.cp = 3)
# linear regression
lm.fit <- lm(as.vector(y) ~ basis - 1)
y.fit <- matrix(fitted(lm.fit), nrow = 100, ncol = 80)
# visualize the data and fitted surface
par(mfrow = c(1,2))
persp(DST$cp, DST$tp, y, theta=60, phi=15,
ticktype = "detailed", col="lightblue",
xlab = "covariate", ylab = "time",
zlab="data", main="data surface")
persp(DST$cp, DST$tp, y.fit, theta=60, phi=15,
ticktype = "detailed", col="lightblue",
xlab = "covariate", ylab = "time",
zlab="data", main="fitted surface via lm")
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.