R/emul_estimate_bootstrap.R
emul_estimate_bootstrap.RdResamples subjects from the original subject-level data and repeats the complete analysis in every bootstrap replicate: cloning, strategy-specific artificial censoring, person-time expansion, censoring-model estimation, weighting, and outcome-model estimation.
emul_estimate_bootstrap(
data,
arms,
id,
treatment,
time_to_treatment,
grace_period,
outcome,
followup,
censoring_predictors = NULL,
censoring_method = c("pooled_logit", "stabilized_logit", "Cox"),
numerator_predictors = NULL,
censoring_time_spline_df = NULL,
method = c("Cox", "logistic"),
predictors = NULL,
n_bootstrap = 200,
conf_level = 0.95,
eps = 1e-06,
seed = NULL
)A data frame with one row per subject.
A character vector of length two. The first element names the strategy of not receiving treatment during the grace period; the second names the strategy of receiving treatment during the grace period.
Name of the column that uniquely identifies subjects.
Name of the binary treatment column.
Name of the numeric time-to-treatment column.
Positive numeric length of the treatment grace period.
Name of the binary outcome column.
Name of the numeric follow-up-time column.
Optional character vector of predictors for the denominator censoring model.
Censoring model passed to estimate_censoring():
"pooled_logit", "stabilized_logit", or "Cox".
Optional character vector of predictors for the
numerator model when censoring_method = "stabilized_logit".
Degrees of freedom for the natural cubic
spline of interval start time in pooled-logistic censoring models. Set to
an integer of at least 2 to use a spline. The default NULL uses a
linear time term. Ignored when censoring_method = "Cox".
Outcome analysis method: "Cox" or "logistic".
Optional adjustment predictors for the outcome model.
Number of bootstrap resamples.
Confidence level for the percentile interval.
Probability floor passed to estimate_censoring() and
weight_cases().
Optional random seed.
A list containing the full-sample effect estimate, percentile confidence limits, bootstrap estimates, and analysis settings. Effects are returned on the exponentiated coefficient scale: a hazard ratio for Cox models and an odds ratio for logistic models.
data(lungcancer)
boot <- emul_estimate_bootstrap(
lungcancer,
arms = c("Control", "Surgery"),
id = "id",
treatment = "surgery",
time_to_treatment = "timetosurgery",
grace_period = 182.62,
outcome = "death",
followup = "fup_obs",
censoring_predictors = c("age", "sex"),
predictors = c("age", "sex"),
n_bootstrap = 3,
seed = 1
)