Core estimation function for Lagrangian multiplier smoothing splines. Computes coefficient estimates under smoothness constraints and penalties for GLMs, handling four distinct computational paths depending on model structure.
get_B(
X,
X_gram,
Lambda,
keep_weighted_Lambda,
unique_penalty_per_partition,
L_partition_list,
A,
Xy,
y,
K,
nc,
nca,
Ghalf,
GhalfInv,
parallel_eigen,
parallel_aga,
parallel_matmult,
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,
shur_correction_function,
need_dispersion_for_estimation,
dispersion_function,
observation_weights,
homogenous_weights,
return_G_getB,
blockfit,
just_linear_without_interactions,
Vhalf,
VhalfInv,
...
)
For `return_G_getB = FALSE`: A list of coefficient vectors by partition.
For `return_G_getB = TRUE`: A list with elements:
List of coefficient vectors by partition
List containing G matrices (covariance matrices), Ghalf (square root), and GhalfInv (inverse square root)
List of design matrices by partition
List of Gram matrices by partition
Combined penalty matrix (smoothing spline + ridge)
Logical; retain GLM weights in smoothing spline penalty
Logical; whether to use partition-specific penalties
List of partition-specific penalty matrices
Matrix of smoothness constraints (continuity, differentiability)
List of X^T y products by partition
List of responses by partition
Integer; number of knots (partitions = K+1)
Integer; number of coefficients per partition
Integer; number of columns in constraint matrix
List of G^(1/2) matrices by partition
List of G^(-1/2) matrices by partition
Logical flags for parallel computation components
Cluster object for parallel processing
Parameters for chunking in parallel processing
GLM family object (includes link function and variance functions)
Function for obtaining unconstrained estimates
Logical; whether to use iterative optimization for non-linear links
Function; see description in lgspline
. Accepts arguments in order "X, y, mu, order_list, dispersion, VhalfInv, ...".
Logical; whether to use quadratic programming for inequality constraints
Quadratic programming constraint parameters
List of previous coefficient estimates for warm starts
List of previous unconstrained coefficient estimates
Iteration tracking for convergence
Numeric; convergence tolerance
List of additional constraint values
List of observation orderings by partition
Function for computing GLM weights
Function for uncertainty corrections in information matrix
Logical; whether dispersion needs estimation
Function for estimating dispersion parameter
Optional observation weights by partition
Logical; whether weights are constant
Logical; whether to return G matrices with coefficient estimates
Logical; whether to use block-fitting approach for special structure
Vector of columns for non-spline effects
Square root and inverse square root correlation matrices for GEE fitting
Additional arguments passed to fitting functions
This function implements the method of Lagrangian multipliers for fitting constrained generalized linear models with smoothing splines. The function follows one of four main computational paths depending on the model structure:
1. Pure GEE (No Blockfitting): When Vhalf and VhalfInv are provided without blockfitting, the function uses generalized estimating equations to handle correlated data. The design matrix is arranged in block-diagonal form, and the estimation explicitly accounts for the correlation structure provided. Uses sequential quadratic programming (SQP) for optimization.
2. Blockfitting (With or Without Correlation): When blockfit=TRUE and linear-only terms are specified, the function separates spline effects from linear-only terms. The design matrix is restructured with spline terms in block-diagonal form and linear terms stacked together. This structure is particularly efficient when there are many non-spline effects. The function can handle both correlated (GEE) and uncorrelated data in this path.
3. Canonical Gaussian, No Correlation: For Gaussian family with identity link and no correlation structure, calculations are greatly simplified. No unconstrained fit function is needed; estimation uses direct matrix operations. This path takes advantage of the closed-form solution available for linear models with Gaussian errors.
4. GLMs, No Correlation: For non-Gaussian GLMs without correlation structure, the function requires an unconstrained_fit_fxn to obtain initial estimates. It may use iterative fitting for non-canonical links. This path first computes unconstrained estimates for each partition, then applies constraints using the method of Lagrangian multipliers.
All paths use efficient matrix decompositions and avoid explicitly constructing full matrices when possible. For non-canonical links, iterative fitting is employed to converge to the optimal solution.