Free-Knot Regression Splines for GAMLSS

Description

Constructs a univariate regression spline whose interior knot locations, and optionally the number of interior knots, are selected from the current weighted working response.

Usage

fk(x, k = 10L, nk = NULL, degree = 1L,
  criterion = "bic", knots = NULL, K = NULL,
  reselect = FALSE, optim.control = list(), ...)

Arguments

x

A numeric covariate.

k

Integer, the largest number of free interior knots considered when nk = NULL. Candidate models from zero through k interior knots are compared.

nk

Integer, optional fixing the number of free interior knots. The locations are still estimated.

degree

Integer, the polynomial degree of the B-spline basis. The default 1 gives a piecewise-linear spline.

criterion

Character selection criterion. Available choices are “bic”, “aic”, “gaic”, “aicc”, and “gcv”.

knots

Optional numeric vector of fixed interior knot locations. The values must be distinct and strictly inside the range of x. When x is transformed, locations are specified on the transformed scale. Supplying knots overrides automatic location optimization.

K

Optional nonnegative penalty multiplier used by criterion = “gaic”. The model-level value, or 2, is used when NULL.

reselect

Logical. If FALSE, the number of knots selected during the first backfitting update is retained and its locations are warm-started in later updates. If TRUE, the number is selected again in every update.

optim.control

Named list passed as the control argument to optim for knot-location optimization.

Additional entries merged into optim.control.

Details

For each candidate number of interior knots, fk() uses a B-spline basis with fixed, repeated boundary knots. Interior knots are represented by positive ordered gaps. This removes permutation ambiguity and prevents knot crossings during optimization.

Conditional on the knot locations, spline coefficients are profiled out by weighted least squares. Knot optimization therefore only operates on the interior locations. The fitted model term is centered.

When nk = NULL, models with zero through k interior knots are compared using criterion. Effective degrees of freedom include both the centered spline coefficients and the estimated interior knot locations. Fixed locations supplied through knots do not add knot-location degrees of freedom.

Value

The constructor returns an object of classes “special” and “fk”.

See Also

gamlss2, special_terms

Examples

library("gamlss2")

data("SpirometryUS")

## subset for female
d <- subset(SpirometryUS, gender == "male")

## Automatically select zero through four free interior knots
m1 <- gamlss2(fev1 ~ fk(age, nk = 1) | ., data = d, family = NO)

## estimated effects
plot(m1)

## predict quantiles
qu <- c(0.025, seq(0.1, 0.9, by = 0.1), 0.975)
fit <- quantile(m1, probs = qu)

## plot
plot(fev1 ~ age, data = d)
i <- order(d$age)
matlines(d$age[i], fit[i, ],
  lty = 1, lwd = 2, col = c(2, rep(4, ncol(fit) - 1)))