cfrnow 0.4.0
- Added
posterior_cumulative_incidence(), which returns posterior draws of the cumulative incidence of death and recovery over time since onset for given covariate patterns, or the daily cause-specific or subdistribution hazards. Hazard ratios between covariate patterns follow from these and vary over time.
cfrnow 0.3.0
- Added a “Real-time CFR over time” vignette. On an outbreak whose CFR rises late, it compares weekly
probfrom a constant and a random-walk model with the predicted fatal fraction built fromposterior_prob_death(), then refits the random walk after more follow-up. - The model parameter (and its prior) is renamed from
cfrtoprob, since it is a case fatality ratio only when the line list runs from onset to death; the same model can fit a hospital fatality ratio or other outcome probability for a differently defined line list. Useprob ~ ...informulaandprob_priorinfit_cfr();summary()now reports aprob(orprob[<group>]) row.cfr ~ ...andcfr_priorare still accepted and translated toprob, with a soft-deprecation warning. -
fit_cfr()gainsloss_prior, a prior on the probability that a case is lost to follow-up and its outcome never recorded. A fit that allows for loss estimates it alongside the outcome probability and the delays, andsummary()reports it. Without it, cases that stay unresolved far longer than the delays allow either stretch the delay’s tail or stop the sampler from starting. A singleBeta()gives one probability whatever the outcome;list(death = 0, recovery = Beta(1, 1))gives each outcome its own, fixed or estimated. Estimating both is a sensitivity analysis, since the data cannot tell them apart, andfit_cfr()warns. Aloss_priorneeds recorded recoveries and arecovery_delayto time them. -
prepare_cfr_data()gainslast_contact_date, the column holding the date a case with no recorded outcome was last known unresolved. Such a case is censored there instead of at the cut-off, in retrospective fits too. -
prepare_cfr_data()’sobs_timeaccepts a vector of per-case cut-offs, or the name of alinelistcolumn holding them, so a case reported by a site that cut off earlier is judged against its own cut-off rather than the latest one in the data.pp_check_cfr()replays each case’s own cut-off when building its follow-up horizon. - Added
posterior_prob_death(), returning draws of the posterior probability of death for each case:probupdated by Bayes’ rule on a censored case’s follow-up, or the deterministic outcome for a resolved case. Averaging these draws over cases by onset date gives a real-time CFR for each onset period without a time trend inprob. - A delay’s
maxis now honoured:fit_cfr()truncates the fitted delay at the bound (LogNormal(..., max = 30)),simulate_linelist()draws from the truncated delay, andpp_check_cfr()replicates from it. Previously the bound was silently ignored. The bound applies to the recorded delay: it runs from 0 tomax - 1days, the same support distspec gives the delay object.fit_cfr()also stops, with a message naming the cases, when a recorded delay or an unresolved case falls outside the bounds and would otherwise fail inside Stan. - The survival term for an unresolved case is computed on the log scale (
primarycensored_lcdf()andlog1m_exp()) instead oflog1m(). A case followed up for much longer than the delay rounds the CDF to 1, which madelog1m()reject every draw withlog1m: x is 1, but must be less than or equal to 1and left the chains stuck at their starting values. -
pp_check_cfr()now draws Weibull-family replicate delays from a Weibull distribution instead of a gamma, so posterior-predictive checks for a Weibull fit compare against the right spread of delays. -
prepare_cfr_data()gives a case with no onset window of its own (NAinonset_lower/onset_upper) a one-day window at its onset date, where it was previously dropped as unusable. In real time, an onset window that closes after the case’s cut-off is cut back to the cut-off. -
prepare_cfr_data()stops when a requested covariate or anobs_timecolumn is missing from the line list, andfit_cfr()warns when arecovery_delayhas no recorded recoveries to time.
cfrnow 0.2.1
-
fit_cfr()warns andpp_check_cfr()no longer errors when aformulacovariate has missing values: brms drops those cases before fitting, and the stored onset dates are now kept in step with the rows it actually used. - distspec is now on CRAN, so it is dropped from
Remotesand installed from CRAN like the other dependencies.
cfrnow 0.2.0
-
fit_cfr()andsimulate_linelist()support aWeibull()onset-to-death (and recovery) delay, alongsideLogNormal()andGamma(). - Delay parameterisation now uses distspec’s exported
natural_params()in place of an internal helper, tracking the distspec API. - Added a “Stratified and partially-pooled CFR” vignette covering no-, complete- and partial-pooling CFR fits and per-group
summary()output. -
pp_check_cfr()runs a posterior-predictive check on a fit: it draws replicate line-list outcomes from the posterior, replays the real-time truncation, and compares the observed death counts (plus recoveries in a two-outcome fit) and the observed onset-to-death delays against the replicates (#14). -
summary()gains anascertainment_ratioargument that corrects the CFR for outcome-dependent case ascertainment (fatal and non-fatal cases entering the line list at different rates). The ratio is supplied, defaulting to 1. -
fit_cfr()accepts intercept-free CFR formulas (e.g.cfr ~ 0 + group, one estimated logit-CFR per group): thecfr_prioris placed on those coefficients rather than a non-existent intercept, so the fit no longer fails brms prior validation. -
summary()reports a CFR per group for acfr ~ groupfit (onecfr[<group>]row per group), rather than erroring or silently reporting only the reference level.
cfrnow 0.1.0
First release.
-
fit_cfr()estimates a real-time case fatality ratio from line-list data with a Bayesian mixture-cure survival model. It is registered as anepidistmodel type, so the CFR and the onset-to-death delay both takebrmsformulas. -
prepare_cfr_data()turns a line list into model inputs. It sorts each case, at a chosen observation cut-off, into an observed death, a resolved non-death, or a right-censored survivor. - The onset-to-death delay (LogNormal or Gamma) can be co-estimated or held fixed. Hold it fixed and you get the Ghani/Nishiura estimator.
- Pass a
recovery_datecolumn and a two-outcome fit also times recoveries. - Put a
brmsformula on the CFR or the delay for covariates or a time-varying CFR. -
simulate_linelist()builds line lists for testing and examples. -
summary()andprint()report the corrected CFR, the delay moments, convergence diagnostics, and a flag for when the CFR is only weakly identified.