makeBasis: Construction of quantile-based linear spline basis

Description Usage Arguments Value Author(s) Examples

Description

Construction of quantile-based linear spline basis

Usage

1
2
  makeBasis(x, type = c("linear", "cubic"), nKnots,
    settings = NULL)

Arguments

x

the covariate vector

type

the type of splines to be used, “linear” splines modelled by a truncated power series basis, or “cubic” splines modelled by O'Sullivan splines.

nKnots

number of quantile-based knots to be used

settings

list of settings. By default, this is NULL and a whole new basis depending on type and nKnots is built. Otherwise this is expected to be attributes(basis) and the settings of the old basis are used to compute the spline basis vectors at new grid points x.

Value

the spline basis in a matrix with length(x) rows. As an attribute, a list with the settings is provided.

Author(s)

Daniel Sabanes Bove daniel.sabanesbove@ifspm.uzh.ch

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
x <- seq(from=-5,
         to=5,
         length=1000)

Z <- makeBasis(x=x,
               nKnots=4L,
               type="linear")
str(Z)

plot(x,
     Z %*% c(1, -3, 2, 1),
     type="l")
abline(v=attr(Z, "knots"),
       col="gray",
       lty=2)

Z <- makeBasis(x=x,
               nKnots=10L,
               type="cubic")
dimZ <- ncol(Z)

coefs <- rnorm(dimZ)

plot(x,
     Z %*% coefs,
     type="l")
abline(v=attr(Z, "knots"),
       col="gray",
       lty=2)

hypergsplines documentation built on May 2, 2019, 6:14 p.m.