Skip to contents

Computes simultaneous confidence intervals, which maintain the specified coverage level across all evaluation timepoints jointly. This is useful for making inferences about the entire VE curve.

Usage

add_simultaneous_ci(object, seed = NULL)

Arguments

object

An object of class vefit created by nomatchVE() or matching_ve(). Must

  • contain evaluations at multiple timepoints (length(object$eval_times) > 0),

  • contain bootstrap samples (keep_boot_samples = TRUE when fitting).

seed

Integer seed for random number generation to ensure reproducible critical values for simultaneous confidence intervals. Default is NULL (no seed set).

Value

The input vefit object with the following modifications:

estimates

Each matrix gets additional columns describing the simultaneous confidence interval bounds and construction: simul_lower, simul_upper, simul_n

simul_z_star

Critical values used for each term (cuminc_0, cuminc_1, ve)

simul_excluded_timepoints

Timepoints excluded from simultaneous bands due to insufficient bootstrap samples

Details

Critical values are computed using the bootstrap covariance structure across timepoints. If any timepoint has more than 5% missing bootstrap samples, it is excluded from the simultaneous band and a warning is issued.

Examples

# Fit model with bootstrap samples
fit <- nomatchVE(
  data = simdata,
  outcome_time = "Y",
  outcome_status = "event",
  exposure = "V",
  exposure_time = "D_obs",
  covariates = c("x1", "x2"),
  eval_times = seq(30, 180, by = 30),
  tau = 14,
  boot_reps = 100,
  keep_boot_samples = TRUE
)
#> Bootstrapping 100 samples...
#> Time difference of 33.32416 secs

# Add simultaneous CIs
fit_simul <- add_simultaneous_ci(fit, seed = 123)

# Look at results
fit_simul$estimates
#> $cuminc_0
#>       estimate wald_lower wald_upper wald_n simul_lower simul_upper simul_n
#> 30  0.01163891 0.01017118 0.01331560    100 0.009895009  0.01368592     100
#> 60  0.03790915 0.03400866 0.04223743    100 0.033261760  0.04317687     100
#> 90  0.05857293 0.05279345 0.06494174    100 0.051682224  0.06631812     100
#> 120 0.06691947 0.06077506 0.07363638    100 0.059587887  0.07508110     100
#> 150 0.07548793 0.06902192 0.08250600    100 0.067767137  0.08400909     100
#> 180 0.09576440 0.08786829 0.10428896    100 0.086331163  0.10610869     100
#> 
#> $cuminc_1
#>        estimate  wald_lower  wald_upper wald_n simul_lower simul_upper simul_n
#> 30  0.006221396 0.004208512 0.009188136    100 0.003767239  0.01025784     100
#> 60  0.022928272 0.018800243 0.027936898    100 0.017770525  0.02953799     100
#> 90  0.035306397 0.030107105 0.041365278    100 0.028775443  0.04325362     100
#> 120 0.044201057 0.038467032 0.050744707    100 0.036978175  0.05275748     100
#> 150 0.055121412 0.048595349 0.062466345    100 0.046885519  0.06470580     100
#> 180 0.099205626 0.089270693 0.110112536    100 0.086626102  0.11338513     100
#> 
#> $vaccine_effectiveness
#>        estimate wald_lower wald_upper wald_n simul_lower simul_upper simul_n
#> 30   0.46546592  0.1734213 0.65432610    100  0.07207828   0.6920789     100
#> 60   0.39517839  0.2376575 0.52015114    100  0.18937369   0.5487327     100
#> 90   0.39722334  0.2713054 0.50138274    100  0.23368928   0.5258585     100
#> 120  0.33948883  0.2167159 0.44301818    100  0.18047300   0.4676502     100
#> 150  0.26979833  0.1510724 0.37191997    100  0.11645255   0.3965299     100
#> 180 -0.03593427 -0.1764529 0.08780042    100 -0.21683403   0.1180721     100
#> 

# Visualize
plot(fit_simul, ci_type = "simul")
#> Error in loadNamespace(x): there is no package called ‘ggh4x’