Skip to content

Orthogonal Nonlinear Least-Squares Regression

0packages dependsuggested by 1
7.4Kdownloads / year
–test coverage
13/13flavors OK

Overview

About

Fits n-dimensional data by means of orthogonal nonlinear least-squares using Levenberg-Marquardt minimization and provides functionality for fit diagnostics and plotting. Delivers the same results as the 'ODRPACK' Fortran implementation described in Boggs et al. (1989) doi:10.1145/76909.76913, but is implemented in pure R.

Changes in 0.2

MAJOR UPDATE: one-pass (ODRPACK-style) algorithm and multivariateness:

  • replaced the nested two-step algorithm (inner foot-point optimization for every observation, outer optimization of the parameters, using L-BFGS-B for foot points when p > 1) by a one-pass algorithm in the manner of ODRPACK: the parameters and all foot-point corrections delta_i are estimated simultaneously by a single Levenberg-Marquardt run (minpack.lm::nls.lm) on the joint problem, minimizing the same objective as ODRPACK, sum[ Qyy_i * (y_i - f(x_i + delta_i, theta))^2 + delta_i' * Qx_i * delta_i ], with Qyy and Qx corresponding to ODRPACK's WE and WD
  • the same code path now handles any number of predictors (single predictor, multivariate, correlated predictor errors); the foot points are no longer found by a separate inner optimizer, and orthogonality of the foot points is now the stationarity condition of the joint problem
  • the Jacobian of the joint problem is now supplied to the solver exactly, using symbolic derivatives of the model formula (deriv()) and falling back to central finite differences if the formula cannot be differentiated (e.g. calls to user-defined functions). MINPACK's internal forward-difference Jacobian is unsuitable here, because its step is proportional to the size of each unknown and vanishes for small foot-point corrections, which stalled foot points at their observations (non-orthogonal points, e.g. for the last point of the odrpack guide example 2.C.i)
  • control$outer_max is now the total budget of Levenberg-Marquardt iterations (default 5000). As minpack.lm silently caps a single nls.lm call at 1024 iterations, the solver is restarted from its last iterate until it converges, a restart brings no further improvement, or the budget is used up
  • new control elements ftol and ptol (convergence tolerances, default 1e-10 instead of sqrt(.Machine$double.eps), which left points with very small residuals slightly non-orthogonal), diag (optional parameter scaling, MINPACK's adaptive scaling is now the default) and lower/upper as alternatives to the arguments of the same name
  • extend and window now default to NULL, i.e. foot points are unbounded as in ODRPACK. They remain available as optional foot-point bounds for single-predictor models (window only together with extend)
  • the covariance matrix of the parameters is now the ODRPACK (Gauss-Newton) covariance, i.e. the parameter block of the inverse of J'J of the joint problem, evaluated with effective-variance weights w_i = 1/(1/Qyy_i + g_i' * Qx_i^-1 * g_i) with g_i = df/dx at the foot point. This is valid for any number of predictors (the previous multivariate version ignored the predictor error in the standard errors)
  • the NLS warm start now substitutes fixed parameters into the model formula instead of fitting them freely and resetting them afterwards, and no longer fails silently when weights are supplied (the weights were not found by nlsLM, so the raw starting values were used instead)
  • onls() now warns if some free parameters have no measurable influence on the fitted model (e.g. a sigmoid that has collapsed to a constant because its exponent underflows), a degenerate stationary point at which the solver may report convergence
  • the model formula is now evaluated in its own environment, so that user-defined functions and constants used in the model are found; the model is evaluated once at the starting values and errors are reported instead of being swallowed
  • extended the core algorithm from single-predictor to n-dimensional (multivariate) models
Show all changes in 0.2Hide the rest of the changes in 0.2
  • added support for weighted/heteroscedastic orthogonal regression via new sigma_x, sigma_y and known_sigma arguments (scalar, per-predictor vector, full p x p covariance matrix, or observation-specific standard deviations)
  • check_o() now automatically switches from the tangent-angle criterion to a KKT-residual criterion for weighted fits, and checks multivariate models one predictor axis at a time
  • check_o() no longer returns NaN if a foot point coincides with its observation (dx = 0, e.g. where the model slope is zero): the angle is now computed as atan2(|m*dx - dy|, |dx + m*dy|), which is algebraically identical to the old formula but avoids the division by dx. Observations lying on the fitted curve are reported with alpha = NA and Ortho = TRUE
  • check_o() gained the arguments tol_deg (default 0.05 degrees) and tol_kkt (default 0.001) for the orthogonality tolerances, and now computes its slopes itself (central differences, evaluated in the environment of the model formula) instead of relying on internal helper functions
  • plot.onls() gained an interactive 3D rgl-based plot for two-predictor models and a grid of partial-dependence panels (selectable via new panel argument) for more than two predictors
  • plot.onls() gained an asp argument to toggle the 1:1 axis-ratio enforcement used to visually verify orthogonality, and now auto-derives a matching range when only xlim or ylim is supplied
  • logLik_o() now includes a Jacobian/normalizing-constant correction for response/predictor precisions, so AIC()/BIC() from it are valid across onls() fits with different weighting schemes
  • confint.onls() now explicitly conducts bootstrap confidence interval estimation on the orthogonal residuals.
  • fixed a diagonal p x p sigma_x matrix giving wrong (partly zero) predictor precisions
  • fixed weights, sigma_x and sigma_y given as vectors not following subset and na.action (only a sigma_x matrix did)
  • fixed residuals_o() returning values in sorted-predictor order instead of original observation order, which also misaligned NA reinsertion via na.action
  • fixed summary.onls() reporting Std. Error/t value/Pr(>|t|) as 0/Inf/a wrong p-value for fixed parameters instead of NA, and computing cov.unscaled from the vertical- instead of the orthogonal-residual variance
  • fixed check_o() using the wrong sign in its KKT-residual computation for multivariate weighted models, and now correctly realigns precisions to sorted-predictor order for single-predictor models
  • fixed vcov.onls() rescaling the covariance matrix by the vertical- instead of the orthogonal-residual variance
  • fixed logLik.onls() scaling the weight-correction term by n/2 instead of 0.5, affecting AIC()/BIC() for any fit with non-constant weights
  • fixed predict.onls() erroring on se.fit/prediction intervals for models with fixed parameters
  • fixed profile.onls() silently treating originally-fixed parameters as free while profiling other parameters
  • deviance_o(), residuals_o() and print.onls() now report general precision-weighted orthogonal distances rather than assuming plain Euclidean distance
  • removed the ..., jac and verbose arguments from onls() (trace already covered progress reporting; the Jacobian is now always supplied internally)
  • data is no longer optional in onls() (previously defaulted to parent.frame())
  • onls() now stops with an informative error if the response is not a plain variable name, if all parameters are fixed, or if lower/upper do not have one value per parameter
  • clarified that multivariate formulas must use explicit classical notation (y ~ b0 + b1*x1 + b2*x2) rather than R shorthand (y ~ x1 + x2)
  • rewrote onls.Rd to describe the one-pass algorithm with its mathematics (objective, joint residual vector and Jacobian structure, stationarity conditions, covariance), updated check_o.Rd, and corrected the value of the bounded fit in example 6 (1.4376 / 0.9)
  • added new reference-check examples to onls() (Total Least Squares closed-form comparison, Pearson/York weighted regression, Daeron & Vermeesch 2024, control settings) and new 3D/multivariate examples to plot.onls()

From NEWS in the release

Install

Health

CRAN checks
13OK
Slowest check: 1.9 min · r-oldrel-windows-x86_64
Status changes
  • OK13 OK2026-08-05
  • NOTE12 OK, 1 NOTE2026-08-01
  • OK14 OK2026-03-10
Advisories

none known

Documentation

In release 0.2
READMENoVignettesYes · 1 · dynamicNEWSYes · 33% structured · mentions 0.2Citation fileNoWebsitenot declared in DESCRIPTION
Help pages
11
Examples that run
45%5 run in a plain check · 2 only when donttest examples are enabled (R CMD check --as-cran) · 4 hold no code
Exported functions with examples
100%
Documented parameters
100%
Return-value docs
100%
Help pages citing references
9%

Downloads

7.4K
CRAN downloads in the past year
Rank #4,282 · ~20/day · ~618/mo
Daily download trend is not available in this view yet.
62930 days
2K90 days
7.4K1 year
Compare downloads with other packages →
Also on111 r2u5 autocran167 c2d4u

Dependencies

Declared dependencies
4 external dependencies (excludes base and recommended)

Installing onls adds 29 packages (17 with compiled code, 23 MB of source tarballs). Heaviest: bslib 5.6 MB, rgl 4.0 MB, sass 2.9 MB.

Depends (3)
R >= 2.13.0minpack.lmrgl
Imports (0)
none
LinkingTo (0)
none
Suggests (2)
Enhances (0)
none
Reverse dependencies
0direct
0indirect
Suggested by 1
Suggests, most downloaded first

People & History

People (1)
Author, Maintainer · added in 0.1-2

Maintainer since 0.1-0 (2015)

Releases (6)

Pick two releases to compare their code metrics.

  • 0.2Latest
    record
    2026-09-21 · current release · diff ↗
  • R
    R 4.6.0 released · 2026-04-24
  • 0.1-4
    record
    2025-09-01 · diff ↗
  • 0.1-3
    record
    2025-08-20 · diff ↗
  • R
    R 4.5.0 released · 2025-04-11
  • R
    R 4.4.0 released · 2024-04-24
  • R
    R 4.3.0 released · 2023-04-21
  • unarchivedReturned to CRAN
    2022-10-31
  • 0.1-2
    record
    2022-10-31 · diff ↗ ·
    added 1 export
    NIST
  • archivedRemoved from CRAN
    2022-05-06
    email to the maintainer was undeliverable
  • R
    R 4.2.0 released · 2022-04-22
  • R
    R 4.1.0 released · 2021-05-18
  • R
    R 4.0.0 released · 2020-04-24
  • R
    R 3.6.0 released · 2019-04-26
  • R
    R 3.5.0 released · 2018-04-23
  • R
    R 3.4.0 released · 2017-04-21
Show 5 earlier eventsHide 5 earlier events
  • R
    R 3.3.0 released · 2016-05-03
  • 0.1-1
    record
    2015-09-09 · diff ↗
  • R
    R 3.2.0 released · 2015-04-16
  • 0.1-0
    record
    2015-01-17
  • R
    R 3.1.0 released · 2014-04-10

Package metadata

First published
2015-01-17
Total releases
6 / 11 yrs
License
GPL (>= 2) OSI
Minimum R
≥ 2.13.0
Download size
152 KB

Cite

Cite this package

Run in R for the authors' preferred citation:

citation("onls")
Andrej-Nikolai Spiess. (2026). onls: Orthogonal Nonlinear Least-Squares Regression (Version 0.2) [Computer software]. https://doi.org/10.32614/CRAN.package.onls

This package has no citation file, so citation() returns this entry built from DESCRIPTION.

Cite the R Observatory

For a number measured here: a download total, a coverage figure, an archival date.

APA

Balamuta, J. J. (2026). R Observatory: Metrics for onls version 0.2 [Data set]. HJJB, LLC. Data release v2026-10-25. https://doi.org/10.5281/zenodo.21843040

From data release v2026-10-25, which the citation names so these numbers can be found later. More on citing and the projects behind them.

Report a problem with this page →

Privacy choices

These apply to this browser and are stored on this device only. Nothing about your choice is sent to us.

Read the privacy policy