Distributions Compatible with Automatic Differentiation by 'RTMB'
Overview
Extends the functionality of the 'RTMB' https://kaskr.r-universe.dev/RTMB package by providing a collection of non-standard probability distributions compatible with automatic differentiation (AD). While 'RTMB' enables flexible and efficient modelling, including random effects, its built-in support is limited to standard distributions. The package adds additional AD-compatible distributions, broadening the range of models that can be implemented and estimated using 'RTMB'. Automatic differentiation and Laplace approximation are described in Kristensen et al. (2016) doi:10.18637/jss.v070.i05.
- Added the Johnson SU distribution in both the original parameterisation (
djsu(),pjsu(),qjsu(),rjsu()) and the moment parameterisation (djsu2(),pjsu2(),qjsu2(),rjsu2()), a four-parameter distribution on the real line covering a wide range of skewness and kurtosis. Indjsu2()the location and scale arguments are exactly the mean and standard deviation. The density and distribution function are both differentiable, so simulation and one-step-ahead residuals are supported. Unlikegamlss.dist, the reparameterisation stays finite for very largetau, where the distribution approaches the normal. - Added references to the primary source for each distribution derived from
gamlss.dist, and cross-links between related families.pgenpois()and friends previously had no references at all. - Removed the dependency on
gamlss.dist, which is scheduled for archival on CRAN. The quantile and random generation functions of the Box-Cox Cole-Green (qbccg(),rbccg()), Box-Cox *t* (qbct(),rbct()), Box-Cox power exponential (qbcpe(),rbcpe()), power exponential (qpowerexp(),rpowerexp(),qpowerexp2(),rpowerexp2()), Pareto (qpareto(),rpareto()), generalised Poisson (pgenpois(),qgenpois(),rgenpois()) and exponentially modified Gaussian (qexgauss()) distributions are now implemented natively. Results are unchanged except for the fixes below. - Fixed argument recycling in
qbccg(),qbct(),qbcpe(),qgenpois()andpgenpois(). Evaluating a single quantile against vectorised parameters previously collapsed the result to length one, and a parameter vector shorter thanxsilently truncated it. These functions now return one value per recycled argument tuple. - Fixed
qbct()andrbct(), which failed with an error whenmu,sigmaortauwas supplied as a vector. qpareto()now honourslower.tail, which was previously accepted but ignored.log.p = TRUEnow works inqpareto(),qbct()andqgenpois(). These previously validatedpbefore transforming it back from the log scale, so the argument could not be used.qexgauss()is substantially more accurate. It invertspexgauss()with a tighter convergence tolerance, reducing the round-trip error|p(q(p)) - p|from roughly 1e-6 to roughly 1e-14.pgenpois()no longer falls back to the Poisson distribution forphi < 1e-4and evaluates the generalised Poisson distribution function across the whole parameter range.pbetaprime(),pinvchisq()andpinvgamma()are now differentiable, so one-step-ahead residuals viamethod = "cdf"are available for the beta prime, inverse chi-squared and inverse gamma distributions.- Added the Bell distribution (
dbell(),pbell(),qbell(),rbell()) and its mean parameterisation (dbell2(),pbell2(),qbell2(),rbell2()), a one-parameter distribution for overdispersed counts. Log Bell numbers are used throughout and cached, so the density stays finite well past the point at which the Bell numbers themselves overflow double precision. One-step-ahead residuals are supported viamethod = "cdf". - Added
lambertW(), an AD-compatible implementation of the principal branch of the Lambert W function. Derivatives of all orders are exact, so it can be used in models fitted by Laplace approximation.
Show all changes in 1.1.0Hide the rest of the changes in 1.1.0
- Added the Conway-Maxwell-binomial distribution (
dcombinom(),pcombinom(),qcombinom(),rcombinom()), a binomial generalisation with an additional dispersion parameternu. The density and distribution function are differentiable with respect tox, so one-step-ahead residuals are supported.
From NEWS.md in the release
Install
Health
- OK13 OK2026-08-05
- NOTE12 OK, 1 NOTE2026-08-01
- OK7 OK2026-07-23
- ERROR11 OK, 1 ERROR2026-04-25
- OK14 OK2026-03-10
Documentation
- Help pages
- 79
- Examples that run
- 100%79 run in a plain check
- Exported functions with examples
- 100%
- Documented parameters
- 66%
- Return-value docs
- 100%
- Help pages citing references
- 16%
- adding-a-distribution HTML
- distlist HTML
- Examples HTML
Downloads
Repository
- PRs merged (all time)
- 100%
- Median days to close, 50 most recently updated closed issues
- 11
- Median days to close, 50 most recently updated closed PRs
- 49
Issues over time
Commits over time
9 development-tooling and community-health practices detected across 4 families in the upstream repository
Checks run against github.com/janolefi/rtmbdist on 2026-10-18.
The R CMD check workflow runs on Linux, macOS and Windows, and on R-devel
GitHub Pages site last deployed 2026-09-26 · The repository has a site deploy workflow
pkgdown site last built 2026-09-26
This repository shows signs of AI coding tools.
- Claude Codefirst seen 2026-05-11Seen in the repository: .claudeNamed in .Rbuildignore: .claudeCommits: at least 10 crediting it in the message
- Claude Opus 5.510 commits · Sep 2026
Dependencies
Installing RTMBdist adds 17 packages (13 with compiled code, 10.0 MB of source tarballs). Heaviest: Rcpp 1.8 MB, RcppEigen 1.7 MB, mvtnorm 1.0 MB.
Code & Tests
People & History
Maintainer since 0.1.0 (2025)
Pick two releases to compare their code metrics.
- 1.1.0Latest2026-09-06 · current release · diff ↗ ·
added 17 exports
dbell, dbell2, djsu, djsu2, lambertW, pbell, pbell2, pjsu, pjsu2, qbell, qbell2, qjsu, qjsu2, rbell, rbell2, rjsu, rjsu2 - 1.0.6
- unarchivedReturned to CRAN2026-07-22
- 1.0.52026-07-22 · diff ↗ ·
removed 1 export
pnbinomadded 8 exports
dgompertz, dllogis, pgompertz, pllogis, qgompertz, qllogis, rgompertz, rllogis - archivedRemoved from CRAN2026-07-15issues were not corrected in time
- RR 4.6.0 released · 2026-04-24
- 1.0.4
- 1.0.3
- 1.0.22026-03-16 · diff ↗ ·
added 22 exports
dbetaprime, dgengamma, dinvchisq, dinvgamma, dkumar, dskellam, pbetaprime, pgengamma, pinvchisq, pinvgamma, pkumar, qbetaprime, qgengamma, qinvchisq, qinvgamma, qkumar, rbetaprime, rgengamma, rinvchisq, rinvgamma, rkumar, rskellam - 1.0.12026-02-24 · diff ↗
- 1.0.02026-01-13 · diff ↗ ·
added 20 exports
Cclayton, Cfrank, Cgumbel, abs_smooth, cgmrf, cmvgauss, ddcopula, dmvcopula, dpgweibull, dskewt2, dwishart, hpgweibull, ppgweibull, pskewt2, qpgweibull, qskewt2, rpgweibull, rskewt2, rwishart, spgweibull - 0.1.02025-10-07
- RR 4.5.0 released · 2025-04-11
Package metadata
- First published
- 2025-10-07
- Total releases
- 9 / 1 yrs
- License
- GPL-2 | GPL-3 OSI · relicensed from MIT + file LICENSE in 1.1.0
- Minimum R
- ≥ 3.5.0
- Download size
- 402 KB
Cite
Cite this package
Run in R for the authors' preferred citation:
citation("RTMBdist")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.
From data release v2026-10-21, which the citation names so these numbers can be found later. More on citing and the projects behind them.