Learn R Programming

Introduction

This R package implements Lagrangian multiplier smoothing splines, which reformulate smoothing splines through constrained optimization. This approach provides direct access to predictor-response relationships through interpretable coefficients, unlike other formulations that require post-fitting algebraic manipulation.

Installation

devtools::install_github("matthewlouisdavisBioStat/lgspline")

Citation

If you use this package in your research, please cite:

Davis, M. (2025). Lagrangian Multiplier Smoothing Splines. https://github.com/matthewlouisdavisBioStat/lgspline/

Contact

For questions or feedback, please open an issue on GitHub.

Copy Link

Version

Install

install.packages('lgspline')

Version

0.2.0

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Matthew Davis

Last Published

April 24th, 2025

Functions in lgspline (0.2.0)

compute_dGhalf

Compute Matrix Square Root Derivative
create_onehot

Create One-Hot Encoded Matrix
create_block_diagonal

Create Block Diagonal Matrix
compute_gram_block_diagonal

Compute Gram Matrix for Block Diagonal Structure
efficient_bfgs

BFGS Implementation for REML Parameter Estimation
compute_trace_UGXX_wrapper

Calculate Trace of Matrix Product \(\text{trace}(\textbf{X}\textbf{U}\textbf{G}\textbf{X}^{T})\)
compute_dW_dlambda_wrapper

Compute Derivative of Penalty Matrix G with Respect to Lambda (Wrapper)
compute_dG_dlambda

Compute Derivative of Penalty Matrix G with Respect to Lambda
damped_newton_r

Damped Newton-Raphson Parameter Optimization
generate_posterior

Generate Posterior Samples from Fitted Lagrangian Multiplier Smoothing Spline
compute_dG_u_dlambda_xy

Compute Derivative of \(\textbf{U}\textbf{G}\textbf{X}^{T}\textbf{y}\) with Respect to Lambda
get_2ndDerivPenalty

Compute Integrated Squared Second Derivative Penalty Matrix for Smoothing Splines
find_extremum

Find Extremum of Fitted Lagrangian Multiplier Smoothing Spline
find_neighbors

Find Neighboring Cluster Partitions Using Midpoint Distance Criterion
get_U

Efficiently Construct U Matrix
get_centers

Get Centers for Partitioning
get_2ndDerivPenalty_wrapper

Wrapper for Smoothing Spline Penalty Computation
lgspline-package

Lagrangian Multiplier Smoothing Splines
leave_one_out

Compute Leave-One-Out Cross-Validated predictions for Gaussian Response/Identity Link under Constraint.
lgspline-methods

lgspline: Lagrangian Multiplier Smoothing Splines
efficient_matrix_mult

Efficient Matrix Multiplication
get_polynomial_expansions

Generate Design Matrix with Polynomial and Interaction Terms
knot_expand_list

Expand Matrix into Partition Lists Based on Knot Boundaries
%**%

Efficient Matrix Multiplication Operator
get_interaction_patterns

Generate Interaction Variable Patterns
expgrid

Generate Grid Indices Without expand.grid()
get_B

Get Constrained GLM Coefficient Estimates
gramMatrix

Compute Gram Matrix
invert

Matrix Inversion with Fallback Methods
is_binary

Test if Vector is Binary
loglik_weibull

Compute Log-Likelihood for Weibull Accelerated Failure Time Model
make_constraint_matrix

Create Smoothing Spline Constraint Matrix
matmult_block_diagonal

Multiply Block Diagonal Matrices in Parallel
matinvsqrt

Calculate Matrix Inverse Square Root
matsqrt

Calculate Matrix Square Root
make_partitions

Create Data Partitions Using Clustering
make_derivative_matrix

Compute First and Second Derivative Matrices
lgspline

Fit Lagrangian Multiplier Smoothing Splines
lgspline.fit

Low-Level Fitting for Lagrangian Smoothing Splines
matmult_U

Left-Multiply a List of Block-Diagonal Matrices by U
nr_iterate

Compute Newton-Raphson Parameter Update with Numerical Stabilization
plot.lgspline

Plot Method for Lagrangian Multiplier Smoothing Spline Models
softplus

Compute softplus transform
std

Standardize Vector to Z-Scores
summary.lgspline

Summary method for lgspline Objects
take_derivative

Calculate Derivatives of Polynomial Terms
predict.lgspline

Predict Method for Fitted Lagrangian Multiplier Smoothing Spline
print.lgspline

Print Method for lgspline Objects
print.summary.lgspline

Print Method for lgspline Object Summaries
vectorproduct_block_diagonal

Vector-Matrix Multiplication for Block Diagonal Matrices
wald_univariate

Univariate Wald Tests and Confidence Intervals for Lagrangian Multiplier Smoothing Splines
prior_loglik

Log-Prior Distribution Evaluation for lgspline Models
take_interaction_2ndderivative

Calculate Second Derivatives of Interaction Terms
tune_Lambda

Tune Smoothing and Ridge Penalties via Generalized Cross Validation
weibull_dispersion_function

Estimate Weibull Dispersion for Accelerated Failure Time Model
weibull_family

Weibull Family for Survival Model Specification
unconstrained_fit_default

Unconstrained Generalized Linear Model Estimation
weibull_qp_score_function

Compute gradient of log-likelihood of Weibull accelerated failure model without penalization
weibull_shur_correction

Correction for the Variance-Covariance Matrix for Uncertainty in Scale
weibull_glm_weight_function

Weibull GLM Weight Function for Constructing Information Matrix
weibull_scale

Estimate Scale for Weibull Accelerated Failure Time Model
unconstrained_fit_weibull

Unconstrained Weibull Accelerated Failure Time Model Estimation
collapse_block_diagonal

Collapse Matrix List into a Single Block-Diagonal Matrix
GAmult_wrapper

Efficient Matrix Multiplication of G and A Matrices
compute_G_eigen

Compute Eigenvalues and Related Matrices for G
approx_grad

Finite-difference Gradient Computer
Details

Lagrangian Multiplier Smoothing Splines: Mathematical Details
coef.lgspline

Extract model coefficients
AGAmult_wrapper

Efficient Matrix Multiplication for \(\textbf{A}^{T}\textbf{G}\textbf{A}\)
compute_GhalfXy_temp_wrapper

Compute Component \(\textbf{G}^{1/2}\textbf{A}(\textbf{A}^{T}\textbf{G}\textbf{A})^{-1}\textbf{A}^{T}\textbf{G}\textbf{X}^{T}\textbf{y}\)
armaInv

Matrix Inversion using Armadillo
compute_Lambda

Construct Smoothing Spline Penalty Matrix