Rdistance v4.4.0 on CRAN now
Enhancements to distance analysis package Rdistance are on CRAN
R
Distance Analysis
A new version of Rdistance, version 4.4.0, is on CRAN now. Since I last blogged on Rdistance (May 2025), many updates, bug fixes, and enhancements have taken place. This blog post summarises the changes between Rdistance version 4.0.3 and 4.4.0.
Functionality Changes
- Added the
triangledistance function, a mixture of triangle and uniform distributions. Seehelp(triangle.like)examples. - Added the
huberdistance function, a mixture of an inverted version of Huber loss and a uniform distribution. Seehelp(huber.like)for examples, and the Huber Distance Functions tutorial for more information. - Added the
oneStepdistance function, a mixture of non-overlapping uniform densities. This required inclusion of a new gradient-free optimizer because theoneSteplikelihood is not smooth. - Implemented use of
stats::optimfor optimization. This change allows Rdistance to use the gradient-free Nelder-Mead optimizer to maximize certain non-smooth likelihoods (i.e.,oneStep,triangle, andhuber) - Version 4.3.0 added parallel bootstrap processing for confidence interval estimation. Bootstrap resampling to compute confidence intervals can take considerable time and running in parallel, on multiple CPU cores, speeds things up. Parallel processing is handled by
multidplyr. Default is to run bootstraps in parallel on n-1 CPU cores, where n is the number of cores available on the local machine . No progress bar is produced during parallel processing. Disable parallel processing by settingparallel = FALSEin call toabundEstim. Run on a specific number of cores by settingparallelto that number (e.g.,parallel = 3uses three cores). I have one report from a user thatparallel = TRUEwill not work on some versions of maxOS due to issues withmultidplyr. - Added the
Gammalikelihood back into the suite of likelihoods available in Rdistance. TheGammawas removed during the big re-vamp of version 4.0.3. The Gamma likelihood works for both lines and points. It works with both covariates and expansions. - Implemented reporting of bootstrap coefficient standard errors, after bootstrap resampling is complete. Prior to bootstrapping, asymptotic se’s are reported when known. After bootstrapping, default standard errors come from the bootstap samples.
- Included unit assignment helpers. Units can now be assigned with the
%#%operator (e.g., 3 %#% “m”), which makes unit assignment easier than in prior versions (which usedunits::set_units). Fixed unit assignment operators are included for all popular linear and squared units (e.g., 3 %m%. assigns meters to 3). Seehelp(unitHelpers). - Included b-spline expansion factors for distance functions. Expansion factors are now
cosine,hermite,simple, andbspline. - Added verbosity control. Verbosity prints intermediate parameter estimates and likelihoods during maximization. Set
options(Rdistance_verbocity = 1)or higher to see progressively more detailed intermediate output. The highest verbosity level,options(Rdistance_verbocity = 5), pauses each iteration for user inspection. - Implemented exact likelihood integration when known to significantly decrease computation time. All likelihoods for both lines and points that do not contain expansions use exact integration, which is much quicker than numerical integration. Numeric integration is used only when necessary (because I couldn’t work out the integral).
Documentation Changes
Are too numerous to list. My hope is that the documentation becomes more clear with every version.
I moved all the Rdistance examples and vignettes to a set of tutorials on the McDonald Data Science website. I have more control over examples there, they are indexed by date and keyword, and they look better.
Bug Fixes
- Version 4.3.0 contained a major bug. That version (in the wild for about a week in February 2026), incorrectly reported ESW when scaling factors (
g.x.scl) were less than 1.0. Versions <=4.1.0 reported correct ESW, and ESW reported by 4.3.0 was correct wheng.x.sclequaled 1.0 (the default). Version 4.3.1 corrected this bug. - Several other non-critical bugs have been corrected.
- The default value for
w.lowas changed inparseModelto suppress warning aboutx.scl<w.lo(not really a bug, just annoying).
