Computes confidence intervals for cumulative risk estimates using the influence curve or supplied bootstrap replicates to estimate standard errors.

compute_cumrisk_effect_ci(
  obj,
  alpha = 0.05,
  ic = FALSE,
  risk_time = NULL,
  ref = 1,
  effect_measure_type = "RD",
  boot_method = "normal"
)

Arguments

obj

A cumrisk object containing the risk estimates, e.g., as computed by estimate_ipwrisk

alpha

The desired nominal significance level of the confidence intervals.

ic

If the supplied object contains a bootstrap risk estimates, setting ic = TRUE will requests that estimated standard errors be derived from the influence curve.

risk_time

The time at which the cumulative risk and effect measure estimates should be returned. The default value NULL returns all times; otherwise the estimates at the latest time in obj$times at or before risk_time are returned.

ref

The index of the treatment group to use as the reference for effect measure calculations, where groups are ordered lexicographically by their labels (default ref = 1).

effect_measure_type

A string identifying the type of effect measure to be computed from among the following options: "RD" (risk difference), "RR" (risk ratio), "logRR" (logarithm of the risk ratio), or "AR" (attributable risk). Note that when obj was created using bootstrap estimation, ic = FALSE, and boot_method is "log-normal", then only effect measures with support on the positive real line can be used (i.e. "RR"). See the Cumulative risk effect measure types section for the definitions of the various effect measures.

boot_method

The specific bootstrap approach used to compute confidence intervals. Options are "normal" (default; normal approximation on the original scale), "log-normal" (normal approximation on the log scale), "percentile" (percentile-based approach using quantiles of the bootstrap distribution), and "basic" (basic bootstrap using the reflection method). When obj was created without using bootstrap estimation or ic = TRUE is provided then the value of boot_method is ignored. Note that when obj was created using bootstrap estimation, ic = FALSE, and boot_method is "log-normal", then only effect measures specified via effect_measure_type with support on the positive real line can be used.

Value

A data frame with one row per time point per non-reference group, containing the following columns:

  • time: the time point at which the estimate and confidence interval are provided

  • group_label: the label of the treatment group being compared with the reference group. The reference group never appears in this column because it is the other side of every comparison; its label is in ref_label.

  • crisk: the cumulative risk estimate for the group_label group

  • crisk_var: the variance of the cumulative risk estimate for the group_label group

  • ref_label: the reference group label

  • ref_crisk: the cumulative risk estimate for the reference group

  • ref_crisk_var: the variance of the cumulative risk estimate for the reference group

  • criskfunc: the point estimate of the effect measure

  • criskfunc_var: the estimated variance of the effect measure. Derived from bootstrap replicates or the influence curve, depending on the inputs. For the "log-normal" bootstrap method this is the variance on the log scale (see the Handling non-finite values section for the case where the point estimate is 0); for all other methods it is on the original scale.

  • lcl: the lower confidence limit

  • ucl: the upper confidence limit

  • label: a contrast label of the form "<group> vs <ref>"

Cumulative risk effect measure types

Risk difference

Mean: \(\mathrm{E}[Y^{1}] - \mathrm{E}[Y^{0}]\)

Variance with IPW: \( \mathrm{Var}[Y^{1}] + \mathrm{Var}[Y^{0}] + \frac{2}{n} \mathrm{E}[Y^{1}] \, \mathrm{E}[Y^{0}] \)

Variance otherwise: \(\mathrm{Var}[Y^{1}] + \mathrm{Var}[Y^{0}]\)

Risk ratio

Mean: \(\frac{\mathrm{E}[Y^{1}]}{\mathrm{E}[Y^{0}]}\)

Variance with IPW: \( \frac{\mathrm{Var}[Y^{1}]}{(\mathrm{E}[Y^{0}])^{2}} + \frac{\mathrm{Var}[Y^{0}]\,(\mathrm{E}[Y^{1}])^2} {(\mathrm{E}[Y^{0}])^{4}} + \frac{2\,(\mathrm{E}[Y^{1}])^2}{n\,(\mathrm{E}[Y^{0}])^2} \)

