Skip to content

Commit

Permalink
find and replace naming
Browse files Browse the repository at this point in the history
  • Loading branch information
seabbs committed Oct 9, 2024
1 parent 0da4530 commit 94eb84e
Show file tree
Hide file tree
Showing 76 changed files with 955 additions and 935 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check-cmdstan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
- name: Compile model and check syntax
run: |
stan_file <- file.path(tempdir(), "pcd_functions.stan")
primarycensoreddist::pcd_load_stan_functions(
primarycensored::pcd_load_stan_functions(
wrap_in_block = TRUE,
write_to_file = TRUE,
output_file = stan_file
Expand Down
15 changes: 7 additions & 8 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
# CITATION file created with {cffr} R package
# See also: https://docs.ropensci.org/cffr/
# --------------------------------------------

cff-version: 1.2.0
message: 'To cite package "primarycensoreddist" in publications use:'
message: 'To cite package "primarycensored" in publications use:'
type: software
license: MIT
title: 'primarycensoreddist: Primary Event Censored Distributions in R and Stan'
title: 'primarycensored: Primary Event Censored Distributions in R and Stan'
version: 0.1.0.1000
doi: 10.5281/zenodo.13632839
identifiers:
- type: url
value: https://github.com/epinowcast/primarycensoreddist/
value: https://github.com/epinowcast/primarycensored/
abstract: This package provides both R functions for working with primary event censored
distributions and Stan implementations for use in Bayesian modeling. Primary event
censored distributions are useful for modeling delayed reporting scenarios in epidemiology
Expand All @@ -25,15 +25,15 @@ authors:
orcid: https://orcid.org/0000-0001-8057-8037
preferred-citation:
type: manual
title: 'primarycensoreddist: Primary Event Censored Distributions in R and Stan'
title: 'primarycensored: Primary Event Censored Distributions in R and Stan'
authors:
- name: Sam Abbott
email: [email protected]
orcid: https://orcid.org/0000-0001-8057-8037
year: '2024'
doi: 10.5281/zenodo.13632839
repository-code: https://github.com/epinowcast/primarycensoreddist/issues/
url: https://primarycensoreddist.epinowcast.org
repository-code: https://github.com/epinowcast/primarycensored/issues/
url: https://primarycensored.epinowcast.org
contact:
- name: Sam Abbott
email: [email protected]
Expand Down Expand Up @@ -195,4 +195,3 @@ references:
orcid: https://orcid.org/0000-0002-7840-692X
year: '2024'
doi: 10.32614/CRAN.package.usethis

13 changes: 7 additions & 6 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Package: primarycensoreddist
Package: primarycensored
Title: Primary Event Censored Distributions in R and Stan
Version: 0.5.0.1000
Authors@R:
Expand All @@ -22,17 +22,18 @@ Authors@R:
role = c("ctb"),
email = "[email protected]",
comment = c(ORCID = "0000-0002-2842-3406")))
Description: This package provides both R functions for working with primary
Description: This package provides R functions for working with primary
event censored distributions and Stan implementations for use in Bayesian
modeling. Primary event censored distributions are useful for modeling
delayed reporting scenarios in epidemiology and other fields. It provides
support for arbitrary delay distributions, a range of common primary
distributions, and allows for truncation and secondary event censoring
to be accounted for.
to be accounted for. In addition, it provides both frequentist and Bayesian
methods for fitting primary event censored distributions to data.
License: MIT + file LICENSE
URL: https://primarycensoreddist.epinowcast.org,
https://github.com/epinowcast/primarycensoreddist/
BugReports: https://github.com/epinowcast/primarycensoreddist/issues/
URL: https://primarycensored.epinowcast.org,
https://github.com/epinowcast/primarycensored/
BugReports: https://github.com/epinowcast/primarycensored/issues/
Depends:
R (>= 4.0.0)
Imports:
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
YEAR: 2024
COPYRIGHT HOLDER: primarycensoreddist authors
COPYRIGHT HOLDER: primarycensored authors
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MIT License

Copyright (c) 2024 primarycensoreddist authors
Copyright (c) 2024 primarycensored authors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
18 changes: 9 additions & 9 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# Generated by roxygen2: do not edit by hand

