vlt.stats.power.calculateTukeyPairwisePower
calculateTukeyPairwisePower Calculates power for a single pairwise Tukey HSD comparison.
power = vlt.stats.power.calculateTukeyPairwisePower(expectedDifference, expectedMSE, nPerGroup, kTotalGroups, alpha)
calculates the a priori statistical power for a single pairwise
comparison within a larger multi-group experiment. It assumes the
comparison will be analyzed using a Tukey's Honestly Significant
Difference (HSD) test, which controls the family-wise error rate (FWER)
for all possible pairwise comparisons.
This function is primarily intended to validate the results of a power
simulation by providing a precise analytical solution for a balanced,
fixed-effects design. It uses an analytical solution based on the
non-central t-distribution and the Studentized range distribution.
power = vlt.stats.power.calculateTukeyPairwisePower(..., 'method', methodName)
specifies the underlying algorithm used to find the critical value from
the Studentized range distribution.
**********************************************************************
*** DEPENDENCIES ***
**********************************************************************
This function is a wrapper and requires one of the following
functions from the MATLAB File Exchange (or within the vlt package)
to be on your MATLAB path, depending on the chosen 'method':
1. 'qTukey' (Default Method):
- NEEDS: 'vlt.stats.qtukey.m' (originally FEX ID: 3469)
- DESC: A fast, direct approximation of the quantile function.
It is generally accurate and robust. Recommended for most uses.
2. 'cdfTukey' (High Accuracy Method):
- NEEDS: 'vlt.stats.cdfTukey.m' (originally FEX ID: 37450, rewritten)
- DESC: Uses high-accuracy numerical integration for the CDF and
MATLAB's 'fzero' to find the precise critical value (quantile).
May be less stable for large 'k' or extreme probabilities due
to numerical integration challenges.
**********************************************************************
INPUT ARGUMENTS:
expectedDifference - The expected absolute mean difference between
the two specific groups you are comparing.
(e.g., |mu_i - mu_j|)
expectedMSE - The expected Mean Squared Error (MSE) from the
full ANOVA model. This is the pooled
within-group variance (sigma_residual^2).
nPerGroup - The sample size *per group* (or per cell).
This function assumes a balanced design.
kTotalGroups - The **total number of groups/cells** in the
entire experiment. This is the "k" that Tukey's
HSD uses to correct for multiple comparisons.
(e.g., For a 3-group one-way ANOVA, kTotalGroups = 3)
(e.g., For a 2x3 two-way ANOVA, kTotalGroups = 6)
alpha - The desired family-wise error rate (FWER)
or significance level (e.g., 0.05).
OPTIONAL NAME-VALUE PAIR ARGUMENTS (options):
method (string) - Specifies the algorithm to use.
'qTukey' (Default): Uses 'vlt.stats.qtukey.m' for a fast
approximation. Recommended.
'cdfTukey': Uses 'vlt.stats.cdfTukey.m' and 'fzero'
for the highest accuracy (may be unstable).
OUTPUT ARGUMENTS:
power - The calculated statistical power (a scalar
value from 0 to 1). This is the probability
(1 - beta) of correctly rejecting the null
hypothesis for this specific pair.
EXAMPLES:
% Example 1: One-Way ANOVA (k=3), default fast method.
% Expect a 3-unit difference, pooled SD of 2.0 (MSE=4), n=10.
try
pwr1 = vlt.stats.power.calculateTukeyPairwisePower(3, 4, 10, 3, 0.05);
fprintf('One-Way (k=3, qTukey) Power: %.2f%%\n', pwr1 * 100);
catch ME
disp(ME.message); % Display error if dependencies are missing
end
% Example 2: Two-Way ANOVA (2x3, k=6), high accuracy method.
% Same parameters, but k=6 increases the correction, reducing power.
try
pwr2 = vlt.stats.power.calculateTukeyPairwisePower(3, 4, 10, 6, 0.05, 'method', 'cdfTukey');
fprintf('Two-Way (k=6, cdfTukey) Power: %.2f%%\n', pwr2 * 100);
catch ME
disp(ME.message); % Display error if dependencies are missing
end
See also nctcdf, fzero, anovan, multcompare, vlt.stats.cdfTukey, vlt.stats.qtukey