stepwedgepower refactors a one-off academic R script
into a reusable R package for:
This package is based on a PhD biostatistics rotation project on statistical methods for stepped wedge clinical trial designs. According to the rotation evaluation, the project involved:
The software was also used to provide sample size calculations for a study under development. In the permission email shown in the screenshots, Prof. Florin Vaida approved publishing the software to GitHub.
The original file mixed together:
This package reorganizes those steps into exported functions:
prepare_physician_data()summarize_by_specialty()fit_specialty_rate_model()estimate_specialty_rates()analyze_lpa_outcomes()simulate_stepwedge_trial()run_stepwedge_analysis()estimate_power()estimate_type1_error()# install.packages("remotes")
remotes::install_github("AmandaLinLi/stepwedgepower")library(stepwedgepower)
dat0 <- read.csv("data_pseudo_homeDPT.csv")
dat <- prepare_physician_data(dat0)
summary_tbl <- summarize_by_specialty(
dat,
vars = c("n_total_pat", "n_ldl_pat")
)
results <- analyze_lpa_outcomes(dat)
results$overall$logit$glm_rates
results$overall$logit$glmer_rates
power_out <- estimate_power(
n_simulations = 500,
effect_size_or = 2.11,
n_providers_per_specialty = c(40, 40, 40, 40) * 0.25,
tau_provider = 1.21,
base_probs = c(0.05, 0.05, 0.05, 0.05),
pts_per_step = 50 / 5,
seed = 2026
)
power_out$powerA small synthetic dataset is included for quick testing:
ex_dat <- read_example_physician_data()
head(ex_dat)stepwedgepower/
DESCRIPTION
NAMESPACE
R/
man/
inst/extdata/
inst/scripts/
tests/
.github/workflows/
R CMD check inside the container.devtools::document().devtools::check().YOUR_GITHUB_USERNAME in
README.md.DESCRIPTION.