Releases: epinowcast/primarycensored
Release list
primarycensored 1.5.1
This patch release fixes a performance regression introduced in 1.5.0 that slowed the Stan likelihood for positive-support delays.
Bug fixes
- Fixed a performance regression in the Stan
primarycensored_lpmfandprimarycensored_lcdffunctions for positive-support delays. After the lower-truncation guard was relaxed in 1.5.0 to support negativeL, every likelihood evaluation for positive-support delays entered a truncation-normalisation block that cancels to a no-op but still adds gradient calculations (anexp/log_diff_expper call), giving a roughly 30% slowdown on the likelihood block. The guard now skips this block unless there is a finiteD, a strictly positiveL, or a finiteLon a real-support distribution, restoring 1.4.0 performance without changing results or losing the negative-support behaviour. Thanks to @sbfnk for reporting (#323).
Full Changelog: v1.5.0...v1.5.1
primarycensored 1.5.0
primarycensored 1.5.0
This minor release extends the L (lower truncation) parameter to accept negative and -Inf values in both the R and Stan code, letting delay distributions with support below zero (e.g. normal, logistic, Cauchy, Gumbel) be used with primary censoring and fitted via fitdistdoublecens() and pcd_cmdstan_model(). The default value of L has changed from 0 to -Inf, which leaves results unchanged for distributions with non-negative support (e.g. lognormal, gamma, Weibull). It also fixes a normalisation bug in the exponential growth primary distribution and rewrites the analytical CDFs in a CDF-direct form, dropping the pracma dependency.
Breaking changes
- The default value of
Linpprimarycensored(),dprimarycensored(),qprimarycensored(),rprimarycensored(), andpcens_quantile()has changed from0to-Inf.fitdistdoublecens()now treats a missingLcolumn asL = -Infto match. For delay distributions with support on the non-negative reals (e.g. lognormal, gamma, Weibull)F_cens(0) = 0, so the new default leaves results unchanged. Callers that relied on the implicit left truncation at0(for example to truncate signed-support delays such aspnorm) must now passL = 0explicitly (or add anLcolumn infitdistdoublecens()). (#267)
New features
Lmay now be negative or-Infinpprimarycensored(),dprimarycensored(),qprimarycensored(), andrprimarycensored(). This lets delay distributions with support below zero (e.g. normal, logistic, Cauchy) be used with primary censoring.L = -Infis the sentinel for "no left truncation"; any finiteLleft-truncates the distribution atL. (#267)- The Stan functions and
pcd_as_stan_data()mirror the R-side handling ofL: negative and-Infvalues are accepted, and a missingstart_relative_obs_timecolumn defaults to-Inf.pcd_cmdstan_model()now accepts negative observed delays and fully-negative truncation windows, letting distributions with support on the reals (e.g. logistic, Cauchy, Gumbel) be fitted. (#313) - The
dist_idupper bound inpcens_model.stanhas been raised from17to25, exposing every delay distribution thatdist_lcdfalready dispatches (Normal, Double Exponential, Pareto, scaled inverse chi-square, Student's t, Uniform, von Mises) throughpcd_cmdstan_model(). (#314)
Documentation
- Added a CDF-direct form of the primary-censored analytic solutions to the "Why it works" and "Analytic solutions" vignettes alongside the existing survival-function form.
- Added a "Fitting delay distributions with negative support" vignette that walks through estimating a logistic-distributed serial interval with both
fitdistdoublecens()andpcd_cmdstan_model()from doubly-censored, right-truncated samples that include negative observed delays.
Bug fixes
- Fixed incorrect normalisation in
dexpgrowth(),pexpgrowth(), and their Stan equivalents (expgrowth_pdf,expgrowth_lpdf,expgrowth_cdf,expgrowth_rng) whenminis non-zero.
The PDF and CDF formulas contained a strayexp(-r * min)factor from usingexp(r * (x - min))instead ofexp(r * x).
The Stan RNG had a compensatingxmin +offset.
The bug did not affect results whenmin = 0(the default and only value used within the package's primary censoring functions).
Thanks to @TimTaylor for reporting (#290).
Internal
- Rewrote the analytical primary-censored CDFs (Gamma, Log-Normal, Weibull with uniform primary) in R and Stan to use a CDF-direct algebraic form,
$F_{S_+}(d) = [d F_T(d) - q F_T(q) - E(\tilde F(d) - \tilde F(q))]/w_P$ . In Stan this unifies theq = 0andq > 0code paths (single algebraic expression, better for NUTS), the outerlog_diff_expordering is now mathematically guaranteed, and the Gamma case uses the incomplete-gamma recursion$P(k{+}1, y) = P(k, y) - y^k e^{-y}/\Gamma(k{+}1)$ to halvegamma_lcdfevaluations. Behaviour and tests are unchanged. - Replaced
pracma::gammaincwithstats::pgammain the Weibullg()helper, dropping thepracmadependency. The previouspwindow > 3fallback to numeric integration (and the internal overflow guard) is no longer needed — the base R implementation is stable across the full parameter range. Closes #127.
primarycensored 1.4.0
This release adds left-truncation support via the L parameter, removes deprecated functionality from v1.1.0, and removes the lifecycle and rlang dependencies.
See NEWS.md for the full changelog.
primarycensored 1.3.0
This minor release improves documentation for fitdistdoublecens() and adds learning objective sections to vignettes. It also fixes floating-point precision issues in dprimarycensored() and adds bounds checking to CDF methods.
Documentation
- Improved documentation for
fitdistdoublecens():- Expanded function description to explain primary censoring, secondary censoring, and truncation.
- Added detailed
@detailssections explaining how distribution names are resolved (e.g.,"gamma"usesdgamma()andpgamma()), and what the function does internally. - Enhanced
distrparameter documentation with examples and guidance on custom distributions.
- Added "What you will learn" and "How you might adapt this vignette" sections to both the fitdistrplus and Stan fitting vignettes to help users understand learning objectives and adapt the examples for their own data.
Package
- Added tests to verify that
pcd_as_stan_data()andfitdistdoublecens()correctly handle data frames with additional columns beyond those required. (#213)
Bug fixes
- Fixed an issue where
dprimarycensored()could return very small negative values (e.g., -2.2e-16) due to floating-point precision when computing PMF as CDF differences. PMF values are now clamped to be non-negative. (#238) - Added bounds checking to all
pcens_cdf()methods to ensure CDF values are always in [0, 1], complementing the existing upper bound check with a lower bound check.
What's Changed
- Update codemeta.json by @github-actions[bot] in #228
- Bump actions/checkout from 4 to 5 by @dependabot[bot] in #231
- Bump actions/upload-artifact from 4 to 5 by @dependabot[bot] in #234
- Update README by @github-actions[bot] in #235
- Bump JamesIves/github-pages-deploy-action from 4.7.3 to 4.7.4 by @dependabot[bot] in #237
- Bump actions/checkout from 5 to 6 by @dependabot[bot] in #239
- Fix dprimarycensored yielding negative values by @seabbs in #240
- Review and fix touchstone benchmarking setup by @seabbs in #245
- Add tests for spurious column checking by @seabbs in #243
- Improve custom distribution documentation by @seabbs in #241
- Add callout box highlighting why primarycensored is useful by @seabbs in #247
- Update codemeta.json by @github-actions[bot] in #242
- Update README by @github-actions[bot] in #250
Full Changelog: v1.2.0...v1.3.0
primarycensored 1.2.0
This minor release adds quantile functions for primary censored distributions and enhances the fitdistdoublecens() function to support varying primary censoring windows and truncation times. The release also improves documentation, particularly the Stan reference, making it easier for users to navigate and work with the Stan code.
Package
- Added new functions to compute quantiles of the primary censored distribution:
pcens_quantile(): Core implementation using numerical optimisation to find
quantiles by inverting the CDF. The implementation allows for analytical
solutions to be added in future versions using the same interface aspcens_cdf().qpcens()andqprimarycensored(): Convenient wrapper functions that provide
alternative interfaces topcens_quantile().
- Added support to
fitdistdoublecens()to allow for varying primary censoring windows and truncation times. As part of this refactor the interface has also been improved to allow for more flexible data input.
Documentation
- Removed authorship from vignettes.
- Updated the
fitdistrplusvignette to use more complex data where the relative observation time is not constant. Also removed the note that thefitdistdoublecens()function is limited to a single primary censoring windows and truncation time as this is no longer the case. - The Stan Reference has been enhanced to make it easier to navigate the Stan code.
Pull requests
- Update codemeta.json by @github-actions in #202
- Update README by @github-actions in #204
- Update codemeta.json by @github-actions in #206
- Issue #50: Add quantile function by @seabbs in #209
- Update README by @github-actions in #211
- Issue #71: Adds support for varying right truncation and primary windows to fitdistdoublecens by @seabbs in #212
- Issue #29 - Enhance stan documentation by @jamesmbaazam in #215
- Update codemeta.json by @github-actions in #216
- Hotfix: Put stan reference update in the dev release news section. by @seabbs in #217
- Issue #172: Drop the authorship from vignettes by @barbora-sobolova in #220
- Update README by @github-actions in #221
- Update README by @github-actions in #222
- Bump JamesIves/github-pages-deploy-action from 4.7.2 to 4.7.3 by @dependabot in #210
New Contributors
- @barbora-sobolova made their first contribution in #220
Full Changelog: v1.1.0...v1.2.0
primarycensored 1.1.0
This minor release improves the documentation and the internal system used to automatically discover analytical solutions. It also adds lookups for supported supported distributions and tooling for working with these lookups. This makes it easier for package developers using primarycensored and also makes it easier to work with the Stan likelihood functions by improving the discoverability of the distribution functions. Minor bugs were also fixed.
Package
- Updated the CI so that stan code is also tested on Windows and Mac. This is to ensure that the stan code is compatible with these platforms and in response to a CI bug in
epidist. - Revised approach to automatic discovery of distribution functions. This soft deprecates the
pdist_nameanddprimary_namearguments throughout. Users wishing to pass distribution names (i.e. to potentially leverage analytical solutions) are advised to use the newly introducedadd_name_attribute()function. Adds transient dependency onlifecycleandrlangpackages. See #188 by @pearsonca. - Added
pcd_stan_dist_id()to allow for discovery of distribution IDs for Stan models. - Added
pcd_dist_name()to allow for discovery of distribution names for R functions as needed foradd_name_attribute(). - Added documentation to suggest the use of
methods(pcens_cdf)to find analytical solutions. - Added new data sets
pcd_distributionsandpcd_primary_distributionsto document the distributions supported byprimarycensored.
Documentation
- Added a CRAN downloads badge to the README.
- Corrected how to specify an empty array in the docs of
primarycensored_lcdf(). - All documentation was reviewed and updated to enhance readability and clarity.
Bug fixes
- Added a missing
@familytag to thepcensfunctions. This omission resulted in the Weibull analytical solution not being visible in the package documentation. - Added precalculation of vector sizes to the
primarycensored_cdf()stan function, avoiding errors on some platforms due to narrowing conversions in aggregate initialisation. - Changed
Dto be of type real inpcens_model.stanin order to support infiniterelative_obs_time. - Switched to using
num_elements()oversize()in all stan code to resolve compilation issues on some platforms as reported by @sbfnk.
Pull requests
- Update codemeta.json by @github-actions in #165
- Update README by @github-actions in #167
- Remove duplicate line in vignette by @athowes in #173
- Bump JamesIves/github-pages-deploy-action from 4.6.8 to 4.6.9 by @dependabot in #168
- Bump JamesIves/github-pages-deploy-action from 4.6.9 to 4.7.1 by @dependabot in #174
- 177: use
num_elementsinstead ofsizeby @sbfnk in #178 - 179: make D real by @sbfnk in #180
- 181: pre-assign sizes to variables by @sbfnk in #182
- Update codemeta.json by @github-actions in #183
- Bump JamesIves/github-pages-deploy-action from 4.7.1 to 4.7.2 by @dependabot in #176
- Update README by @github-actions in #185
- Use correct specification of empty array by @jamesmbaazam in #186
- Turn on stan testing for mac and windows on CI by @seabbs in #189
- Bump mattnotmitt/doxygen-action from 1.9.8 to 1.12.0 by @dependabot in #190
- Pdist naming alt by @pearsonca in #188
- Update README by @github-actions in #191
- Update codemeta.json by @github-actions in #192
- Issue #193: Swap to num_elements from size by @seabbs in #194
- Issue #175: Add distribution look up tables and associated tooling by @seabbs in #195
- Update README by @github-actions in #197
- Documentation review changes by @seabbs in #198
- Update README by @github-actions in #200
New Contributors
- @jamesmbaazam made their first contribution in #186
- @pearsonca made their first contribution in #188
Full Changelog: v1.0.0...v1.1.0
primarycensored 1.0.0
This is the first major release of primarycensored and the first to be available from CRAN.
Package
- Fix internal package misspelling of
primary_lpdf. - Move to "stable" lifecycle status.
- Added
rhubchecks to theGithub Actionsworkflow. - Added
dependencies: "hard"to theR-CMD-checkworkflow to ensure checks pass without optional dependencies. - Improved handling of examples that use optional dependencies.
- Check all URLs for redirects.
- Ensure that all functions have documented return values.
Pull requests
- Update codemeta.json by @github-actions in #138
- Update README by @github-actions in #140
- Update codemeta.json by @github-actions in #141
- Update codemeta.json by @github-actions in #151
- Update README by @github-actions in #154
- Update codemeta.json by @github-actions in #153
- Update codemeta.json by @github-actions in #156
- Update README by @github-actions in #158
- Update README by @github-actions in #160
- Update codemeta.json by @github-actions in #159
- Update README by @github-actions in #163
- Update codemeta.json by @github-actions in #162
Full Changelog: v0.6.0...v1.0.0
primarycensored 0.6.0
This release renames the package to primarycensored from primarycensoredist and also renames many of the functions to remove the dist in their name. This was done to make the package name and the functions more consistent and to remove the need to use the dist suffix. It also aligns it with the new PrimaryCensored.jl package in our Julia ecosystem.
Aside from name changes, this release also adds an analytical solution for the weibull distribution with uniform primary censoring, removes the need to assign functions to the global environment for fitdistdoublecens() by using withr, and adds a check_truncation() function to check if the truncation time is larger than the maximum observed delay. This is used in fitdistdoublecens() and pcd_as_stan_data() to ensure that the truncation time is appropriate to maximise computational efficiency.
Package
- Removed the need to assign functions to the global environment for
fitdistdoublecens()by usingwithr. - Added a
check_truncation()function to check if the truncation time is larger than the maximum observed delay. This is used infitdistdoublecens()andpcd_as_stan_data()to ensure that the truncation time is appropriate to maximise computational efficiency. pcd_as_cmdstan_data()has been renamed topcd_as_stan_data()to better reflect that it is used forStanmodels in general rather than just theCmdStanmodels.- The stan code has been refactored into a folder of functions within the current
stanfolder and thestanmodel has been moved into thestanfolder. All paths to the stan code have been updated to reflect this. - Added R and stan implementations of the primary censored cdf for the weibull distribution with uniform primary censoring.
- The package has been renamed to
primarycensoredas have all functions that use "dist" in their name.
Documentation
- Simplified the "Analytic solutions" vignette by removing verbose derivation details.
- Added links between vignettes to make it easier to navigate the documentation.
- Added explicit usage of
pdist,dprimary,rdist, andrprimaryarguments in the getting started vignette to make it easier to link to mathematical details. - Fixed error in "Analytic solutions" vignette where the Weibull density was not being treated as zero for negative delays.
- Split "Why it works" vignette into two separate vignettes, "Why it works" and "Analytic solutions for censored delay distributions"
Pull requests
- Update codemeta.json by @github-actions in #103
- Issue 72: Split why it works vignette into intro and analytic solutions vignette by @SamuelBrand1 in #106
- Bump JamesIves/github-pages-deploy-action from 4.6.4 to 4.6.8 by @dependabot in #110
- Update README by @github-actions in #111
- use local environment for
fitdistcall by @sbfnk in #113 - Update codemeta.json by @github-actions in #114
- Update README by @github-actions in #115
- Issue #84: Prune not helpful to arg flow maths by @seabbs in #116
- Issue #82: Link between vignettes by @seabbs in #118
- Issue #69: Add check_truncation by @seabbs in #120
- Update README by @github-actions in #121
- Issue 109: Add explicit dist and primary arg usage to getting started by @seabbs in #122
- Issue 70: Restructure stan code by @seabbs in #123
- Issue 125: Update analytic solutions to deal with possible neg t values by @SamuelBrand1 in #126
- Issue 94: Add R and Stan for analytical Weibull by @seabbs in #109
- Update codemeta.json by @github-actions in #128
- Issue #108: Rename from primarycensoreddist to primarycensored by @seabbs in #130
- Update README by @github-actions in #132
- Update codemeta.json by @github-actions in #131
New Contributors
Full Changelog: v0.5.0...v0.6.0
primarycensoreddist 0.5.0
This release adds a new {touchstone} based benchmark suite to the package. It also adds a new "How it works" vignette which aims to give the reader more details into how the primary censored distributions work.
As part of the "How it works" we (@SamuelBrand1) found analytical solutions for the gamma, lognormal, and weibull distributions with uniform primary censoring. These are now implemented for the lognormal and gamma distributions in the R and stan code providing significant speedups to the fitting process (~10-20 times faster). The Weibull will be added in the next release.
Package
- Add
{touchstone}based benchmarks for benchmarking R utility functions, and fitting thestanandfitdistplusmodels. - Added a "How it works" vignette.
- Added R infrastructure for analytical solutions via the
primary_censored_distS3 class. - Added Weibull analytical solution to "How it works" vignette.
- Added analytical solutions for the gamma and lognormal distributions with uniform primary censoring to both the
Randstancode. - Added numerical protection to ensure that CDFs for delays greater than the maximum truncation are exactly 1.
Pull requests
- Update codemeta.json by @github-actions in #74
- Update codemeta.json by @github-actions in #78
- Issue 36: Add benchmarking of R, Stan, and fitdistdoublecens by @seabbs in #79
- Issue 37 draft: Why it works vignette with analytic solutions by @SamuelBrand1 in #68
- Update codemeta.json by @github-actions in #81
- Issue 86: Fixes for "Why it works" vignette by @SamuelBrand1 in #88
- Update README by @github-actions in #89
- Issue 85: Add infrastructure for analytical solutions in R by @seabbs in #87
- Update README by @github-actions in #92
- Issue 85: Implement analytical solutions in R by @seabbs in #90
- Issue 76: Add weibull distribution to analytic solutions in vignette by @SamuelBrand1 in #93
- Issue 85: Analytical solutions in stan by @seabbs in #95
- Update README by @github-actions in #99
- Update codemeta.json by @github-actions in #98
New Contributors
- @SamuelBrand1 made their first contribution in #68
Full Changelog: v0.4.0...v0.5.0
primarycensoreddist 0.4.0
In this release, we have added a new package stan model for fitting distributions using the cmdstanr package. We have also added a new function fitdistdoublecens() to allow for fitting of double censored and truncated data using the fitdistrplus package. As well as these functionality improvements this release focuses on improving the stability of the CmdStan model and improving the speed of the primary_censored_ode function.
Package
- Added a new function
fitdistdoublecens()to allow for fitting of double censored and truncated data using thefitdistrpluspackage. - Added low level tests for the Stan
primary_censored_odefunction. - Rephrased the stan code to use a ODE solver rather than a numerical integration method. This allows for much faster and more stable computation of the likelihood
- Added a
CmdStanmodel for fitting distributions using thecmdstanrpackage. - Added helpers functions for working with the new
CmdStanmodel and added an example to the vignette. - Added parameter recovery tests for the new
CmdStanmodel which tests theprimary_censored_dist_lpmffunction when used with NUTS based fitting.
Pull Requests
- Update codemeta.json by @github-actions in #54
- Update README by @github-actions in #57
- Update codemeta.json by @github-actions in #56
- Bump peter-evans/create-pull-request from 6 to 7 by @dependabot in #59
- Bump JamesIves/github-pages-deploy-action from 4.6.3 to 4.6.4 by @dependabot in #60
- Issue 55: Add fitdistdoublecens wrapper by @seabbs in #61
- Issue 34: rephrase integral as an ODE by @seabbs in #64
- Issue 35 and 36: Package CmdStan model by @seabbs in #67
Full Changelog: v0.3.0...v0.4.0