Description Usage Arguments Details Value Note Author(s) References See Also Examples
Compute the Type I Error level necessary to achieve a specified power for a one or twosample ttest, given the sample size(s) and scaled difference.
1 2 3 
n.or.n1 
numeric vector of sample sizes. When 
n2 
numeric vector of sample sizes for group 2. The default value is the value of

delta.over.sigma 
numeric vector specifying the ratio of the true difference (δ) to the population standard deviation (σ). This is also called the “scaled difference”. 
power 
numeric vector of numbers between 0 and 1 indicating the power
associated with the hypothesis test. The default value is 
sample.type 
character string indicating whether to compute power based on a onesample or
twosample hypothesis test. When 
alternative 
character string indicating the kind of alternative hypothesis. The possible values
are 
approx 
logical scalar indicating whether to compute the power based on an approximation to
the noncentral tdistribution. The default value is 
tol 
numeric scalar indicating the tolerance argument to pass to the

maxiter 
positive integer indicating the maximum number of iterations
argument to pass to the 
Formulas for the power of the ttest for specified values of
the sample size, scaled difference, and Type I error level are given in
the help file for tTestPower
. The function tTestAlpha
uses the uniroot
search algorithm to determine the
required Type I error level for specified values of the sample size, power,
and scaled difference.
numeric vector of Type I error levels.
See tTestPower
.
Steven P. Millard ([email protected])
See tTestPower
.
tTestPower
, tTestScaledMdd
,
tTestN
,
plotTTestDesign
, Normal,
t.test
, Hypothesis Tests.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67  # Look at how the required Type I error level for the onesample ttest
# decreases with increasing sample size. Set the power to 80% and
# the scaled difference to 0.5.
seq(5, 30, by = 5)
#[1] 5 10 15 20 25 30
alpha < tTestAlpha(n.or.n1 = seq(5, 30, by = 5),
power = 0.8, delta.over.sigma = 0.5)
round(alpha, 2)
#[1] 0.65 0.45 0.29 0.18 0.11 0.07
#
# Repeat the last example, but use the approximation.
# Note how the approximation underestimates the power
# for the smaller sample sizes.
#
alpha < tTestAlpha(n.or.n1 = seq(5, 30, by = 5),
power = 0.8, delta.over.sigma = 0.5, approx = TRUE)
round(alpha, 2)
#[1] 0.63 0.46 0.30 0.18 0.11 0.07
#
# Look at how the required Type I error level for the twosample
# ttest decreases with increasing scaled difference. Use
# a power of 90% and a sample size of 10 in each group.
seq(0.5, 2, by = 0.5)
#[1] 0.5 1.0 1.5 2.0
alpha < tTestAlpha(10, sample.type = "two.sample",
power = 0.9, delta.over.sigma = seq(0.5, 2, by = 0.5))
round(alpha, 2)
#[1] 0.82 0.35 0.06 0.01
#
# Look at how the required Type I error level for the twosample
# ttest increases with increasing values of required power. Use
# a sample size of 20 for each group and a scaled difference of
# 1.
alpha < tTestAlpha(20, sample.type = "two.sample", delta.over.sigma = 1,
power = c(0.8, 0.9, 0.95))
round(alpha, 2)
#[1] 0.03 0.07 0.14
#
# Clean up
#
rm(alpha)

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.