| sbw_estimate | R Documentation |
sbw_fit objectEstimate a treatment effect from a fitted sbw_fit object
sbw_estimate(object, outcome, estimand, ...)
## S3 method for class 'sbw_fit'
sbw_estimate(
object,
outcome,
estimand,
data = NULL,
probs = 0.5,
horizon = NULL,
B = 1500,
alpha = 0.05,
ci_method = c("wald", "percentile"),
seed = NULL,
...
)
object |
An |
outcome |
A one-sided-response formula naming the outcome, e.g.
|
estimand |
One of |
... |
Passed to methods. |
data |
Optional data frame holding the outcome, for when the weights
were fit on baseline data before outcomes were available. Its rows must
correspond one-to-one, in the same order, to the data passed to
|
probs |
Vector of probabilities in (0, 1), used when |
horizon |
Time |
B |
Number of bootstrap replicates. |
alpha |
Significance level for the confidence interval. |
ci_method |
Either |
seed |
Optional seed set at the start of the bootstrap. |
The bootstrap resamples participants independently (a nonparametric row bootstrap), which is valid under simple randomization. It does not account for stratified or covariate-adaptive randomization (permuted blocks, minimization, biased coin); under those designs the confidence intervals may be miscalibrated.
For estimand = "survival_ratio", if the SBW point estimate or its
bootstrap standard error is non-finite, the unadjusted Kaplan-Meier
ratio is returned instead, with a warning and mc_fail = TRUE.
An object of class sbw_estimate: a list with estimand;
estimate (named by estimand, or q<p> per quantile); se, the
bootstrap standard error (on the log scale when scale = "log"); ci,
a matrix with one row per estimate (lower, upper) on the estimate's own
scale; scale ("log" for "RR", "quantile_ratio", and
"survival_ratio", otherwise "identity"); alpha; and B. Most
estimands also return boot_fail_rate, the fraction of bootstrap
resamples that failed. "survival_ratio" instead returns horizon,
mc_fail, and detail (the full boot_km_ratio() result, which
includes its own boot_fail_rate).
set.seed(1)
n = 100
trial_baseline = data.frame(
age = rnorm(n, 50, 10),
region = sample(c("N", "S"), n, replace = TRUE),
arm = rbinom(n, 1, 0.5)
)
# Design stage: fit weights before any outcomes exist.
sbw = sbw_weights(~ age + region, data = trial_baseline, treatment = arm)
# Analysis stage: outcomes arrive later, one row per participant, same order.
trial_outcomes = data.frame(Y = rbinom(n, 1, plogis(-1 + 0.02 * trial_baseline$age)))
sbw_estimate(sbw, Y ~ 1, estimand = "RR", data = trial_outcomes, B = 200, seed = 1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.