| Title: | A Modular Two-Step Convex Optimization Estimator for Ill-Posed Problems |
|---|---|
| Description: | Convex Least Squares Programming (CLSP) is a two-step estimator for solving underdetermined, ill-posed, or structurally constrained least-squares problems. It combines pseudoinverse-based estimation with convex-programming correction methods inspired by Lasso, Ridge, and Elastic Net to ensure numerical stability, constraint enforcement, and interpretability. The package also provides numerical stability analysis and CLSP-specific diagnostics, including partial R^2, normalized RMSE (NRMSE), Monte Carlo t-tests for mean NRMSE, and condition-number-based confidence bands. |
| Authors: | Ilya Bolotov [aut, cre] (ORCID: <https://orcid.org/0000-0003-1148-7144>) |
| Maintainer: | Ilya Bolotov <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 2.0.0 |
| Built: | 2026-06-07 23:03:15 UTC |
| Source: | https://github.com/econcz/rclsp |
for CLSP.This method assembles the constraint matrix A from user-supplied or internally generated components — C, S, M, and Q — and assigns the corresponding right-hand side vector b. It is a required pre-step before solving a Convex Least Squares Programming (CLSP) problem.
canonize( object, problem = "", C = NULL, S = NULL, M = NULL, Q = NULL, b = NULL, m = NULL, p = NULL, i = 1L, j = 1L, zero_diagonal = FALSE )canonize( object, problem = "", C = NULL, S = NULL, M = NULL, Q = NULL, b = NULL, m = NULL, p = NULL, i = 1L, j = 1L, zero_diagonal = FALSE )
object |
An object of class |
problem |
Character, optional. Structural template for matrix construction. One of:
|
C, S, M
|
Numeric matrix or |
Q |
Numeric matrix or |
b |
Numeric vector or |
m, p
|
Integer or |
i, j
|
Integer, default = |
zero_diagonal |
Logical, default = |
Depending on the specified problem type, it can generate allocation, tabular matrix, or modular constraints and enforce optional diagonal exclusions. All missing blocks are padded to ensure conformability.
An updated object of class "clsp".
ANumeric matrix. Canonical design matrix constructed from (C, S, M, Q).
C_idxInteger vector of length 2 indicating the size of the C block.
bNumeric vector. Conformable right-hand side vector.
The Convex Least Squares Programming (CLSP) estimator solves underdetermined, ill-posed, or structurally constrained least-squares problems using a modular two-step approach. The first step computes a pseudoinverse-based estimate, and the second step applies a convex correction (Lasso, Ridge, or Elastic Net) to ensure numerical stability, constraint enforcement, and interpretability.
clsp( problem = "", C = NULL, S = NULL, M = NULL, b = NULL, m = NULL, p = NULL, i = 1L, j = 1L, zero_diagonal = FALSE, r = 1L, Z = NULL, rcond = FALSE, tolerance = NULL, iteration_limit = NULL, final = TRUE, alpha = NULL, cond_tolerance = NULL, ... )clsp( problem = "", C = NULL, S = NULL, M = NULL, b = NULL, m = NULL, p = NULL, i = 1L, j = 1L, zero_diagonal = FALSE, r = 1L, Z = NULL, rcond = FALSE, tolerance = NULL, iteration_limit = NULL, final = TRUE, alpha = NULL, cond_tolerance = NULL, ... )
problem |
character scalar, optional Structural template for matrix construction. One of:
|
C, S, M
|
numeric matrix or |
b |
numeric vector or |
m, p
|
integer scalar or |
i, j
|
integer scalar, default = |
zero_diagonal |
logical scalar, default = |
r |
integer scalar, default = |
Z |
numeric matrix or |
rcond |
numeric scalar or logical scalar, default = |
tolerance |
numeric scalar or |
iteration_limit |
integer scalar or |
final |
logical scalar, default = |
alpha |
numeric scalar, numeric vector, or
|
cond_tolerance |
numeric scalar or |
... |
Optional. Additional arguments passed to the CVXR solver backend. |
This estimator unifies pseudoinverse-based least squares with convex
programming correction. The pseudoinverse step computes an initial solution
iteratively via the Moore–Penrose or Bott–Duffin
inverse. The convex step then refines by minimizing a
mixed norm under equality constraints
. The method supports allocation
problems (AP), constrained modular least squares (CMLS), and general CLSP
formulations.
To ensure cross-platform reproducibility, all CLSP implementations use a
modified condition number function based on singular values, with a relative
cutoff equal to .
An object of class "clsp" representing the fitted
Convex Least Squares Programming (CLSP) model.
The object is a named list containing all initialized fields and
solver results.
Class-specific methods such as summary.clsp(),
corr.clsp(), and ttest.clsp() can be used to
extract, analyze, and summarize the results.
## Not run: ## Example: CMLS (RP) estimation with stationary-point constraints set.seed(123456789) # sample (dataset) k <- 500L # number of observations p <- 6L # number of regressors c0 <- 1 # sum of coefficients D <- matrix(NA_real_, nrow = k, ncol = p) D[, 1] <- 1.0 # constant D[, 2:p] <- matrix(rnorm(k * (p - 1)), k, p - 1) b_true <- rnorm(p) b_true <- (b_true / sum(b_true)) * c0 # normalize to sum = c e <- matrix(rnorm(k), ncol = 1) y <- D %*% b_true + e # build blocks for CLSP (CMLS) b <- rbind( matrix(c0, ncol = 1), # sum of coefficients matrix(0, nrow = k - 2, ncol = 1), matrix(0, nrow = k - 1, ncol = 1), matrix(y, ncol = 1) ) C <- rbind( matrix(1, nrow = 1, ncol = p), # row of ones diff(D, differences = 2), # 2nd differences diff(D, differences = 1) # 1st differences ) # diagonal sign-matrix for 2nd differences S <- rbind( matrix(0, nrow = 1, ncol = k - 2), diag(sign(diff(as.numeric(y), differences = 2))), matrix(0, nrow = k - 1, ncol = k - 2) ) # model model <- rclsp::clsp( problem = "cmls", b = b, C = C, S = S, M = D, r = 1L, # no refinement alpha = 1.0 # MNBLUE solution ) # results print("true beta (x_M):") print(round(b_true, 4)) print("beta hat (x_M hat):") print(round(model$x, 4)) print(model) # bootstrap t-test tt <- rclsp::ttest( model, sample_size = 30L, seed = 123456789L, distribution = rnorm, partial = TRUE ) print("Bootstrap t-test:") print(tt) ## End(Not run)## Not run: ## Example: CMLS (RP) estimation with stationary-point constraints set.seed(123456789) # sample (dataset) k <- 500L # number of observations p <- 6L # number of regressors c0 <- 1 # sum of coefficients D <- matrix(NA_real_, nrow = k, ncol = p) D[, 1] <- 1.0 # constant D[, 2:p] <- matrix(rnorm(k * (p - 1)), k, p - 1) b_true <- rnorm(p) b_true <- (b_true / sum(b_true)) * c0 # normalize to sum = c e <- matrix(rnorm(k), ncol = 1) y <- D %*% b_true + e # build blocks for CLSP (CMLS) b <- rbind( matrix(c0, ncol = 1), # sum of coefficients matrix(0, nrow = k - 2, ncol = 1), matrix(0, nrow = k - 1, ncol = 1), matrix(y, ncol = 1) ) C <- rbind( matrix(1, nrow = 1, ncol = p), # row of ones diff(D, differences = 2), # 2nd differences diff(D, differences = 1) # 1st differences ) # diagonal sign-matrix for 2nd differences S <- rbind( matrix(0, nrow = 1, ncol = k - 2), diag(sign(diff(as.numeric(y), differences = 2))), matrix(0, nrow = k - 1, ncol = k - 2) ) # model model <- rclsp::clsp( problem = "cmls", b = b, C = C, S = S, M = D, r = 1L, # no refinement alpha = 1.0 # MNBLUE solution ) # results print("true beta (x_M):") print(round(b_true, 4)) print("beta hat (x_M hat):") print(round(model$x, 4)) print(model) # bootstrap t-test tt <- rclsp::ttest( model, sample_size = 30L, seed = 123456789L, distribution = rnorm, partial = TRUE ) print("Bootstrap t-test:") print(tt) ## End(Not run)
This method performs a row-deletion sensitivity analysis on the canonical
constraint matrix , denoted as , and
evaluates the marginal effect of each constraint row on numerical stability,
angular alignment, and estimator sensitivity.
corr(object, reset = FALSE, threshold = 0)corr(object, reset = FALSE, threshold = 0)
object |
An object of class |
reset |
Logical, default = |
threshold |
Numeric, default = |
For each row in , it computes:
The Root Mean Square Alignment () with all
other rows .
The change in condition numbers , , and
when row is deleted.
The effect on estimation quality: changes in NRMSE and in the norms
of , , and .
Additionally, it computes the total RMSA statistic across all rows, summarizing the overall angular alignment of the constraint block.
A named list containing per-row diagnostic values:
Numeric vector of constraint indices (1-based).
Numeric vector of values.
Numeric vector of after
deleting row i.
Numeric vector of after
deleting row i.
Numeric vector of after
deleting row i.
Numeric vector of after
deleting row i.
Numeric vector of after
deleting row i.
Numeric vector of after
deleting row i.
Numeric vector of or
after deleting row i.
This function either (a) resamples residuals via a nonparametric bootstrap
to generate an empirical NRMSE sample, or (b) produces synthetic right-hand
side vectors b from a user-defined or default distribution and
re-estimates the model. It tests whether the observed NRMSE significantly
deviates from the null distribution of resampled or simulated NRMSE values.
ttest( object, reset = FALSE, sample_size = 50L, seed = NULL, distribution = NULL, partial = FALSE, simulate = FALSE )ttest( object, reset = FALSE, sample_size = 50L, seed = NULL, distribution = NULL, partial = FALSE, simulate = FALSE )
object |
An object of class |
reset |
Logical, default = |
sample_size |
Integer, default = |
seed |
Integer or |
distribution |
Function or |
partial |
Logical, default = |
simulate |
Logical, default = |
A named list containing test results and null distribution statistics:
P(nrmse null mean)
P(nrmse null mean)
2-sided t-test p-value
Observed value
Mean of null distribution
Standard deviation of null distribution