get_B: Compute Constrained GLM Coefficient Estimates via Lagrangian...

View source: R/get_B.R

get_BR Documentation

Compute Constrained GLM Coefficient Estimates via Lagrangian Multipliers

Description

Core estimation function for Lagrangian multiplier smoothing splines. Computes penalized coefficient estimates subject to smoothness constraints (continuity and derivative matching at knots) and optional user-supplied linear equality or inequality constraints. Dispatches to one of three computational paths depending on the model structure:

Path 1. GEE (correlation structure present): When both Vhalf and VhalfInv are provided, the full N \times P whitened design \mathbf{X}^{*} = \mathbf{V}_{\mathrm{perm}}^{-1/2}\mathbf{X} is used after permuting observations to partition ordering via order_list. For structured correlation, the solver tries the supplement's decomposition \mathbf{G}^{-1} = \mathbf{G}_{\mathrm{on}}^{-1} + \mathbf{G}_{\mathrm{off}}^{-1} with \mathbf{G}_{\mathrm{off}}^{-1} = \mathbf{E}\mathbf{J}\mathbf{E}^{\top}. This gives a Woodbury path with cost O(Kp^3 + Pr^2) when the cross-partition rank r is small; otherwise the dense O(P^3) path is used. Two sub-paths:

  • Path 1a. Gaussian identity + GEE. See .get_B_gee_gaussian (dense) and .get_B_gee_woodbury (accelerated).

  • Path 1b. Non-Gaussian GEE. See .get_B_gee_glm (dense) and .get_B_gee_glm_woodbury (accelerated).

Path 2. Gaussian identity link, no correlation: Unconstrained estimate \hat{\boldsymbol{\beta}}_k = \mathbf{G}_k\mathbf{X}_k^{\top}\mathbf{y}_k per partition, then a single Lagrangian projection. See .get_B_gaussian_nocorr.

Path 3. Non-Gaussian GLM, no correlation: Partition-wise unconstrained estimates via Newton-Raphson, then Lagrangian projection. See .get_B_glm_nocorr.

Inequality constraint handling: When inequality constraints \mathbf{C}^{\top}\boldsymbol{\beta} \succeq \mathbf{c} are present, the sparsity pattern of \mathbf{C} is inspected automatically. If every constraint column has nonzeros in only a single partition block (block-separable), a partition-wise active-set method is used. If any constraint spans multiple partition blocks (e.g.\ cross-knot monotonicity), the dense quadprog::solve.QP SQP fallback is invoked.

Usage

get_B(
  X,
  X_gram,
  Lambda,
  keep_weighted_Lambda,
  unique_penalty_per_partition,
  L_partition_list,
  A,
  Xy,
  y,
  K,
  p_expansions,
  R_constraints,
  Ghalf,
  GhalfInv,
  parallel_eigen,
  parallel_aga,
  parallel_matmult,
  parallel_qr,
  parallel_unconstrained,
  cl,
  chunk_size,
  num_chunks,
  rem_chunks,
  family,
  unconstrained_fit_fxn,
  iterate,
  qp_score_function,
  quadprog,
  qp_Amat,
  qp_bvec,
  qp_meq,
  prevB = NULL,
  prevUnconB = NULL,
  iter_count = 0,
  prev_diff = Inf,
  tol,
  constraint_value_vectors,
  order_list,
  glm_weight_function,
  schur_correction_function,
  need_dispersion_for_estimation,
  dispersion_function,
  observation_weights,
  homogenous_weights,
  return_G_getB,
  blockfit,
  just_linear_without_interactions,
  Vhalf,
  VhalfInv,
  gee_precomp = NULL,
  initial_active_ineq = integer(0),
  ...
)

Arguments

X

List of length K+1; partition-specific design matrices.

X_gram

List of Gram matrices by partition.

Lambda

Combined penalty matrix.

keep_weighted_Lambda

Logical.

unique_penalty_per_partition

Logical.

L_partition_list

List of partition-specific penalty matrices.

A

Constraint matrix \mathbf{A} (P \times R).

Xy

List of cross-products by partition.

y

List of response vectors by partition.

K

Integer; number of interior knots.

p_expansions

Integer; basis terms per partition.

R_constraints

Integer; columns of \mathbf{A}.

Ghalf

List of \mathbf{G}^{1/2}_k matrices.

GhalfInv

List of \mathbf{G}^{-1/2}_k matrices.

parallel_eigen, parallel_aga, parallel_matmult, parallel_qr

parallel_unconstrained Logical flags.

cl

Cluster object.

chunk_size, num_chunks, rem_chunks

Parallel distribution parameters.

family

GLM family object.

unconstrained_fit_fxn

Partition-wise unconstrained estimator.

iterate

Logical; iterate for non-canonical links.

qp_score_function

Score function for QP steps.

quadprog

Logical; use quadprog::solve.QP for inequality constraints.

qp_Amat, qp_bvec, qp_meq

Inequality constraint specification \mathbf{C}^{\top}\boldsymbol{\beta} \succeq \mathbf{c}.

prevB, prevUnconB, iter_count, prev_diff

Retired; ignored.

tol

Convergence tolerance.

constraint_value_vectors

List encoding nonzero RHS \mathbf{A}^{\top}\boldsymbol{\beta} = \mathbf{c}.

order_list

Partition-to-data index mapping.

glm_weight_function

Function computing working weights.

schur_correction_function

Function computing Schur corrections.

need_dispersion_for_estimation

Logical.

dispersion_function

Dispersion estimator.

observation_weights

List of observation weights by partition.

homogenous_weights

Logical.

return_G_getB

Logical; return \mathbf{G}, \mathbf{G}^{1/2}, \mathbf{G}^{-1/2} per partition.

blockfit, just_linear_without_interactions

Retired; retained for call-site compatibility.

Vhalf, VhalfInv

Square root and inverse square root of the working correlation matrix in the original observation ordering. When both are non-NULL, dispatches to Path 1; VhalfInv is permuted internally to partition ordering via order_list.

gee_precomp

Optional pre-computed correlated tuning objects. Internal use only; avoids rebuilding fixed whitening objects at each tuning step.

initial_active_ineq

Optional inequality columns used as the first active set in tuning or repeated solves.

...

Passed to fitting, weight, correction, and dispersion functions.

Value

If return_G_getB = FALSE: a list with B (coefficient column vectors by partition) and qp_info.

If return_G_getB = TRUE: a list with elements:

B

List of constrained coefficient column vectors \tilde{\boldsymbol{\beta}}_k by partition.

G_list

List with G, Ghalf, GhalfInv, each a list of K+1 matrices.

qp_info

QP or active-set metadata, including Lagrangian multipliers and active-constraint information when available, or NULL.


lgspline documentation built on May 8, 2026, 5:07 p.m.