FactorialPowerPlan: sample size, power and effect size calculations for a...

View source: R/factorial_power_plan.R

FactorialPowerPlanR Documentation

sample size, power and effect size calculations for a factorial or fractional factorial experiment

Description

There are three ways to use this function:

  1. Estimate power available from a given sample size and a given effect size.

  2. Estimate sample size needed for a given power and a given effect size.

  3. Estimate effect size detectable from a given power at a given sample size.

That is, there are three main pieces of information: power, sample size, and effect size. The user provides two of them, and this function calculates the third.

Usage

FactorialPowerPlan(
  alpha = 0.05,
  assignment = "unclustered",
  change_score_icc = NULL,
  cluster_size = NULL,
  cluster_size_sd = NULL,
  d_main = NULL,
  effect_size_ratio = NULL,
  icc = NULL,
  model_order = 1,
  nclusters = NULL,
  nfactors = 1,
  ntotal = NULL,
  power = NULL,
  pre_post_corr = NULL,
  pretest = "none",
  raw_coef = NULL,
  raw_main = NULL,
  sigma_y = NULL,
  std_coef = NULL
)

Arguments

alpha

Two sided Type I error level for the test to be performed(default=0.05).

assignment

One of three options: (default=unclustered)

  1. “independent” or equivalently “unclustered”

  2. “within” or equivalently “within_clusters”

  3. “between” or equivalently “between_clusters”

Clusters in this context are preexisting units within which responses may be dependent (e.g., clinics or schools). A within-cluster experiment involves randomizing individual members, while a between-cluster experiment involves randomizing clusters as whole units (see Dziak, Nahum-Shani, and Collins, 2012) <DOI:10.1037/a0026972>

change_score_icc

The intraclass correlation of the change scores (posttest minus pretest). Relevant only if assignment is between clusters and there is a pretest.

cluster_size

The mean number of members in each cluster. Relevant only if assignment is between clusters or within clusters.

cluster_size_sd

Relevant only if assignment is between clusters. The standard deviation of the number of members in each cluster (the default is 0 which means that the clusters are expected to be of equal size).

d_main

Effect size measure: standardized mean difference raw_main/sigma_y.

effect_size_ratio

Effect size measure: signal to noise ratio raw_coef^2/sigma_y^2.

icc

Relevant only if assignment is between clusters or within clusters. The intraclass correlation of the variable of interest in the absence of treatment.

model_order

The highest order term to be included in the regression model in the planned analysis (1=main effects, 2=two-way interactions, 3=three-way interactions, etc.); must be >= 1 and <= nfactors (default=1).

nclusters

The total number of clusters available (for between clusters or within clusters assignment).

nfactors

The number of factors (independent variables) in the planned experiment(default=1).

ntotal

The total sample size available (for unclustered assignment. For clustered assignment, use “cluster_size” and “nclusters.”

power

If specified: The desired power of the test. If returned in the output list: The expected power of the test.

pre_post_corr

Relevant only if there is a pretest. The correlation between the pretest and the posttest.

pretest

One of three options:

  1. “no” or “none” for no pretest.

  2. “covariate” for pretest to be entered as a covariate in the model.

  3. “repeated” for pretest to be considered as a repeated measure.

The option “yes” is also allowed and is interpreted as “repeated.” The option “covariate” is not allowed if assignment is between clusters. This is because predicting power for covariate-adjusted cluster-level randomization is somewhat complicated, although it can be approximated in practice by using the formula for the repeated-measures cluster-level randomization (see simulations in Dziak, Nahum-Shani, and Collins, 2012).

raw_coef

Effect size measure: unstandardized effect-coded regression coefficient.

raw_main

Effect size measure: unstandardized mean difference.

sigma_y

The assumed standard deviation of the response variable after treatment, within each treatment condition (i.e., adjusting for treatment but not adjusting for post-test). This statement must be used if the effect size argument used is either “raw_main” or “raw_coef”.

std_coef

Effect size measure: standardized effect-coded regression coefficient raw_coef/sigma_y.

Value

A list with power, sample size and effect size.

Examples

FactorialPowerPlan(assignment="independent",
                   model_order=2,
                   nfactors=5,
                   ntotal=300,
                   raw_main=3,
                   sigma_y=10)

FactorialPowerPlan(assignment="independent",
                   model_order=2,
                   nfactors=5,
                   ntotal=300,
                   pre_post_corr=.6,
                   pretest="covariate",
                   raw_main=3,
                   sigma_y=10)


MOST documentation built on June 24, 2022, 1:06 a.m.