Marginalize conditional cumulative incidences
Source:R/marginalize_psi_dx.R
marginalize_psi_dx_t0.Rd
Averages day- and covariate-specific cumulative incidences from compute_psi_dx_t0()
to produce overall cumulative incidences under each exposure. By default, performs
a simple average. If weights are provided for in gp_list
, performs a weighted
average.
Arguments
- psi_dx
A data frame with conditional risk predictions containing:
<covariates>
: all covariate columns<exposure_time>
: vaccination day columnpsi_0_dx
: cumulative incidence under no vaccine,\(\psi_0(t_0; d, x)\)psi_1_dx
: cumulative incidence under vaccine,\(\psi_1(t_0; d, x)\)
Typically output from
compute_psi_dx_t0()
.- gp_list
A list with two data frames:
g_weights Data frame of covariate-conditional exposure-day probabilities \(g(d \mid x)\). Must include:
group_id
: covariate group identifier<exposure_time>
: exposure time variableprob_g
: probability of exposure time given the covariatesall variables in
covariates
p_weights Data frame of covariate probabilities \(p(x)\). Must include:
group_id
: covariate group identifierprob_p
: marginal probability of each covariate groupall variables in
covariates
Default is
NULL
in which case each row ofpsi_dx
gets equal weight.- show_intermediates
Logical that only applies when
gp_list
is notNULL; when
FALSE(default), the function performs marginalization in a single step and returns only the overall cumulative incidences \eqn{\bar{\psi}_0(t_0)} and \eqn{\bar{\psi}_1(t_0)}. When
TRUE“, performs the two-step marginalization (first over days \(d\), then covariate groups \(x\)) and returns intermediate group-level results \(\psi_v(t_0; x)\).
Value
When show_intermediates = FALSE
, a named numeric vector with two elements:
cuminc_0
: Overall cumulative incidence under no exposurecuminc_1
: Overall cumulative incidence under exposure
When show_intermediates = TRUE
, a list containing both overall results (as a vector)
and group-specific results (as a data frame).
See also
compute_psi_dx_t0()
for generatingpsi_dx
inputcanonicalize_weights()
for creatinggp_list