Package: primarycensored 1.5.2

Sam Abbott

primarycensored: Primary Event Censored Distributions

Provides 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 (Charniga et al. (2024) <doi:10.48550/arXiv.2405.08841>). It also provides support for arbitrary delay distributions, a range of common primary distributions, and allows for truncation and secondary event censoring to be accounted for (Park et al. (2024) <doi:10.1101/2024.01.12.24301247>). A subset of common distributions also have analytical solutions implemented, allowing for faster computation. In addition, it provides multiple methods for fitting primary event censored distributions to data via optional dependencies.

Authors:Sam Abbott [aut, cre, cph], Sam Brand [aut], Adam Howes [ctb], James Mba Azam [aut], Carl Pearson [aut], Sebastian Funk [aut], Kelly Charniga [aut]

primarycensored_1.5.2.tar.gz
primarycensored_1.5.2.zip(r-4.7-any)primarycensored_1.5.2.zip(r-4.6-any)primarycensored_1.5.2.zip(r-4.5-any)
primarycensored_1.5.2.tgz(r-4.6-any)primarycensored_1.5.2.tgz(r-4.5-any)
primarycensored_1.5.2.tar.gz(r-4.7-any)primarycensored_1.5.2.tar.gz(r-4.6-any)
primarycensored_1.5.2.tgz(r-4.6-emscripten)
manual.pdf |manual.html✨
DESCRIPTION |NEWS
card.svg |card.png
primarycensored/json (API)

# Install 'primarycensored' in R:
install.packages('primarycensored', repos = c('https://epinowcast.r-universe.dev', 'https://cloud.r-project.org'))

Bug tracker:https://github.com/epinowcast/primarycensored/issues

Pkgdown/docs site:https://primarycensored.epinowcast.org

Datasets:

On CRAN:

Conda:

censoringdistributionsmc-stantruncation

9.11 score 9 stars 5 packages 39 scripts 1.0k downloads 37 exports 3 dependencies

Last updated from:75b079075f (on v1.5.2). Checks:7 ERROR, 2 OK. Indexed: yes.

TargetResultTimeFilesSyslog
linux-develERROR166
source / vignettesOK213
linux-releaseERROR162
macos-releaseERROR108
macos-oldrelERROR107
windows-develERROR91
windows-releaseERROR68
windows-oldrelERROR112
wasm-releaseOK120

Exports:add_name_attributecheck_dprimarycheck_pdistcheck_truncationddiscretehazardddiscretestepdexpgrowthdiscretehazard_startdpcensdprimarycensoredfitdistdoublecenshazards_to_pmfnew_pcenspcd_as_stan_datapcd_cmdstan_modelpcd_dist_namepcd_load_stan_functionspcd_stan_dist_idpcd_stan_filespcd_stan_function_depspcd_stan_functionspcd_stan_pathpcens_cdfpcens_quantilepdiscretehazardpdiscretesteppexpgrowthpmf_to_hazardsppcenspprimarycensoredqpcensqprimarycensoredrdiscretehazardrdiscretesteprexpgrowthrpcensrprimarycensored

Dependencies:clilifecyclerlang

Analytic solutions for censored delay distributions
Introduction | What are we going to do in this vignette | Analytic solutions for exponentially tilted primary event times | Uniform primary event time ($r=0$) | General partial expectation | General discrete censored delay distribution | Gamma distributed delay times | Gamma partial expectation | Survival function of $S_{+}$ for Gamma distribution | CDF form of $S_{+}$ for Gamma distribution | Gamma discrete censored delay distribution | Log-Normal distribution | Log-Normal partial expectation | Survival function of $S_{+}$ for Log-Normal distribution | CDF form of $S_{+}$ for Log-Normal distribution | Log-Normal discrete censored delay distribution | Weibull distribution | Weibull partial expectation | Survival function of $S_{+}$ for Weibull distribution | CDF form of $S_{+}$ for Weibull distribution | Weibull discrete censored delay distribution | Generalised gamma distribution | Generalised gamma partial expectation | Survival function of $S_{+}$ for generalised gamma distribution | CDF form of $S_{+}$ for generalised gamma distribution | Learning more | References

