Skip to content

Releases: epinowcast/primarycensored

primarycensored 1.5.1

Choose a tag to compare

@seabbs-bot seabbs-bot released this 15 Jun 13:04
2531649

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_lpmf and primarycensored_lcdf functions for positive-support delays. After the lower-truncation guard was relaxed in 1.5.0 to support negative L, every likelihood evaluation for positive-support delays entered a truncation-normalisation block that cancels to a no-op but still adds gradient calculations (an exp/log_diff_exp per call), giving a roughly 30% slowdown on the likelihood block. The guard now skips this block unless there is a finite D, a strictly positive L, or a finite L on 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

Choose a tag to compare

@seabbs-bot seabbs-bot released this 04 Jun 09:27
1ea1d80

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 L in pprimarycensored(), dprimarycensored(), qprimarycensored(), rprimarycensored(), and pcens_quantile() has changed from 0 to -Inf. fitdistdoublecens() now treats a missing L column as L = -Inf to 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 at 0 (for example to truncate signed-support delays such as pnorm) must now pass L = 0 explicitly (or add an L column in fitdistdoublecens()). (#267)

New features

  • L may now be negative or -Inf in pprimarycensored(), dprimarycensored(), qprimarycensored(), and rprimarycensored(). This lets delay distributions with support below zero (e.g. normal, logistic, Cauchy) be used with primary censoring. L = -Inf is the sentinel for "no left truncation"; any finite L left-truncates the distribution at L. (#267)
  • The Stan functions and pcd_as_stan_data() mirror the R-side handling of L: negative and -Inf values are accepted, and a missing start_relative_obs_time column 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_id upper bound in pcens_model.stan has been raised from 17 to 25, exposing every delay distribution that dist_lcdf already dispatches (Normal, Double Exponential, Pareto, scaled inverse chi-square, Student's t, Uniform, von Mises) through pcd_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() and pcd_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) when min is non-zero.
    The PDF and CDF formulas contained a stray exp(-r * min) factor from using exp(r * (x - min)) instead of exp(r * x).
    The Stan RNG had a compensating xmin + offset.
    The bug did not affect results when min = 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 the q = 0 and q > 0 code paths (single algebraic expression, better for NUTS), the outer log_diff_exp ordering 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 halve gamma_lcdf evaluations. Behaviour and tests are unchanged.
  • Replaced pracma::gammainc with stats::pgamma in the Weibull g() helper, dropping the pracma dependency. The previous pwindow > 3 fallback 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

Choose a tag to compare

@seabbs-bot seabbs-bot released this 06 Mar 13:22
65d6c58

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

Choose a tag to compare

@seabbs seabbs released this 01 Dec 11:29

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 @details sections explaining how distribution names are resolved (e.g., "gamma" uses dgamma() and pgamma()), and what the function does internally.
    • Enhanced distr parameter 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() and fitdistdoublecens() 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

Choose a tag to compare

@seabbs seabbs released this 09 Jun 14:26

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 as pcens_cdf().
    • qpcens() and qprimarycensored(): Convenient wrapper functions that provide
      alternative interfaces to pcens_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 fitdistrplus vignette to use more complex data where the relative observation time is not constant. Also removed the note that the fitdistdoublecens() 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

Full Changelog: v1.1.0...v1.2.0

primarycensored 1.1.0

Choose a tag to compare

@seabbs seabbs released this 10 Feb 19:55

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_name and dprimary_name arguments throughout. Users wishing to pass distribution names (i.e. to potentially leverage analytical solutions) are advised to use the newly introduced add_name_attribute() function. Adds transient dependency on lifecycle and rlang packages. 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 for add_name_attribute().
  • Added documentation to suggest the use of methods(pcens_cdf) to find analytical solutions.
  • Added new data sets pcd_distributions and pcd_primary_distributions to document the distributions supported by primarycensored.

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 @family tag to the pcens functions. 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 D to be of type real in pcens_model.stan in order to support infinite relative_obs_time.
  • Switched to using num_elements() over size() 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_elements instead of size by @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

Full Changelog: v1.0.0...v1.1.0

primarycensored 1.0.0

Choose a tag to compare

@seabbs seabbs released this 28 Oct 12:22

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 rhub checks to the Github Actions workflow.
  • Added dependencies: "hard" to the R-CMD-check workflow 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

Choose a tag to compare

@seabbs seabbs released this 09 Oct 17:04

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 using withr.
  • Added 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.
  • pcd_as_cmdstan_data() has been renamed to pcd_as_stan_data() to better reflect that it is used for Stan models in general rather than just the CmdStan models.
  • The stan code has been refactored into a folder of functions within the current stan folder and the stan model has been moved into the stan folder. 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 primarycensored as 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, and rprimary arguments 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 fitdist call 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

Choose a tag to compare

@seabbs seabbs released this 21 Sep 22:52
7ada1c9

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 the stan and fitdistplus models.
  • Added a "How it works" vignette.
  • Added R infrastructure for analytical solutions via the primary_censored_dist S3 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 R and stan code.
  • 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

Full Changelog: v0.4.0...v0.5.0

primarycensoreddist 0.4.0

Choose a tag to compare

@seabbs seabbs released this 17 Sep 09:43

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 the fitdistrplus package.
  • Added low level tests for the Stan primary_censored_ode function.
  • 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 CmdStan model for fitting distributions using the cmdstanr package.
  • Added helpers functions for working with the new CmdStan model and added an example to the vignette.
  • Added parameter recovery tests for the new CmdStan model which tests the primary_censored_dist_lpmf function 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