| sbw_weights | R Documentation |
Formula-based front end to get_sbws_for_study(): balances the covariates
named in balance (factors dummy-coded automatically) to the pooled-arm
mean, exactly (imbalance tolerance fixed at zero), matching the paper's
SBW specification. Intended to be called before unblinding, using only
baseline covariates and the randomization assignment.
sbw_weights(balance, data, treatment)
balance |
One-sided formula naming the covariates to balance, e.g.
|
data |
Data frame containing the balance covariates and treatment. |
treatment |
Treatment assignment: either a column name in |
An object of class sbw_fit with elements weights, n_clipped,
max_abs_clipped (see get_sbws_for_study()), balance (the formula),
treatment_name, treatment_levels, treatment (recoded 0/1),
X (the balance design matrix), data, n, and call.
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)
)
sbw = sbw_weights(~ age + region, data = trial_baseline, treatment = arm)
sbw
summary(sbw)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.