qknots: Specification of knots in a cubic P-spline model

View source: R/qknots.R

qknotsR Documentation

Specification of knots in a cubic P-spline model

Description

Specification of knots for a cubic B-spline basis with K elements in a P-spline model. The knots should support the data contained in vector x and are by default assumed equidistant. Alternatively, they can be based on the data quantiles. The penalty matrix of the selected penalty order (3 by default) is also returned.

Usage

qknots(x, xmin = NULL, xmax = NULL, equid.knots = TRUE, pen.order = 3, K = 25)

Arguments

x

data that the knots should upport.

xmin

desired minimum value for the knots.

xmax

desired maximum value for the knots.

equid.knots

logical indicating if equidistant knots are desired (Default: TRUE). If FALSE, the quantile of x are used to select the knots.

pen.order

penalty order if equid.knots is TRUE.

K

number of B-splines in the basis.

Value

A list containing:

  • xmin : ⁠ ⁠specified minimum value for the knots, except if \min(x) < xmin, in which case the default value \min(x)-sd(x) is returned.

  • xmin : ⁠ ⁠specified maximum value for the knots, except if xmax < \max(x), in which case the default value \max(x)+sd(x) is returned.

  • K : ⁠ ⁠number of B-splines.

  • knots : ⁠ ⁠equidistant knots on (xmin,xmax) if equidistant.knots is TRUE, based on quantiles of x otherwise.

  • Pd : ⁠ ⁠K\times K penalty matrix of order pen.order.

  • pen.order : ⁠ ⁠a reminder of the requested penalty order (Default: 3).

Examples

x = runif(500)
obj = qknots(x,xmin=0,xmax=1,K=13)
print(obj)

DALSM documentation built on Oct. 2, 2023, 5:09 p.m.