Variance otherwise: \( \frac{\mathrm{Var}[Y^{1}]}{(\mathrm{E}[Y^{0}])^{2}} + \frac{\mathrm{Var}[Y^{0}]\,(\mathrm{E}[Y^{1}])^2} {(\mathrm{E}[Y^{0}])^{4}} \)

A ratio of 0 (no events yet in the numerator group) is reported with a variance of 0 and a CI of (0, 0). This holds for the influence-curve variance, where every term is 0, and for every bootstrap method, since resampling or reweighting cannot create events and so every replicate is 0 as well. (The "log-normal" method's log-scale variance is undefined for a ratio of 0 and is taken to be 0 to give the same result.) The exception is when the denominator group is also 0 in all but at most one replicate; see the Handling non-finite values section.

Logarithm of the risk ratio

Mean: \(\mathrm{log}\frac{\mathrm{E}[Y^{1}]}{\mathrm{E}[Y^{0}]}\)

Variance with IPW: \( \frac{\mathrm{Var}[Y^{1}]}{(\mathrm{E}[Y^{1}])^{2}} + \frac{\mathrm{Var}[Y^{0}]}{(\mathrm{E}[Y^{0}])^{2}} + \frac{2}{n} \)

Variance otherwise: \( \frac{\mathrm{Var}[Y^{1}]}{(\mathrm{E}[Y^{1}])^{2}} + \frac{\mathrm{Var}[Y^{0}]}{(\mathrm{E}[Y^{0}])^{2}} \)

Attributable risk

Mean: \(\frac{\mathrm{E}[Y^{1}] - \mathrm{E}[Y^{0}]}{\mathrm{E}[Y^{1}]}\)

Variance with IPW: \( \frac{\mathrm{Var}[Y^{0}]}{(\mathrm{E}[Y^{1}])^{2}} + \frac{\mathrm{Var}[Y^{1}]\,(\mathrm{E}[Y^{0}])^{2}} {(\mathrm{E}[Y^{1}])^{4}} + \frac{2\,(\mathrm{E}[Y^{0}])^{2}}{n\,(\mathrm{E}[Y^{1}])^{2}} \)

Variance otherwise: \( \frac{\mathrm{Var}[Y^{0}]}{(\mathrm{E}[Y^{1}])^{2}} + \frac{\mathrm{Var}[Y^{1}]\,(\mathrm{E}[Y^{0}])^{2}} {(\mathrm{E}[Y^{1}])^{4}} \)

Handling non-finite values

Effect measures that involve division or a log (RR, logRR, and AR) can produce non-finite values (-Inf, Inf, or NaN) at time points where one of the groups has no events yet: the reference group for RR, the non-reference group for AR (the denominator in each case), and either group for logRR. These arise both in the point estimate and in the influence-curve variance formula, which also divides by group means. All non-finite point estimates and influence-curve variances are mapped to NA_real_ in the output.

When computing bootstrap confidence intervals, non-finite replicates are excluded before calculating variances and quantiles (for the "log-normal" method, replicates equal to 0 are also excluded since the log of 0 is -Inf). This is thought to be a reasonable compromise because:

  • With a continuous (weighted) bootstrap, every subject receives a positive weight, so if the effect measure is finite in the original sample it will be finite in every replicate.

  • With a discrete (resampling) bootstrap, a replicate can only produce a non-finite effect measure when all subjects with events in one of the groups listed above happen to be excluded from it. The chance of this happening in any given replicate shrinks quickly as the number of subjects with an event grows, so typically few if any replicates are affected.

A variance needs at least two values, so in the very rare case where the original point estimate is finite but fewer than two bootstrap replicates remain after exclusion, the variance, the CI bounds, and the point estimate are all returned as NA_real_.

Author

M. Alan Brookhart