# Load required packages
library(rbmiUtils)
library(beeca) # for get_marginal_effect()
library(dplyr)
# Load example data
data("ADMI")
# Ensure correct factor levels
ADMI <- ADMI |>
mutate(
TRT = factor(TRT, levels = c("Placebo", "Drug A")),
STRATA = factor(STRATA),
REGION = factor(REGION)
)
# Apply g-computation for binary responder
result <- gcomp_binary(
data = ADMI,
outcome = "CRIT1FLN",
treatment = "TRT",
covariates = c("BASE", "STRATA", "REGION"),
reference = "Placebo",
contrast = "diff",
method = "Ge", # from beeca: GEE robust sandwich estimator
type = "HC0" # from beeca: heteroskedasticity-consistent SE
)
# Print results
print(result)
Run the code above in your browser using DataLab