pls_diagnostic_q — Q residual (squared prediction error)¶
Group: Diagnostic · Registry tolerance: 1e-08
Description¶
PLS Q residuals / SPE (§9)
Registry note — R
mdatools::pls$xdecomp$Q. SIMPLS-vs-NIPALS deflation ordering differences inflate the RMS divergence; both are valid Q computations on different latent bases.
Parameters¶
Name |
Type |
Default |
Notes |
|---|---|---|---|
|
|
|
registry benchmark cell value |
Explanations¶
Bibliographic source¶
Jackson, J. E. & Mudholkar, G. S. (1979). Control procedures for residuals associated with principal component analysis. Technometrics 21(3), 341–349. Verified primary link: https://doi.org/10.1080/00401706.1979.10489779.
Mathematical principle¶
Q (also called SPE — Squared Prediction Error) is the sum of squared residuals between \(\mathbf{x}\) and its PLS reconstruction \(\hat{\mathbf{x}} = \mathbf{T}\mathbf{P}^{\top}\): \(Q_i = \|\mathbf{x}_i - \mathbf{t}_i \mathbf{P}^{\top}\|_2^2 = \sum_j (x_{ij} - \hat{x}_{ij})^2\). It measures the part of \(\mathbf{x}\) that lies orthogonal to the latent space — variation in the predictor that the model could not capture.
Under the assumption of Gaussian residuals, Jackson & Mudholkar (1979) derived a parametric upper control limit. High Q with low T² typically signals a sample with a fundamentally different spectral fingerprint from the calibration set (e.g. contamination, instrument failure); low Q with high T² signals an extreme combination of otherwise normal features.
Reported per-sample as a 1-D vector aligned with the rows of the input.
Appropriate uses¶
Flagging spectra poorly reconstructed by the retained latent X subspace.
Limits and validation¶
Q residuals do not detect all high-leverage points and are sensitive to preprocessing and component count.
Implementation¶
n4m_metrics_pls_diagnostics_compute with stat=’q’. Reference: R mdatools 0.15.0.
Sources and provenance¶
Current implementation: cpp/src/core/pls_diagnostics.cpp.
API and bindings¶
C ABI (ABI 2): n4m_metrics_pls_diagnostics_compute. Use the linked public header for the exact signature, configuration, and result handles.
Python: no current AST-verified public n4m re-export was found for this method. The linked C ABI above is the documented surface in this checkout.
R: no current source-verified entry point was found for this catalog method.
MATLAB / Octave: no current source-verified entry point was found for this catalog method.
Registry parity references 📐
📐
ref.r_mdatools(R · r) —mdatools0.15.0 · strict (rmse_rel ≤ 1e-08) — Rmdatools::plswithpredict()$xdecomp$T2 / $Q. DModX is derived locally from $Q + DOF. mdatools uses different SIMPLS deflation / normalization conventions than pls4all, so cross-implementation parity is qualitative.
Benchmarks¶
Archived measurement identity. Backend labels in this table are the raw IDs recorded when the benchmark ran (including historical pls4all.* IDs). They preserve measurement provenance and do not describe a current public Python, R, or MATLAB binding; use the source-verified API and bindings section above for current entry points.
Adaptive wall-clock per cell measured against full_matrix.csv. Only backends that implement this method are listed; libraries without the method are omitted.
Verdict · ✓ ref / ≈ ref / ~ shape mark a reference-gate pass at strict / relaxed / qualitative tolerance · ✓ bind = archived binding-harness result agrees with the C++ baseline · ⇄ cross-check = documented by-design selector/RNG/model, noncanonical API/facade convention, or secondary oracle · ✗ divergent · ⚠ error · — not run. The fastest backend per column is marked 🏆.
Reference gate: strict — numeric equivalence (rmse_rel_tol ≤ 1e-08).
Rows tagged with 📐 are the canonical parity references for this method (declared in parity_timing.registry). C++ and external rows show reference parity; archived language-harness rows show binding parity against the C++ backend. Hover the icon for role and tolerance band.
| Backend | Parity | 200×30 (ms) |
|---|---|---|
| C++ native · libn4m | ||
pls4all.cpp.blas+omp | ✓ ref 1e-15 | 1.22 ms |
| Python · archived pls4all benchmark | ||
pls4all.python | ✓ bind | 1.19 ms🏆 |
pls4all.sklearn | ✓ bind | 1.30 ms |
| R · archived pls4all benchmark | ||
pls4all.R | ✓ 3e-14 | 3.10 ms |
pls4all.R.formula | ✓ 3e-14 | 3.57 ms |
pls4all.R.mdatools | ✓ 3e-14 | 3.96 ms |
pls4all.R.pls | ✓ 3e-14 | 3.47 ms |
| R · external | ||
📐ref.r_mdatools | source | 13.8 ms |
| Backend | Parity | 200×30 (ms) |
|---|---|---|
| C++ native · libn4m | ||
pls4all.cpp.blas+omp | ✓ ref 1e-15 | 1.21 ms |
| Python · archived pls4all benchmark | ||
pls4all.python | ✓ bind | 1.21 ms🏆 |
pls4all.sklearn | ✓ bind | 1.27 ms |
| R · archived pls4all benchmark | ||
pls4all.R | ✓ 3e-14 | 3.11 ms |
pls4all.R.formula | ✓ 3e-14 | 3.59 ms |
pls4all.R.mdatools | ✓ 3e-14 | 3.52 ms |
pls4all.R.pls | ✓ 3e-14 | 3.64 ms |
| R · external | ||
📐ref.r_mdatools | source | 14.9 ms |
| Backend | Parity | 200×30 (ms) |
|---|---|---|
| C++ native · libn4m | ||
pls4all.cpp.blas+omp | ✓ ref 1e-15 | 1.23 ms |
| Python · archived pls4all benchmark | ||
pls4all.python | ✓ bind | 1.22 ms🏆 |
pls4all.sklearn | ✓ bind | 1.36 ms |
| R · archived pls4all benchmark | ||
pls4all.R | ✓ 3e-14 | 3.28 ms |
pls4all.R.formula | ✓ 3e-14 | 3.83 ms |
pls4all.R.mdatools | ✓ 3e-14 | 3.89 ms |
pls4all.R.pls | ✓ 3e-14 | 3.74 ms |
| R · external | ||
📐ref.r_mdatools | source | 15.5 ms |
See also: benchmark overview · methods index · interactive dashboard