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.prob from a constant and a random-walk model with
the predicted fatal fraction built from posterior_prob_death(), then refits
the random walk after more follow-up.cfr to prob, 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. Use prob ~ ... in formula and
prob_prior in fit_cfr(); summary() now reports a prob (or
prob[<group>]) row. cfr ~ ... and cfr_prior are still accepted and
translated to prob, with a soft-deprecation warning.fit_cfr() gains loss_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, and
summary() 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 single Beta() 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, and fit_cfr() warns. A loss_prior needs recorded
recoveries and a recovery_delay to time them.prepare_cfr_data() gains last_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()'s obs_time accepts a vector of per-case cut-offs, or
the name of a linelist column 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.posterior_prob_death(), returning draws of the posterior probability
of death for each case: prob updated 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 in prob.max is now honoured: fit_cfr() truncates the fitted delay at
the bound (LogNormal(..., max = 30)), simulate_linelist() draws from the
truncated delay, and pp_check_cfr() replicates from it. Previously the bound
was silently ignored. The bound applies to the recorded delay: it runs from
0 to max - 1 days, 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.primarycensored_lcdf() and log1m_exp()) instead of log1m(). A case
followed up for much longer than the delay rounds the CDF to 1, which made
log1m() reject every draw with log1m: x is 1, but must be less than or equal to 1 and 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 (NA in
onset_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 an obs_time
column is missing from the line list, and fit_cfr() warns when a
recovery_delay has no recorded recoveries to time.fit_cfr() warns and pp_check_cfr() no longer errors when a formula
covariate 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.Remotes and installed from
CRAN like the other dependencies.fit_cfr() and simulate_linelist() support a Weibull() onset-to-death (and
recovery) delay, alongside LogNormal() and Gamma().natural_params() in place
of an internal helper, tracking the distspec API.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 an ascertainment_ratio argument 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): the cfr_prior is 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 a cfr ~ group fit (one cfr[<group>]
row per group), rather than erroring or silently reporting only the reference
level.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 an epidist model
type, so the CFR and the onset-to-death delay both take brms formulas.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.recovery_date column and a two-outcome fit also times recoveries.brms formula on the CFR or the delay for covariates or a time-varying
CFR.simulate_linelist() builds line lists for testing and examples.summary() and print() report the corrected CFR, the delay moments,
convergence diagnostics, and a flag for when the CFR is only weakly identified.