Learn R Programming

⚠️There's a newer version (1.0.4) of this package.Take me there.

PUMP package

Last updated: May 2023.

Authors:

  • Zarni Htet
  • Kristen Hunter
  • Luke Miratrix
  • Kristin Porter

For randomized controlled trials (RCTs) with a single intervention being measured on multiple outcomes, researchers often apply a multiple testing procedure (such as Bonferroni or Benjamini-Hochberg) to adjust $p$-values. Such an adjustment reduces the likelihood of spurious findings, but also changes the statistical power, sometimes substantially, which reduces the probability of detecting effects when they do exist. However, this consideration is frequently ignored in typical power analyses, as existing tools do not easily accommodate the use of multiple testing procedures. We introduce the PUMP R package as a tool for analysts to estimate statistical power, minimum detectable effect size, and sample size requirements for multi-level RCTs with multiple outcomes. Multiple outcomes are accounted for in two ways. First, power estimates from PUMP properly account for the adjustment in $p$-values from applying a multiple testing procedure. Second, as researchers change their focus from one outcome to multiple outcomes, different definitions of statistical power emerge. PUMP allows researchers to consider a variety of definitions of power, as some may be more appropriate for the goals of their study. The package estimates power for frequentist multi-level mixed effects models, and supports a variety of commonly-used RCT designs and models and multiple testing procedures. In addition to the main functionality of estimating power, minimum detectable effect size, and sample size requirements, the package allows the user to easily explore sensitivity of these quantities to changes in underlying assumptions.

Please see the vignettes for examples of how to use this package.

More details about the package:

We provide below one example of using PUMP to calculate a minimium detectable effect size (MDES). The user specifies the RCT design and model (d_m), the multiple testing procedure (MTP, in this case Holm), the target power (0.8), and the type of power desired (individual power for outcome 1). The user also specifies a variety of design and model parameters, such as the number of outcomes, sample sizes at different levels, variation explained by covariates, etc.

m <- pump_mdes(
  d_m = "d3.2_m3fc2rc",         # choice of design and analysis strategy
  MTP = "HO",                   # multiple testing procedure
  target.power = 0.80,          # desired power
  power.definition = "D1indiv", # power type
  M = 5,                        # number of outcomes
  J = 3,                        # number of schools per block
  K = 21,                       # number districts
  nbar = 258,                   # average number of students per school
  Tbar = 0.50,                  # prop treated
  alpha = 0.05,                 # significance level
  numCovar.1 = 5,               # number of covariates at level 1
  numCovar.2 = 3,               # number of covariates at level 2
  R2.1 = 0.1, R2.2 = 0.7,       # explanatory power of covariates for each level
  ICC.2 = 0.05, ICC.3 = 0.4,    # intraclass correlation coefficients
  rho = 0.4 )                   # how correlated outcomes are

Copy Link

Version

Install

install.packages('PUMP')

Monthly Downloads

236

Version

1.0.2

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Luke Miratrix

Last Published

May 22nd, 2023

Functions in PUMP (1.0.2)

gen_RE_cov_matrix

generate a parameterized covariance matrix from the provided 3 blocks
gen_T.x

Generate treatment assignment vector (simulation function)
convert_params

Converts model params into DGP params (simulation function)
comp_rawp_ss

Helper function for Westfall Young Single Step
get_adjp_minp

Helper function for Westfall Young
comp_rawp_sd

Helper function for Westfall Young Step Down
gen_Yobs

Generate observed outcomes (simulation function)
get_pval_tstat

Function: get_pval_tstat extracts p-value and t statistics from a given fitted model.
gen_base_sim_data

Generate base simulated multi-level data (simulation function)
get_rawpt

Function: get_rawpt
estimate_power_curve

Calculate a power curve for sample size or mdes.
makelist_samp

Convert multi-outcome data structure to list for each outcome.
get_power_results

Calculates different definitions of power (support function)
plot.pumpresult

Plot a pumpresult object (result function)
gen_sim_data

Generate simulated multi-level data (simulation function)
plot.pumpgridresult

Plot a pumpgridresult object (result function)
plot_power_curve

Examine a power curve (result function)
optimize_power

Optimizes power to help in search for MDES or SS
gen_cov_matrix

generate covariance matrix between two variables
plot.pumpgridresult.mdes

Plot a grid pump mdes object
plot.pumpgridresult.power

Plot a grid pump power object
parse_d_m

Return characteristics of a given context/d_m code (support function)
make_model

Function: make.model
parse_power_definition

Parse the power definition
interacted_linear_estimators

Interacted linear regression models
pump_info

Provides details about supported package features (core function)
pump_mdes_grid

Run pump_mdes on varying values of parameters (grid function)
pump_power

Estimate power across definitions (core function)
plot.pumpgridresult.sample

Plot a grid pump sample object
power_curve

Obtain a power curve for a range of sample size or MDES values
plot_power_search

Examine search path of a power search (result function)
pump_mdes

Estimate the minimum detectable effect size (MDES) (core function)
pump_sample_grid

Run pump_sample on varying values of parameters (grid function)
pump_sample_raw

Calculating Needed Sample Size for Raw (Unadjusted) Power
update_grid

Update a single pump call to a grid call (grid function)
validate_d_m

Validate d_m string
gen_corr_matrix

Generate correlation matrix (simulation function)
gen_cluster_ids

Generates school and district assignments (simulation function)
pump_sample

Estimate the required sample size (core function)
pump_power_grid

Run pump_power on varying values of parameters (grid function)
update.pumpresult

Update a pump call, tweaking some parameters (core function)
print_search

Print the search history of a pump result object (result function)
transpose_power_table

Convert power table from wide to long (result function)
print_context

Print context (design, model, parameter values) of pumpresult or pumpgridresult (result function)
pumpresult

pumpresult object for results of power calculations
pumpgridresult

Result object for results of grid power calculations
validate_inputs

Validates user inputs
setup_default_parallel_plan

Setup parallel processing
run_grid

Run grid across any of the core pump functions
PUMP

PUMP: A package for estimating power under multiplicity
calc_J

This function calculates needed J to achieve a given power
calc_df

Calculate degrees of freedom (support function)
check_cor

Check correlation of test statistics (simulation function)
adjp_wyss

Westfall-Young Single Step Adjustment Function
calc_SE

Computes Q_m, the standard error of the effect size estimate
calc_K

Calculates K, the number of districts
adjp_wysd

Westfall Young Step Down Function
calc_nbar

This function calculates needed nbar to achieve a given power
calc_pval

Calculates p-values from t-values
fit_bounded_logistic

Fit a bounded logistic curve
find_best

Determine next point to check for correct power level.