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

compute_cumcount_effect_ci(
  obj,
  alpha = 0.05,
  ic = FALSE,
  count_time = NULL,
  ref = 1,
  effect_measure_type = "CD",
  boot_method = "normal"
)

Arguments

obj

A cumcount object containing the count estimates, e.g., as computed by estimate_ipwcount

alpha

The desired nominal significance level of the confidence intervals.

ic

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

count_time

The time at which the cumulative count 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 count_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: "CD" (count difference) or "CR" (count ratio). 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. "CR"). See the Cumulative count 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.

  • ccnt: the cumulative count estimate for the group_label group

  • ccnt_var: the variance of the cumulative count estimate for the group_label group

  • ref_label: the reference group label

  • ref_ccnt: the cumulative count estimate for the reference group

  • ref_ccnt_var: the variance of the cumulative count estimate for the reference group

  • ccntfunc: the point estimate of the effect measure

  • ccntfunc_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 count effect measure types

Count 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}]\)

Count 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.

Handling non-finite values

The count ratio (CR) involves division, so it can produce non-finite values (-Inf, Inf, or NaN) at time points where the denominator group has no events yet. 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 the denominator group 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 & Alexander Breskin