Package: n4m 0.99.0

Gregory Beurier

n4m: Portable Partial Least Squares and NIRS Engine

Implements a portable Partial Least Squares (PLS) and Near-Infrared Spectroscopy (NIRS) engine. Provides fit/predict wrappers for the shipped PLS regression solvers (NIPALS, SIMPLS, SVD, kernel, wide-kernel, orthogonal-scores, power, randomized SVD, PCR), variants (sparse SIMPLS, CPPLS, weighted, robust, ridge, continuum, multi-block, GLM, MIR), adaptive AOM-PLS and POP-PLS operator selection, variable-selection methods (SPA, CARS, GA, random frog, stability selection, VIP), diagnostics (Hotelling T2, Q residuals, DModX), and calibration transfer (PDS, DS). The C++17 implementation is vendored and compiled from source at install time; no external system libraries are required.

Authors:Gregory Beurier [aut, cre], pls4all contributors [ctb]

n4m_0.99.0.tar.gz
n4m_0.99.0.zip(r-4.7)n4m_0.99.0.zip(r-4.6)n4m_0.99.0.zip(r-4.5)
n4m_0.99.0.tgz(r-4.6-x86_64)n4m_0.99.0.tgz(r-4.6-arm64)n4m_0.99.0.tgz(r-4.5-x86_64)n4m_0.99.0.tgz(r-4.5-arm64)
n4m_0.99.0.tar.gz(r-4.7-arm64)n4m_0.99.0.tar.gz(r-4.7-x86_64)n4m_0.99.0.tar.gz(r-4.6-arm64)n4m_0.99.0.tar.gz(r-4.6-x86_64)
n4m_0.99.0.tgz(r-4.6-emscripten)
manual.pdf |manual.html
card.svg |card.png
n4m/json (API)

# Install 'n4m' in R:
install.packages('n4m', repos = c('https://gbeurier.r-universe.dev', 'https://cloud.r-project.org'))

Bug tracker:https://github.com/gbeurier/nirs4all-methods/issues

Uses libs:
  • c++– GNU Standard C++ Library v3

On CRAN:

Conda:

cpp

4.48 score 15 stars 5 scripts 105 exports 0 dependencies

Last updated from:288e2a8880. Checks:13 OK. Indexed: yes.

TargetResultTimeFilesSyslog
linux-devel-arm64OK192
linux-devel-x86_64OK200
source / vignettesOK352
linux-release-arm64OK209
linux-release-x86_64OK165
macos-release-arm64OK245
macos-release-x86_64OK405
macos-oldrel-arm64OK224
macos-oldrel-x86_64OK545
windows-develOK300
windows-releaseOK286
windows-oldrelOK267
wasm-releaseOK198

Exports:aom_plsaom_preprocessaomplsapproximate_pressbagging_plsbagging_pls_fitbipls_selectboosting_plsboosting_pls_fitbve_selectcars_selectcoefficient_selectcontinuum_regressioncontinuum_regression_fitcpplscppls_fitdi_plsdi_pls_fitds_fitecrecr_fitemcuve_selectfused_sparse_pls_fitga_selectgpr_pls_fitgroup_sparse_pls_fitinterval_selectipw_selectirf_selectiriv_selectkennard_stone_splitkernel_pls_fitlw_pls_fitmb_plsmb_pls_fitmir_plsmir_pls_fitmissing_aware_nipalsmissing_aware_nipals_fitMSEPmvrn_pls_fitn4m_abi_versionn4m_fitn4m_methodn4m_predictn4m_versiono2plso2pls_fiton_pls_fitone_se_ruleoplspcrpds_fitplspls_cox_fitpls_diagnosticspls_glmpls_glm_fitpls_lda_fitpls_logistic_fitpls_mdatoolspls_monitoringpls_qda_fitplsrpop_plspopplspso_selectR2random_frog_selectrandom_subspace_plsrandom_subspace_pls_fitrandomization_selectrecursive_plsrecursive_pls_fitrep_selectridge_plsridge_pls_fitRMSEProbust_plsrobust_pls_fitrosa_fitsavgol_transformscars_selectselectivity_ratio_selectselectNcompshaving_selectsipls_selectsnv_transformso_pls_fitspa_selectsparse_plssparse_pls_da_fitsparse_simpls_fitst_selectstability_selectt2_selectuve_selectvip_selectvip_spa_selectvissa_selectweighted_plsweighted_pls_fitwvc_selectwvc_threshold_select

Dependencies:

Introduction to n4m

Rendered fromn4m.Rmdusingknitr::knitron Jun 12 2026.

Last update: 2026-05-28
Started: 2026-05-23

Readme and manuals

Help Manual