S3method(primary_censored_cdf,default)
S3method(primary_censored_cdf,pcens_pgamma_dunif)
S3method(primary_censored_cdf,pcens_plnorm_dunif)
S3method(primary_censored_cdf,pcens_pweibull_dunif)
S3method(primarycensored_cdf,default)
S3method(primarycensored_cdf,pcens_pgamma_dunif)
S3method(primarycensored_cdf,pcens_plnorm_dunif)
S3method(primarycensored_cdf,pcens_pweibull_dunif)
export(check_dprimary)
export(check_pdist)
export(check_truncation)
export(dexpgrowth)
export(dpcens)
export(dprimarycensoreddist)
export(dprimarycensored)
export(fitdistdoublecens)
export(new_primary_censored_dist)
export(new_primarycensored)
export(pcd_as_stan_data)
export(pcd_cmdstan_model)
export(pcd_load_stan_functions)
Expand All @@ -20,11 +20,11 @@ export(pcd_stan_functions)
export(pcd_stan_path)
export(pexpgrowth)
export(ppcens)
export(pprimarycensoreddist)
export(primary_censored_cdf)
export(pprimarycensored)
export(primarycensored_cdf)
export(rexpgrowth)
export(rpcens)
export(rprimarycensoreddist)
export(rprimarycensored)
importFrom(stats,dunif)
importFrom(stats,runif)
importFrom(stats,setNames)
35 changes: 18 additions & 17 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# primarycensoreddist 0.5.0.1000
# primarycensored 0.5.0.1000

This is the development version of `primarycensoreddist` and is not yet ready for release.
This is the development version of `primarycensored` and is not yet ready for release.

## Package

