| Type: | Package |
| Title: | A Modular Two-Step Convex Optimization Estimator for Ill-Posed Problems |
| Version: | 0.1.0 |
| 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. |
| License: | MIT + file LICENSE |
| Encoding: | UTF-8 |
| Language: | en-US |
| Depends: | R (≥ 4.2) |
| Imports: | Matrix, stats, methods, CVXR, MASS |
| Suggests: | testthat (≥ 3.0.0) |
| Config/testthat/edition: | 3 |
| URL: | https://github.com/econcz/rclsp |
| BugReports: | https://github.com/econcz/rclsp/issues |
| RoxygenNote: | 7.3.3 |
| NeedsCompilation: | no |
| Packaged: | 2025-11-13 00:02:15 UTC; ilyabolotov |
| Author: | Ilya Bolotov |
| Maintainer: | Ilya Bolotov <ilya.bolotov@vse.cz> |
| Repository: | CRAN |
| Date/Publication: | 2025-11-17 21:10:02 UTC |
Construct the canonical design matrix A = [C | S; M | Q] for CLSP.
Description
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.
Usage
canonize(
object,
problem = "",
C = NULL,
S = NULL,
M = NULL,
Q = NULL,
b = NULL,
m = NULL,
p = NULL,
i = 1L,
j = 1L,
zero_diagonal = FALSE
)
Arguments
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 = |
Details
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.
Value
An updated object of class "clsp".
Attributes Set
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.
Convex Least Squares Programming (CLSP) estimator
Description
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.
Usage
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,
...
)
Arguments
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
|
... |
Optional. Additional arguments passed to the CVXR solver backend. |
Details
This estimator unifies pseudoinverse-based least squares with convex
programming correction. The pseudoinverse step computes an initial solution
\mathbf{z}^{(r)} iteratively via the Moore–Penrose or Bott–Duffin
inverse. The convex step then refines \boldsymbol{z} by minimizing a
mixed \ell_1/\ell_2 norm under equality constraints
\mathbf{A}\mathbf{z} = \mathbf{b}. The method supports allocation
problems (AP), constrained modular least squares (CMLS), and general CLSP
formulations.
Value
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.
Compute the structural correlogram of the CLSP constraint system.
Description
This method performs a row-deletion sensitivity analysis on the canonical
constraint matrix [C | S], denoted as C_{\text{canon}}, and
evaluates the marginal effect of each constraint row on numerical stability,
angular alignment, and estimator sensitivity.
Usage
corr(object, reset = FALSE, threshold = 0)
Arguments
object |
An object of class |
reset |
Logical, default = |
threshold |
Numeric, default = |
Details
For each row i in C_{\text{canon}}, it computes:
The Root Mean Square Alignment (
\mathrm{RMSA}_i) with all other rowsj \ne i.The change in condition numbers
\kappa(C),\kappa(B), and\kappa(A)when rowiis deleted.The effect on estimation quality: changes in NRMSE,
\hat{z},z, andx.
Additionally, it computes the total RMSA statistic across all rows, summarizing the overall angular alignment of the constraint block.
Value
A named list containing per-row diagnostic values:
- constraint
Vector of constraint indices (1-based).
- rmsa_i
List of
\mathrm{RMSA}_ivalues.- rmsa_dkappaC
List of
\Delta\kappa(C)after deleting row i.- rmsa_dkappaB
List of
\Delta\kappa(B)after deleting row i.- rmsa_dkappaA
List of
\Delta\kappa(A)after deleting row i.- rmsa_dnrmse
List of
\Delta\mathrm{NRMSE}after deleting row i.- rmsa_dzhat
List of
\Delta\hat{z}after deleting row i.- rmsa_dz
List of
\Delta zafter deleting row i.- rmsa_dx
List of
\Delta xafter deleting row i.
Perform bootstrap or Monte Carlo t-tests on the NRMSE statistic from the CLSP estimator.
Description
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.
Usage
ttest(
object,
reset = FALSE,
sample_size = 50L,
seed = NULL,
distribution = NULL,
partial = FALSE,
simulate = FALSE
)
Arguments
object |
An object of class |
reset |
Logical, default = |
sample_size |
Integer, default = |
seed |
Integer or |
distribution |
Function or |
partial |
Logical, default = |
simulate |
Logical, default = |
Value
A named list containing test results and null distribution statistics:
- p_one_left
P(nrmse
\lenull mean)- p_one_right
P(nrmse
\genull mean)- p_two_sided
2-sided t-test p-value
- nrmse
Observed value
- mean_null
Mean of null distribution
- std_null
Standard deviation of null distribution