Generates a penalty matrix representing the integrated squared second derivatives for smoothing spline basis functions, which controls the smoothness of the fitted curve.
get_2ndDerivPenalty(
colnm_expansions,
C,
power1_cols,
power2_cols,
power3_cols,
power4_cols,
interaction_single_cols,
interaction_quad_cols,
triplet_cols,
nc,
select_cols = NULL
)
A symmetric \(p \times p\) penalty matrix \(\textbf{P}\) representing integrated squared second derivatives for basis expansions in a single partition of the smoothing spline.
Character vector of column names for basis expansions
Numeric matrix of basis expansions
Indices of linear term columns
Indices of quadratic term columns
Indices of cubic term columns
Indices of quartic term columns
Indices of single interaction columns
Indices of quadratic interaction columns
Indices of triplet interaction columns
Number of cubic expansions
Optional vector of column indices to penalize (default: all linear terms)
This function computes the analytic form of the traditional integrated, squared, second-derivative evaluated over the bounds of the input data. If \(f(x) = \textbf{X}\boldsymbol{\beta}\), then the penalty is based on \(\int \{ f''(x) \}^2 dx = \boldsymbol{\beta}^{T}(\int \textbf{X}''^{T}\textbf{X}'' dx)\boldsymbol{\beta}\). This function computes the matrix \(\textbf{P} = \int \textbf{X}''^{T}\textbf{X}'' dx\). When scaled by a non-negative scalar (wiggle penalty, predictor penalties and/or partition penalties), this becomes the smoothing spline penalty.