Last update: 2026-09-10
Started: 2024-09-24

Why it works
Introduction | What are we going to do in this vignette | Censoring and right truncation problems in time to event analysis | Statistical model used in primarycensored | Censored delay time distribution | Survival function of time from the end of the primary censoring window to the secondary event time | CDF form of $S_+$ for uniform primary | Probability of secondary event time within a secondary censoring window | Connections to other approaches | Connection to Park et al 2024 | Learning more | References

Last update: 2026-04-22
Started: 2024-09-18

Getting started with primarycensored
Introduction | Packages in this getting started vignette. | Generating random samples with rprimarycensored() | Compute the primary event censored cumulative distribution function (CDF) for delays with pprimarycensored() | Compute the primary event censored probability mass function (PMF) with dprimarycensored() | Other key functionality | Learning more

Last update: 2026-02-12
Started: 2024-10-09

Readme and manuals

Help Manual

Help pageTopics
Helper method for custom distributionsadd_name_attribute
Check if a function is a valid bounded probability density function (PDF)check_dprimary
Check if a function is a valid cumulative distribution function (CDF)check_pdist
Check if truncation time is appropriate relative to the maximum delaycheck_truncation
Hazard-parameterised piecewise-constant PMFddiscretehazard
Step (piecewise-constant) PMFddiscretestep
Start values for the logit-hazard parameterisationdiscretehazard_start
Compute the primary event censored PMF for delaysdpcens dprimarycensored
Exponential growth distribution functionsdexpgrowth expgrowth pexpgrowth rexpgrowth
Fit a distribution to doubly censored datafitdistdoublecens
Convert discrete-time hazards to a PMFhazards_to_pmf
S3 class for primary event censored distribution computationnew_pcens
Prepare data for primarycensored Stan modelpcd_as_stan_data
Create a CmdStanModel with primarycensored Stan functionspcd_cmdstan_model
Get distribution function cdf or pdf namepcd_dist_name
Supported delay distributionspcd_distributions
Load Stan functions as a stringpcd_load_stan_functions
Supported primary event distributionspcd_primary_distributions
Get distribution stan ID by namepcd_stan_dist_id
Get Stan files containing specified functionspcd_stan_files
Get dependencies for a Stan functionpcd_stan_function_deps
Get Stan function names from Stan filespcd_stan_functions
Get the path to the Stan codepcd_stan_path
Compute primary event censored CDFpcens_cdf
Default method for computing primary event censored CDFpcens_cdf.default
Method for hazard CDF delay with general primary event distributionpcens_cdf.pcens_pdiscretehazard
Method for step CDF delay with general primary event distributionpcens_cdf.pcens_pdiscretestep
Method for Gamma delay with uniform primarypcens_cdf.pcens_pgamma_dunif
Method for generalised gamma (Prentice parameterisation) delay with uniform primarypcens_cdf.pcens_pgengamma_dunif
Method for generalised gamma delay with uniform primarypcens_cdf.pcens_pgengamma.orig_dunif
Method for Log-Normal delay with uniform primarypcens_cdf.pcens_plnorm_dunif
Method for Weibull delay with uniform primarypcens_cdf.pcens_pweibull_dunif
Compute primary event censored quantilespcens_quantile
Default method for computing primary event censored quantilespcens_quantile.default
Hazard-parameterised piecewise-constant CDFpdiscretehazard
Step (piecewise-constant) CDFpdiscretestep
Convert a PMF to discrete-time hazardspmf_to_hazards
Compute the primary event censored CDF for delaysppcens pprimarycensored
Compute quantiles corresponding to target probabilities for primary event censored delaysqpcens qprimarycensored
Sample from a hazard-parameterised step distributionrdiscretehazard
Sample from a step distributionrdiscretestep
Generate random samples from a primary event censored distributionrpcens rprimarycensored