Smooth: R6 class for a penalized spline smooth

Description Public fields Methods

Description

The penalized spline smooths are constructed using the mgcv package. See also:

Public fields

terms

The names of the covariates as a character vector.

data

The data frame from which the covariates are extracted.

bs

A basis abbreviation as defined in mgcv. Defaults to "tp".

k

The basis dimension before constraints and penalization. Defaults to 10.

m

The order of the penalty. Defaults to NA for auto-initialization.

xt

Extra information to set up the basis. Defaults to NULL.

knots

The knots for the basis construction as a data frame with the terms as names. Defaults to NULL for auto-initialization with mgcv's basis-specific method.

constraints

A matrix of (identifiability) constraints. Defaults to NULL, in which case only a centering constraint will be applied.

absorb_constraints

If the constraints should be absorbed into the basis. Defaults to TRUE.

scale_penalty

If the penalty matrices should be scaled to match the inner product of the design matrix. Defaults to TRUE.

identity_penalty

If the smooth should be reparameterized to turn the penalty matrices into identity matrices. This is more or less equivalent to mgcv::smooth2random(). Defaults to FALSE.

Methods

Public methods


Method new()

Create a new smooth object.

Usage
Smooth$new(terms, data, bs = "tp", k = 10)
Arguments
terms

The names of the covariates as a character vector.

data

The data frame from which the covariates are extracted.

bs

A basis abbreviation as defined in mgcv. Defaults to "tp".

k

The basis dimension before constraints and penalization. Defaults to 10.


Method initialize_knots()

Initialize knots using mgcv's basis-specific method.

Usage
Smooth$initialize_knots()

Method initialize_constraints()

Initialize constraints with a centering constraint.

Usage
Smooth$initialize_constraints()

Method add_centering_constraint()

Add a centering constraint.

Usage
Smooth$add_centering_constraint()

Method add_point_constraints()

Add a point constraint where the smooth should pass through zero.

Usage
Smooth$add_point_constraints(data)
Arguments
data

A data frame with the terms as names defining where the smooth should pass through zero.


Method remove_all_constraints()

Remove all constraints (including the centering constraint).

Usage
Smooth$remove_all_constraints()

Method construct()

Construct the design matrix and the penalty matrices.

Usage
Smooth$construct(data = NULL)
Arguments
data

An optional data frame if different data should be used for the construction of the design matrix than the basis.

Returns

A list with the elements design_matrix, penalty_matrices and ranks.


Method clone()

The objects of this class are cloneable with this method.

Usage
Smooth$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.


hriebl/SmoothOperator documentation built on Dec. 20, 2021, 4:49 p.m.