Aggregate Posterior Profile Draws into R_ALL / R_KNOWN_OUTCOME / R_NF Summaries
Source:R/daly_resistance_profiles.R
aggregate_profiles_for_daly.RdSummarises draw-level R_ALL, R_KNOWN_OUTCOME, and R_NF values from
compute_event_profile_probabilities() into posterior mean and
credible interval per hospital x pathogen x profile combination, and
derives explicit eligible_for_YLL/eligible_for_YLD flags
(with reasons) rather than asserting universal usability.
Usage
aggregate_profiles_for_daly(
profile_output,
hospital_col = "hospital",
pathogen_col = "pathogen",
estimand = "observed_stewardship_event_mix",
ci_level = 0.95,
min_n_events = 10L,
min_n_draws = 100L,
sampler_acceptable = TRUE
)Arguments
- profile_output
List returned by
compute_event_profile_probabilities().- hospital_col
Character. Hospital column in
aggregate_draws. Must match the upper RE column used during fitting. Default"hospital".- pathogen_col
Character. Pathogen column. Default
"pathogen".- estimand
Character. Estimand label to attach to output. Default
"observed_stewardship_event_mix".- ci_level
Numeric. Credible interval coverage. Default
0.95.- min_n_events
Integer. Minimum events in the relevant cohort (known-outcome for YLL, nonfatal for YLD) for eligibility. Default
10L.- min_n_draws
Integer. Minimum valid posterior draws in the relevant summary for eligibility. Default
100L.- sampler_acceptable
Logical, scalar or one value per row of
profile_output$aggregate_drawsgroups. Whether the fit's sampler diagnostics are acceptable (e.g.fitted_model$diagnostics$converged_structuralfromfit_bayesian_multivariate_probit());FALSEmakes every row ineligible for YLL/YLD regardless of panel/count support. DefaultTRUE(i.e. does not gate on sampler status unless the caller supplies it –estimate_resistance_profiles()supplies it automatically).
Value
Tibble with one row per hospital x pathogen x profile: R_ALL,
R_KNOWN_OUTCOME, and R_NF posterior mean and credible interval, panel
composition (n_profile_classes, panel_eligibility_method,
classes_excluded, classes_excluded_reason), event and draw
counts, and profile/YLL/YLD eligibility flags with reasons.
Details
Cohort definitions: R_ALL is the mean over truly all events
in the hospital-pathogen-panel cohort (no outcome filter). R_KNOWN_OUTCOME
restricts to events with a known patient outcome (this is what earlier
versions of this function called R_ALL – renamed because it is not
actually all events). R_NF restricts to the non-fatal subset of the
known-outcome cohort. All three are computed per posterior draw and then
summarised here; n_draws_all/n_draws_known_outcome/n_draws_nf
count only the non-NA draws feeding each summary (a cohort that is
empty for a given hospital-pathogen pair yields NA draws, which must
not be silently counted as valid support).
Eligibility: eligible_for_profile_inference is a hard
boolean, TRUE only for rows generated by a conditional
(observed-plus-imputed) method – "conditional_analytic_identity"
or "conditional_gibbs_correlated"; see
compute_event_profile_probabilities(). FALSE for any other
profile_generation_method value, including the legacy
"unconditional_simulation_correlated_not_daly_eligible" tag from an
older profile_output – callers must not rely on the descriptive
profile_generation_method string alone.
eligible_for_YLL/eligible_for_YLD additionally require:
sampler_acceptable (passed in by the caller, e.g. from
fitted_model$diagnostics$converged_structural); the relevant event
cohort has at least min_n_events events; and at least
min_n_draws valid posterior draws contributed to the relevant
summary. exclusion_reason_YLL/exclusion_reason_YLD record
why, distinguishing a cohort that is completely empty
("no_known_outcome_events" / "no_nonfatal_events") from one
that is merely small ("too_few_known_outcome_events" /
"too_few_nonfatal_events").