Sample Size / Power Analysis
The main goal of sample size / power analyses is to allow a user to evaluate:
A number of packages exist in R to aid in sample size and power analyses. A few examples are provided in the following sections.
Sample Size / Power Analysis for t-test
The samplesize package provides the simplest method for performing sample size analysis for Student's t-tests. Within the samplesize package, the n.ttest function is used for a t-test power analysis.
n.ttest ( power = PowerLevel, alpha = AlphaLevel, mean.diff = ExpectedMeanDifference, sd1 = StandardDeviationGroup1, k = SampleFraction, design = "Paired/Unpaired", fraction = "balanced/unbalanced", variance = "equal/unequal")
> install.packages ("samplesize")
> n.ttest(power = 0.8, alpha = 0.05, mean.diff = 0.80, sd1 = 0.83, k = 1, design = "unpaired", fraction = "balanced", variance = "equal")
Sample Size / Power Analysis for One-Way ANOVA
The pwr package provides the simplest method for performing sample size analysis for one-way ANOVA. Within the pwr package, the pwr.anova.test function is used for ANOVA power analyses.
pwr.anova.test ( k = NumberOfGroups , n = NumberofObservationsPerGroup , f = EffectSize , sig.level = SignificanceLevel , power = PowerLevel)
> install.packages ("pwr")
> pwr.anova.test ( k = 4 , n = NULL , f = 0.2 , sig.level = 0.05, power = 0.8)