Help pageTopics
AOM-PLS and POP-PLS adaptive operator selectionaompls aom_pls poppls pop_pls
Adaptive Operator-Mixture preprocessing fit/transform.aom_preprocess
Approximate-PRESS component selection.approximate_press
Bagging PLS — formula entry point.bagging_pls
Bagging PLS (bootstrap aggregation of PLS regressors).bagging_pls_fit
biPLS — backward interval PLS.bipls_select
Boosting PLS — formula entry point.boosting_pls
Boosting PLS (stage-wise refit with learning_rate).boosting_pls_fit
BVE-PLS.bve_select
CARS — Competitive Adaptive Reweighted Sampling.cars_select
Extract the regression coefficients of a [pls()]-fitted model.coef.n4m_fit
Coefficient-magnitude ranker.coefficient_select
Continuum regression — formula entry point.continuum_regression
Continuum regression (tau in [0, 1]).continuum_regression_fit
Canonical Powered PLS — formula entry point.cppls
Canonical Powered PLS fit (Indahl 2005).cppls_fit
Domain-invariant PLS - formula entry point.di_pls
Domain-Invariant PLS (Nikzad-Langerodi 2018).di_pls_fit
Direct Standardization (calibration transfer).ds_fit
Elastic Component Regression — formula entry point.ecr
Elastic Component Regression (Liu 2009/2010).ecr_fit
EMCUVE — ensemble Monte Carlo UVE.emcuve_select
Fused-sparse PLS (L1 + adjacent-coef smoothing).fused_sparse_pls_fit
GA-PLS — genetic algorithm variable selection.ga_select
Gaussian Process Regression on PLS scores (single-target Y).gpr_pls_fit
Group-sparse PLS (group L1 across feature groups).group_sparse_pls_fit
Interval selector (iPLS).interval_select
IPW-PLS.ipw_select
IRF — Interval Random Frog.irf_select
IRIV — Iteratively Retains Informative Variables.iriv_select
Kennard-Stone train/test splitkennard_stone_split
Non-linear kernel PLS (Rosipal & Trejo 2001).kernel_pls_fit
Locally-weighted PLS (Næs & Centner 1998).lw_pls_fit
Multi-block PLS — formula entry point.mb_pls
Multi-block PLS (block-weighted SIMPLS).mb_pls_fit
MIR-PLS — formula entry point.mir_pls
MIR-PLS — Multivariate Inverse Regression PLS.mir_pls_fit
Missing-aware NIPALS — formula entry point.missing_aware_nipals
Missing-aware NIPALS PLS (Nelson 1996).missing_aware_nipals_fit
N-PLS (3-way tensor) regression. `X_flat` is the flattened (n, mode_j*mode_k) matrix.n_pls_fit
Loaded ABI version as an integer vector (major, minor, patch).n4m_abi_version
Fit a PLS regression model via the libn4m C ABI.n4m_fit
Low-level n4m method dispatcher.n4m_method
Predict with a fitted n4m model.n4m_predict
Runtime version string of the loaded libn4m.n4m_version
O2-PLS — formula entry point (uses n_predictive for component count).o2pls
O2-PLS (bi-directional OPLS).o2pls_fit
OnPLS — Orthogonal multi-block PLS (joint + unique loadings).on_pls_fit
One-SE rule from a (max_components × n_folds) fold RMSE matrix.one_se_rule
Formula-based OPLS regression wrapper around the n4m C ABI.opls
Piecewise Direct Standardization (calibration transfer).pds_fit
Formula-based PLS regression wrapper around the n4m C ABIpls
PLS-Cox proportional hazards.pls_cox_fit
PLS diagnostics: T², Q, DModX from a fitted model.pls_diagnostics
PLS-GLM — formula entry point. Default is Gaussian; set `family = "poisson"` for Poisson IRLS.pls_glm
PLS-GLM — Gaussian (default) or Poisson IRLS.pls_glm_fit
PLS-LDA — Linear Discriminant Analysis on PLS scores.pls_lda_fit
Multinomial logistic regression on PLS scores.pls_logistic_fit
mdatools-style matrix PLS interfacepls_mdatools predict.n4m_mdatools_pls
PLS process monitoring (Hotelling T² + Q with alarms).pls_monitoring
PLS-QDA (Quadratic Discriminant Analysis on PLS scores).pls_qda_fit
PLS package compatibility facadecoef.n4m_mvr MSEP mvr pcr plsr predict.n4m_mvr R2 RMSEP selectNcomp
Predict from a [pls()]-fitted model.predict.n4m_fit
Predict from a MethodResult-based n4m fit.predict.n4m_method_fit
PSO-PLS (Binary Particle Swarm Optimization).pso_select
Random Frog (Phase 5g).random_frog_select
Random-subspace PLS — formula entry point.random_subspace_pls
Random-subspace PLS (Ho 1998).random_subspace_pls_fit
Randomization test selector.randomization_select
Recursive PLS - formula entry point.recursive_pls
Moving-window recursive PLS.recursive_pls_fit
REP-PLS.rep_select
Ridge PLS — formula entry point.ridge_pls
L2-augmented PLS regression.ridge_pls_fit
Robust PLS — formula entry point.robust_pls
Robust PLS via Huber IRLS.robust_pls_fit
ROSA — Response-Oriented Sequential Alternation.rosa_fit
SCARS — Stability + CARS.scars_select
Selectivity-ratio ranker.selectivity_ratio_select
Shaving selector.shaving_select
siPLS — synergistic interval PLS.sipls_select
Portable preprocessing transformssavgol_transform snv_transform
Sequential & Orthogonalised multi-block PLS (Næs et al. 2011). `block_sizes` integer vector summing to ncol(X); `n_components_per_block` integer vector of same length.so_pls_fit
SPA — Successive Projections Algorithm.spa_select
Sparse SIMPLS — formula entry point.sparse_pls
Sparse PLS-DA classifier (`y_labels` is an integer vector of class IDs).sparse_pls_da_fit
Sparse SIMPLS fit.sparse_simpls_fit
ST-PLS — score-threshold selector.st_select
Stability selector (coefficient stability, MCUVE-style).stability_select
T2-PLS - sweep over alpha thresholds.t2_select
UVE — Uninformative Variable Elimination.uve_select
VIP (Variable Importance in Projection) ranker.vip_select
VIP-SPA hybrid selector.vip_spa_select
VISSA — Variable Iterative Space Shrinkage Approach.vissa_select
Sample-weighted PLS — formula entry point.weighted_pls
Sample-weighted PLS (sqrt(w)-prescaled SIMPLS).weighted_pls_fit
WVC-PLS — weighted vector correlation top-k selector.wvc_select
WVC-threshold selector.wvc_threshold_select