Expand All @@ -9,6 +9,7 @@ This is the development version of `primarycensoreddist` and is not yet ready fo
* `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

Expand All @@ -18,7 +19,7 @@ This is the development version of `primarycensoreddist` and is not yet ready fo
* 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".

# primarycensoreddist 0.5.0
# primarycensored 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.

Expand All @@ -28,50 +29,50 @@ As part of the "How it works" we (@SamuelBrand1) found analytical solutions for

* 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 R infrastructure for analytical solutions via the `primarycensored` 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.

# primarycensoreddist 0.4.0
# primarycensored 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 `stan` model and improving the speed of the `primary_censored_ode` function.
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 `stan` model and improving the speed of the `primarycensored_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.
* Added low level tests for the Stan `primarycensored_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.
* Added parameter recovery tests for the new `CmdStan` model which tests the `primarycensored_lpmf` function when used with NUTS based fitting.

# primarycensoreddist 0.3.0
# primarycensored 0.3.0

This release fixes and improves truncation handling across the code base. It also adds a new vignette showcasing how to use the `primarycensoreddist` and `fitdistrplus` packages together to fit distributions.
This release fixes and improves truncation handling across the code base. It also adds a new vignette showcasing how to use the `primarycensored` and `fitdistrplus` packages together to fit distributions.

## Package

* Updated the approach to truncation to be outside the primary censored distribution integral.
* Improved tests that compare random sampling and probability mass/density functions between R and Stan.
* Improved cross-testing between R and Stan implementations of the primary censored distributions.
* Worked on improving the stability of the `primary_censored_dist_lpmf` when used for NUTS based fitting (i.e. in Stan).
* Worked on improving the stability of the `primarycensored_lpmf` when used for NUTS based fitting (i.e. in Stan).

## Documentation

* @athowes improved the getting started vignette by catching a few grammar errors and simplifying language.
* Added a new vignette showcasing how to use the `primarycensoreddist` and `fitdistrplus` packages together to fit distributions.
* Added a new vignette showcasing how to use the `primarycensored` and `fitdistrplus` packages together to fit distributions.

# primarycensoreddist 0.2.0
# primarycensored 0.2.0

This release puts in place initial documentation and vignettes. It also includes a new primary censored distribution interface to allow for non-secondary event censored distributions. Development of this release as identified some numerical issues in the
gradient evaluations for the primary censored distributions which may lead to breaking
interface changes in `0.3.0` for the Stan code.

## Package

* Added support for `swindow = 0` to `rprimarycensoreddist` to allow for non-secondary event censored distributions.
* Adapted `rprimarycensoreddist` so that truncation is based on the primary censored distribution before secondary events are censored. This better matches the generative process.
* Added support for `swindow = 0` to `rprimarycensored` to allow for non-secondary event censored distributions.
* Adapted `rprimarycensored` so that truncation is based on the primary censored distribution before secondary events are censored. This better matches the generative process.
* Added a new Stan interface tool to enable finding which files functions are implemented in the Stan code.

## Documentation
Expand All @@ -80,9 +81,9 @@ interface changes in `0.3.0` for the Stan code.
* Added a vignette showcasing how to use the package Stan code with `cmdstanr`.
* Added a vignette showcasing how to fit distributions using the `cmdstanr` package.

# primarycensoreddist 0.1.0
# primarycensored 0.1.0

This is the initial `primarycensoreddist` release and includes R and stan tools for dealing with potentially truncated primary event censored delay distributions. We expect all current features to work but the UI may change as the package matures over the next few versions.
This is the initial `primarycensored` release and includes R and stan tools for dealing with potentially truncated primary event censored delay distributions. We expect all current features to work but the UI may change as the package matures over the next few versions.

## Package

Expand Down
4 changes: 2 additions & 2 deletions R/check.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#' This function tests whether a given function behaves like a valid CDF by
#' checking if it's monotonically increasing and bounded between 0 and 1.
#'
#' @inheritParams pprimarycensoreddist
#' @inheritParams pprimarycensored
#' @return NULL. The function will stop execution with an error message if
#' pdist is not a valid CDF.
#' @export
Expand Down Expand Up @@ -40,7 +40,7 @@ check_pdist <- function(pdist, D, ...) {
#' checking if it integrates to approximately 1 over the specified range
#' and if it takes the arguments min and max.
#'
#' @inheritParams pprimarycensoreddist
#' @inheritParams pprimarycensored
#' @param tolerance The tolerance for the integral to be considered close to 1
#'
#' @return NULL. The function will stop execution with an error message if
Expand Down
22 changes: 11 additions & 11 deletions R/dprimarycensoreddist.R → R/dprimarycensored.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#' truncation at a maximum delay (D). The function allows for custom primary
#' event distributions and delay distributions.
#'
#' @inheritParams pprimarycensoreddist
#' @inheritParams pprimarycensored
#'
#' @param x Vector of quantiles
#'
Expand Down Expand Up @@ -37,7 +37,7 @@
#' where \eqn{F_{\text{cens}}} is the primary event censored CDF.
#'
#' The function first computes the CDFs for all unique points (including both
#' \eqn{d} and \eqn{d + \text{swindow}}) using [pprimarycensoreddist()]. It then
#' \eqn{d} and \eqn{d + \text{swindow}}) using [pprimarycensored()]. It then
#' creates a lookup table for these CDFs to efficiently calculate the PMF for
#' each input value. For non-positive delays, the function returns 0.
#'
Expand All @@ -51,23 +51,23 @@
#' where \eqn{f_{\text{cens,norm}}(d)} is the normalized PMF and
#' \eqn{f_{\text{cens}}(d)} is the unnormalized PMF. For the explanation and
#' mathematical details of the CDF, refer to the documentation of
#' [pprimarycensoreddist()].
#' [pprimarycensored()].
#'
#' @family primarycensoreddist
#' @family rpd_primarycensored
#'
#' @importFrom stats setNames
#'
#' @examples
#' # Example: Weibull distribution with uniform primary events
#' dprimarycensoreddist(c(0.1, 0.5, 1), pweibull, shape = 1.5, scale = 2.0)
#' dprimarycensored(c(0.1, 0.5, 1), pweibull, shape = 1.5, scale = 2.0)
#'
#' # Example: Weibull distribution with exponential growth primary events
#' dprimarycensoreddist(
#' dprimarycensored(
#' c(0.1, 0.5, 1), pweibull,
#' dprimary = dexpgrowth,
#' dprimary_args = list(r = 0.2), shape = 1.5, scale = 2.0
#' )
dprimarycensoreddist <- function(
dprimarycensored <- function(
x, pdist, pwindow = 1, swindow = 1,
D = Inf, dprimary = stats::dunif,
dprimary_args = list(), log = FALSE,
Expand Down Expand Up @@ -97,7 +97,7 @@ dprimarycensoreddist <- function(
return(rep(0, length(x)))
}

cdfs <- pprimarycensoreddist(
cdfs <- pprimarycensored(
unique_points, pdist, pwindow, Inf, dprimary, dprimary_args,
pdist_name = pdist_name, dprimary_name = dprimary_name, ...
)
Expand All @@ -123,7 +123,7 @@ dprimarycensoreddist <- function(
if (max(unique_points) == D) {
cdf_D <- max(cdfs)
} else {
cdf_D <- pprimarycensoreddist(
cdf_D <- pprimarycensored(
D, pdist, pwindow, Inf, dprimary, dprimary_args, ...
)
}
Expand All @@ -137,6 +137,6 @@ dprimarycensoreddist <- function(
}
}

#' @rdname dprimarycensoreddist
#' @rdname dprimarycensored
#' @export
dpcens <- dprimarycensoreddist
dpcens <- dprimarycensored
Loading

0 comments on commit 94eb84e

Please sign in to comment.