ttp
From one or two sample sizes, and either the within-cell (pooled) standard deviation, or one or two separate group standard deviations, generate and calibrate a power curve for either the one-sample t-test or the independent-groups t-test, as well as ancillary statistics. Uses the standard R function power.t.test
to calculate power and then the plt
function in this package to automatically display the annotated power curve with colors.
For both the one and two-group t-tests, power is calculated from a single sample size and single standard deviation. For the two-sample test, the within-group standard deviation is automatically calculated from the two separate group standard deviations if not provided directly. Similarly, the harmonic mean of two separate sample sizes is calculated if two separate sample sizes are provided.
ttestPower(n=NULL, s=NULL, n1=NULL, n2=NULL, s1=NULL, s2=NULL,
mmd=NULL, msmd=NULL, mdp=.8, mu0=NULL,
pdf.file=NULL, pdf.width=5, pdf.height=5, ...)ttp(...)
powercurve.t.test(...)
mmd
and msmd
is provided.d
, the Minimum value of
practical importance. The concept is optional, and only one of mmd
and msmd
is provided.power.t.test
function to calibrate and then calculate the power curve according to the relevant non-central t-distribution. The Plot
function from this package, which in turn relies upon the standard plot
function, plots the power curve. As such, parameters in Plot
for controlling the different colors and other aspects of the display are also available, as are many of the more basic parameters in the usual plot
function.Also plotted, if provided, is the minimal meaningful difference, mmd
, as well as the minimal desired power, mdp
, provided by default. Relevant calculations regarding these values are also displayed at the console. One or both concepts can be deleted from the analysis. Not providing a value mmd
implies that the concept will not be considered, and similarly for setting mdp
to 0.
Invoke the function with the either the within-group (pooled) standard deviation, s
, or the two separate group standard deviations, s1
and s2
, from which s
is computed. If the separate standard deviations are provided, then also provide the sample sizes, either as a single value of n
or as two separate sample sizes, n1
and n2
. If separate sample sizes n1
and n2
are entered, their harmonic mean serves as the value of n
.
For power analysis of the two-sample t-test, the null hypothesis is a zero population mean difference. For a one-sample test, the null hypothesis is specified, and it is this non-null specification of mu0 that triggers the one-sample analysis. Only non-directional or two-tailed tests are analyzed.
The effect size that achieves a power of 0.8 is displayed. If a minimal meaningful difference, mmd
, is provided, then the associated power is also displayed, as well as the needed sample size to achieve a power of 0.8.
If the function is called with no parameter values, that is, as ttp()
, then the values of n1
, n2
and sw must already exist before the function call. If they do, these values are used in the power computations.
Plot
, plot
, power.t.test
.# default power curve and colors
ttestPower(n=20, s=5)
# short name
ttp(n=20, s=5)
# default power curve and colors
# plus optional smallest meaningful effect to enhance the analysis
ttestPower(n=20, s=5, mmd=2)
# power curve from both group standard deviations and sample sizes
# also provide the minimum standardized mean difference of
# practical importance to obtain corresponding power
ttestPower(n1=14, n2=27, s1=4, s2=6, msmd=.5)
# power curve for one sample t-test, triggered by non-null mu0
ttestPower(n=20, s=5, mu0=30, mmd=2)
Run the code above in your browser using DataLab