Statistics tutorial · Chapter 05
Comparing groups
This chapter presents the analyses of the Analysis › Compare Groups submenu that compare means, medians or distributions between groups: t tests and their nonparametric equivalents, the one-sample test, multiple t tests, one-, two- and three-way ANOVA (with repeated measures and mixed models), and nested analyses. Contingency tables (chi-square, Fisher's exact test) are covered in the next chapter; Bland-Altman and ROC curves in the chapter "Method comparison and ROC curves".
For each analysis, the tutorial describes exactly what Variance computes. The worked examples use the sample data of the Start window; the values quoted were recomputed with Variance's code.
Elements common to the analyses of this chapter#
Running an analysis#
- Open the data table to analyze (the required table type is given for each analysis: One factor, Two factors or Nested).
- Choose the analysis in Analysis › Compare Groups, or click the Analyze button of the ribbon (or Analysis › Choose an Analysis…): the "Choose an Analysis" window lists the analyses on the left ("Analysis", with a search box and the "Recent" group), and the table ("Table:") and data sets to analyze on the right ("Data sets to analyze", Select All and Deselect All buttons). Analyses that do not suit the table type are grayed out.
- The "<analysis name> – settings" window opens. Its tabs are specific to each analysis; the "Options" tab and the "Data sets" tab (one check box per data set, "Data sets to analyze:") are always present. The OK, Cancel and Defaults (restore the default settings) buttons and the "Save as the default for new analyses" check box are at the bottom of the window.
- After OK, a results sheet is created. It shows the name of the analysis, the Settings… button (Ctrl+Shift+A, also Analysis › Analysis Settings…), Copy and Export…, the line "Input table: …", possible warnings (preceded by ⚠), then the result tabs and the output tables (tabs preceded by ⊞), which can be graphed (Graph These Results) or analyzed in turn (Analyze These Results). Results are recalculated when the data change.
The Options tab#
- "P value" (in the analyses that offer it): "Two-tailed" (default), "One-tailed (second group greater)" or "One-tailed (second group smaller)".
- "Confidence level (%)": level of confidence intervals, 95 by default (50 to 99.99).
- "Significance level (alpha)": threshold α, 0.05 by default (0.0001 to 0.5).
- "Significant digits": number of significant digits displayed (value of the preferences, 4 by default).
- "P value format": how P values are shown (standard with 4 decimals, detailed with 6 decimals, APA style or NEJM style).
The decision rows ("Difference significant at α = 0.05", etc.) read Yes when P < α (strict inequality); in multiple comparison tables, "Significant?" reads Yes when the adjusted P is ≤ α. The "Significance code" row follows fixed thresholds that do not depend on α: ns if P ≥ 0.05, * if P < 0.05, ** if P < 0.01, *** if P < 0.001 and **** if P < 0.0001 (the APA and NEJM styles stop at ***).
Sign conventions#
- t tests: the difference is always B − A, the second column minus the first ("First column (A)", "Second column (B)").
- Multiple comparisons: a row "X vs. Y" gives the mean of X minus the mean of Y.
The Residuals tab#
The parametric t tests and one-way ANOVA have a "Residuals" tab that helps check the normality assumption. A residual is the deviation of a value from what the model predicts: value minus the mean of its group (unpaired tests, ordinary ANOVA), difference of a pair minus the mean difference (paired tests), value minus the effects of its row and column (repeated measures). The tab gives:
- three normality tests of the pooled residuals: "D'Agostino-Pearson (K²)" (at least 8 residuals), "Anderson-Darling (A2*)" (at least 8 residuals; statistic A²* = A²·(1 + 0.75/n + 2.25/n²), P from the approximations of D'Agostino and Stephens) and "Shapiro-Wilk (W)" (3 to 5,000 residuals, Royston's algorithm AS R94); for each, "Test statistic", "P value" and "Passed normality test (alpha = …)?" (Yes if P > α); with too few residuals, the row reads "Not enough residuals";
- "Number of residuals", "Mean" (zero by construction) and "SD" of the residuals;
- the output table "Residuals: QQ plot": the sorted residuals ("Actual residual") and the expected normal quantiles ("Predicted normal quantile" = Φ⁻¹((i − 0.375)/(n + 0.25)), Blom positions). Points lying on a straight line indicate residuals consistent with a normal distribution.
Annotating a graph#
The P values of the comparisons computed are stored with the results: on a graph of the data, Objects › Significance Brackets… draws the brackets and P values (or asterisks), and Objects › Compact Letter Display… places the letters of the compact letter display when the analysis computed them.
Two-Group Comparisons#
This analysis compares two groups, that is, two columns of a One factor table: Student's unpaired t test (equal variances), the t test with Welch's correction, the paired t test, t tests on logarithms (ratio of geometric means, lognormal data) and their nonparametric equivalents: the Mann-Whitney test, the two-sample Kolmogorov-Smirnov test and the Wilcoxon signed-rank test (paired). Besides the P value, Variance reports the size of the difference (B − A) with its confidence interval, an R² (effect size), the F test comparing variances, the effectiveness of pairing and the analysis of residuals.
When to use it#
- You compare two groups on a quantitative variable. With three groups or more, use one-way ANOVA (several t tests between pairs of groups inflate the risk of false positives).
- Unpaired: the groups consist of different subjects (wild-type and knock-out mice). Paired: each value of A is linked to a value of B (same subject before and after, twins, same experiment day, same litter); pairing must follow from the experimental design, not from the results.
- Data consistent with a normal distribution: t test. Different standard deviations, or unequal sample sizes and doubts about the variances: Welch's correction (many authors recommend it by default; it loses almost nothing when variances are equal).
- Strictly positive, right-skewed values with multiplicative effects (concentrations, titers, expression levels): the lognormal option, which compares logarithms and expresses the result as a ratio.
- Ordinal data, very skewed data or outliers, small samples with no information on the distribution: nonparametric tests (Mann-Whitney, Wilcoxon), or Kolmogorov-Smirnov if any difference between distributions (not only in location) matters.
Assumptions and checks#
Parametric tests:
- Independence of observations (between subjects; between pairs for a paired test). It follows from the design and cannot be tested: repeated measurements of the same animal are not independent replicates (see the nested t test).
- Normality of the values in each group (unpaired) or of the differences (paired). Check: the "Residuals" tab (normality tests, QQ plot). The t test tolerates moderate departures when samples are large and of similar size.
- Equal standard deviations (Student's unpaired t test only). Variance shows the F test comparing variances, but choosing the test from this preliminary test is not recommended (it is very sensitive to non-normality): decide in advance, and prefer Welch when in doubt.
- Lognormal option: all values must be > 0; it is the logarithms that must be normally distributed.
Nonparametric tests:
- Mann-Whitney: independent observations, continuous distributions. The test compares ranks; it is sensitive to values of B tending to be larger than those of A. It can be read as a comparison of medians only if both distributions have the same shape (location-shift model), an assumption also required by the Hodges-Lehmann estimator.
- Kolmogorov-Smirnov: detects any difference between the cumulative distributions (location, spread, shape); less powerful than Mann-Whitney for a pure shift.
- Wilcoxon: independent pairs; distribution of the differences symmetric about its median.
Step by step in Variance#
- Create a One factor table ("Start" window, "One factor" type): "Replicates one below the other, one group per column" for independent groups, or "Paired or repeated measures: one subject per row" for paired data. To follow the example, choose "an example" then "Two groups (t test)" or "Paired data (before/after)".
- Enter one column per group. For paired data, each row holds the two values of one pair; a row with a missing value is ignored by the paired tests.
- You can also enter summary data ("Center and error, computed elsewhere" with "Mean, SD, N", "Mean, SEM, N" or "Mean, %CV, N"): only the unpaired t tests (Student and Welch) are then possible; the other options need raw values, and without N the test cannot be computed.
- Menu Analysis › Compare Groups › Two-Group Comparisons.
- "Experimental Design" tab:
- "Experimental design": "Unpaired" or "Paired";
- "Distribution of the data": "Gaussian: parametric test", "Lognormal: test on logarithms (ratio)" or "Not Gaussian: nonparametric test";
- "Unpaired parametric test": "Unpaired t test (equal SDs)" or "Welch's t test (unequal SDs)" (also applies to the unpaired lognormal option);
- "Unpaired nonparametric test": "Mann-Whitney test (ranks)" or "Kolmogorov-Smirnov test (distributions)";
- "Mann-Whitney: apply continuity correction" is unchecked by default and affects only the normal approximation;
- "Wilcoxon: handle zero differences with Pratt's method" (check box, unchecked by default);
- "First column (A)" and "Second column (B)": the two data sets compared. If the choice is invalid (same column, column not analyzed), Variance takes the first two analyzed data sets.
- "Options" tab: "P value", "Confidence level (%)", "Significance level (alpha)", significant digits and P value format (see above), and "Equivalence margin (± difference B − A)" (0 by default: no equivalence test; see below).
- Click OK.
The test performed depends on the combination of choices:
| Experimental design | Distribution of the data | Test computed |
|---|---|---|
| Unpaired | Yes | unpaired t test (Student) or Welch |
| Unpaired | Lognormal | t test (Student or Welch) on log10, ratio of geometric means |
| Unpaired | No | Mann-Whitney or Kolmogorov-Smirnov |
| Paired | Yes | paired t test |
| Paired | Lognormal | ratio paired t test (log10 B − log10 A) |
| Paired | No | Wilcoxon signed-rank test (paired) |
How it is calculated#
Notation: n_A, n_B sample sizes; ȳ_A, ȳ_B means; s_A², s_B² variances (denominator n − 1); D = ȳ_B − ȳ_A; C confidence level (0.95 by default).
Unpaired t test (Student)
s_p² = [ (n_A − 1)·s_A² + (n_B − 1)·s_B² ] / (n_A + n_B − 2) pooled variance
SE = √[ s_p² · (1/n_A + 1/n_B) ] standard error of D
t = D / SE df = n_A + n_B − 2
Each group must have at least 2 values, even for Student's test, whose pooled variance would still be computable with a single value in one group: otherwise the test is refused.
Welch's t test
q_A = s_A² / n_A q_B = s_B² / n_B
SE = √(q_A + q_B)
t = D / SE
df = (q_A + q_B)² / [ q_A²/(n_A − 1) + q_B²/(n_B − 1) ] (Welch-Satterthwaite)
Welch's df is not an integer; Variance uses it as is (the t distribution is computed with the regularized incomplete beta function, without tables or rounding).
P value and confidence interval. T follows Student's t distribution with df degrees of freedom:
two-tailed P = 2 · Prob(T ≥ |t|)
"second group greater" (B > A) P = Prob(T ≥ t)
"second group smaller" (B < A) P = Prob(T ≤ t)
CI of D: D ± t* · SE, t* = quantile 1 − (1 − C)/2 of t(df)
The confidence interval is always two-sided, even when you ask for a one-tailed P value.
Effect size. "R squared (eta squared)" = t² / (t² + df) (with Welch's df for Welch's test): fraction of the total variance explained by group membership.
F test comparing variances. F = larger variance / smaller variance, DFn = n − 1 of the group with the larger variance, DFd = n − 1 of the other; P = min(1, 2 · Prob(F(DFn, DFd) ≥ F)) (two-sided). R's var.test doubles the smaller of the two tails instead: when the larger variance has more degrees of freedom and F is close to 1, it can give a P below 1 where Variance gives 1.
Paired t test. For the n complete pairs, d_i = B_i − A_i:
d̄ = Σ d_i / n s_d = √[ Σ (d_i − d̄)² / (n − 1) ] SE = s_d / √n
t = d̄ / SE df = n − 1 CI: d̄ ± t* · SE
R² (partial eta squared) = t² / (t² + df)
The effectiveness of pairing is measured by Pearson's correlation coefficient r between A and B, with a one-tailed P value (alternative r > 0); "Pairing significantly effective" reads Yes if this P < α.
Lognormal option, unpaired. Each value is replaced by log10(x) (error if a value is ≤ 0), then the t test (Student or Welch) is computed on the logarithms. The result is back-transformed:
ratio of geometric means (B/A) = 10^( mean(log10 B) − mean(log10 A) )
CI of the ratio = 10^(lower limit), 10^(upper limit) of the CI on the log scale
The F test then compares the variances of the logarithms; the rows "Mean of column A/B" remain the arithmetic means of the raw values.
Ratio paired t test. d_i = log10(B_i) − log10(A_i) = log10(B_i/A_i); paired t test on these d_i; "Geometric mean of ratios (B/A)" = 10^d̄, CI = 10^(limits). The pairing correlation is computed on the logarithms.
Mann-Whitney test.
- The N = n_A + n_B values are ranked together (average ranks for ties); R_A and R_B are the rank sums.
- U_A = R_A − n_A(n_A + 1)/2 (number of pairs (a, b) with a > b, ties counting ½); U_B = n_A·n_B − U_A; Variance displays U = min(U_A, U_B).
- Exact P value when there are no ties and n_A ≤ 50 and n_B ≤ 50: the exact null distribution of U_A (all arrangements of the ranks equally likely) is computed by recursion; two-tailed P = min(1, 2·min[Prob(U_A ≤ u_A), Prob(U_A ≥ u_A)]); "second group greater" P = Prob(U_A ≤ u_A); "second group smaller" P = Prob(U_A ≥ u_A).
- Otherwise, normal approximation with tie correction:
E(U_A) = n_A · n_B / 2
Var(U_A) = (n_A · n_B / 12) · [ (N + 1) − Σ(t³ − t) / (N(N − 1)) ]
z = (U_A − E(U_A)) / √Var(U_A)
where the sum runs over the groups of ties (t = number of equal values in a group). With continuity correction enabled, the numerator moves 0.5 toward zero for a two-tailed test (zero stays zero). For a one-tailed test, add 0.5 for "second group greater" or subtract 0.5 for "second group smaller".
"Difference: Actual (B - A)" is the difference between medians. "Hodges-Lehmann difference" is the median of the n_A·n_B differences b_j − a_i. Its confidence interval is obtained by sorting these m = n_A·n_B differences D(1) ≤ … ≤ D(m):
k = ⌊ n_A·n_B/2 − z · √( n_A·n_B·(N + 1) / 12 ) ⌋ z = quantile 1 − (1 − C)/2 of N(0,1)
CI = [ D(k+1) ; D(m−k) ]
(normal approximation, without tie correction; computed if n_A·n_B ≤ 4,000,000).
Kolmogorov-Smirnov test. D = max |F_A(x) − F_B(x)|, the largest gap between the two empirical cumulative distribution functions. Asymptotic P value with Stephens' small-sample correction:
n_e = n_A·n_B / (n_A + n_B)
λ = ( √n_e + 0.12 + 0.11/√n_e ) · D
P = 2 · Σ (k = 1, 2, …) (−1)^(k−1) · exp(−2·k²·λ²) (P = 1 if λ < 0.2)
This P value is approximate and always two-sided: the "P value" option is ignored (the row "P value tails" nevertheless repeats the option chosen).
Wilcoxon signed-rank test (paired).
- d_i = B_i − A_i. Wilcoxon's method (default): zero differences are discarded. Pratt's method (box checked): zeros are ranked with the others (they receive the smallest ranks) and then excluded from the sums.
- The |d_i| are ranked (average ranks for ties); W+ = sum of the ranks of positive differences, W− = sum of the ranks of negative differences; "W (signed rank sum)" = W+ − W−.
- Exact P value when there are neither ties nor zeros among the ranked differences and at most 50 nonzero differences: exact distribution of W+ (2^n equally likely sign patterns); two-tailed P = min(1, 2·min[Prob(W+ ≥ w+), Prob(W+ ≤ w+)]); "second group greater" P = Prob(W+ ≥ w+); "second group smaller" P = Prob(W+ ≤ w+).
- Otherwise, normal approximation without continuity correction (n = number of ranked differences, zeros included with Pratt; n0 = number of zeros ranked):
E(W+) = [ n(n + 1) − n0(n0 + 1) ] / 4
Var(W+) = [ n(n + 1)(2n + 1) − n0(n0 + 1)(2n0 + 1) ] / 24 − Σ(t³ − t) / 48
z = (W+ − E(W+)) / √Var(W+)
The sum Σ(t³ − t) runs over all groups of ties among the ranked |d_i|, including, with Pratt's method, the group of zeros.
"Median" is the median of all differences (zeros included). The Hodges-Lehmann estimator is the median of the M = n(n + 1)/2 Walsh averages (d_i + d_j)/2, i ≤ j, computed on all differences; its CI is [W(k+1) ; W(M−k)] among these sorted averages, with k = ⌊ n(n + 1)/4 − z·√( n(n + 1)(2n + 1)/24 ) ⌋ (normal approximation; computed if n ≤ 3,000).
Effect size (t tests on normal data, neither lognormal nor nonparametric). The P value says whether a difference is demonstrated, not whether it is large; the effect size expresses the difference in standard deviations, which allows studies to be compared and a power to be computed:
unpaired: d = (m_B − m_A) / s_p s_p² = [(n_A − 1)s_A² + (n_B − 1)s_B²] / (n_A + n_B − 2)
paired: d_z = mean of the differences / SD of the differences
g = d · J, J = 1 − 3 / (4·df − 1) (Hedges: small-sample correction,
df = n_A + n_B − 2, or n − 1 if paired)
SE(g) ≈ √[ (n_A + n_B)/(n_A·n_B) + g²/(2(n_A + n_B)) ] (paired: √[ 1/n + g²/(2n) ])
CI of g ≈ g ± z · SE(g) (Hedges and Olkin approximation, 1985)
Cohen's d uses the pooled standard deviation even with Welch's correction. Usual benchmarks (Cohen, 1988): 0.2 small, 0.5 medium, 0.8 large; they do not replace a judgment about the biological or clinical importance of the difference.
Equivalence test (TOST). To show that two means are equivalent, a nonsignificant P value is not enough (absence of evidence is not evidence of absence). With a margin Δ > 0 set before the study (the largest difference of no practical importance), Variance runs two one-sided tests (Schuirmann, 1987), with the difference D = B − A, its standard error and its degrees of freedom (those of the t test, Welch included):
H0: D ≤ −Δ versus D > −Δ : t₁ = (D + Δ) / SE P₁ = Prob(T > t₁)
H0: D ≥ +Δ versus D < +Δ : t₂ = (D − Δ) / SE P₂ = Prob(T < t₂)
TOST P = max(P₁, P₂) equivalence if TOST P < α
Equivalently, the means are equivalent if the 100(1 − 2α)% confidence interval of D (90% for α = 0.05) lies entirely between −Δ and +Δ.
Reading the results#
The "Results" tab starts with "Input table" and a row "Column B: …" / "vs. Column A: …" that recalls the direction of the comparison. Then come the title of the test and:
- "P value", "Significance code", "Significantly different (P < α)?" and "P value tails". The P value is the probability of observing a difference at least as large as the one observed if both populations had the same mean (or, for nonparametric tests, the same distribution). It is not the probability that H0 is true.
- t tests: "t" and "df"; paired tests: "Number of pairs".
- "Size of the difference": "Mean of column A", "Mean of column B", "Difference between means (B - A)", "SEM of the difference" (its standard error), the 95% CI ("95% CI") and "R squared (eta squared)". Paired: "Mean of differences (B - A)", "SD of differences", "SEM of differences", the CI and "R squared (partial eta squared)". With the lognormal option: "Ratio of geometric means (B/A)" or "Geometric mean of ratios (B/A)" and its CI; a ratio of 1 means no difference.
- "F test of the variances" (unpaired): "F", "DFn", "DFd", "P value" and "Significantly different (P < α)?". A small P value signals different standard deviations.
- "Effectiveness of the pairing" (paired): "Correlation coefficient (r)", "One-tailed P value", "Pairing significantly effective". A clearly positive correlation justifies the paired design.
- Mann-Whitney: "P value method", "Rank sums (A, B)", "Mann-Whitney U", then "Difference between medians": medians of A and B, "Difference: Actual (B - A)", "Hodges-Lehmann difference" and its CI.
- Kolmogorov-Smirnov: "Kolmogorov-Smirnov D" and "Difference between medians (B - A)".
- Wilcoxon: "P value method" ("Exact" or "Gaussian approximation"), "Positive and negative rank sums" (the negative sum is shown with a − sign), "W (signed rank sum)", "Number of pairs", then "Median of differences": "Median", "Hodges-Lehmann estimate" and its CI.
- "Effect size" (t tests on normal data): "Cohen's d (difference / pooled SD)" and "Hedges' g" (paired: "Cohen's dz (mean / SD of differences)" and "Hedges' gz"), then "95% CI of g (approximate)".
- "Equivalence test (TOST)" (equivalence margin > 0): "Equivalence margins" (−Δ to Δ), "90% CI of the difference" (for α = 0.05), the two one-sided P values, "TOST P value (larger of the two)" and "Equivalent (both P < 0.05)?".
- "Sample sizes": sample size of each column.
The other tabs: "Residuals" (parametric tests, see above) and "Descriptive statistics" ("Number of values", "Mean", "Std. Deviation", "Standard error of the mean", "Median" of each column). The paired t tests also produce the output table "Differences" (column "Difference (B - A)", raw differences), which can be graphed directly.
The last tab, "Narrative results", states the test in sentences: the difference (difference between the means, or mean of the differences for a paired test, with its confidence interval) for the ordinary t test, the P value, the chance of observing a difference this large if the two populations were identical, the conclusion and, for a paired test, whether the pairing was effective.
Worked example#
Sample data "Two groups (t test)" (One factor table):
Wild type (A, n = 12) : 5.584 5.303 5.128 4.836 5.718 5.605 5.206 5.238 5.235 4.432 5.348 5.378
Knock-out (B, n = 10) : 6.222 7.028 6.113 6.26 5.928 7.277 6.778 7.058 7.034 5.578
Hand calculation of the unpaired t test (default settings):
ȳ_A = 5.250917 s_A² = 0.122100 ȳ_B = 6.527600 s_B² = 0.334513
D = 6.527600 − 5.250917 = 1.276683
s_p² = (11 × 0.122100 + 9 × 0.334513) / 20 = 0.217686
SE = √[ 0.217686 × (1/12 + 1/10) ] = 0.199773
t = 1.276683 / 0.199773 = 6.391 df = 20
t*(0.975 ; 20) = 2.0860 → 95% CI = 1.2767 ± 2.0860 × 0.1998 = [0.860 ; 1.693]
R² = 6.391² / (6.391² + 20) = 0.6713
F = 0.334513 / 0.122100 = 2.740 (DFn = 9, DFd = 11)
Variance shows (excerpt of the "Results" tab):
Unpaired t test
P value <0.0001
Significance code ****
Difference significant at α = 0.05 Yes
P value tails Two-tailed
t 6.391
df 20
Mean of column A (Wild type) 5.251
Mean of column B (Knock-out) 6.528
Difference between means (B - A) 1.277
SEM of the difference 0.1998
95% CI 0.86 to 1.693
R squared (eta squared) 0.6713
F test of the variances
F 2.74
DFn 9
DFd 11
P value 0.1183
Difference significant at α = 0.05 No
The exact P value is 3.1 × 10⁻⁶. The three normality tests of the 22 residuals are not significant (Shapiro-Wilk W = 0.968, P = 0.66).
With "Welch's correction": q_A = 0.122100/12 = 0.010175 and q_B = 0.334513/10 = 0.033451, SE = √0.043626 = 0.2089, t = 6.112, df = 0.043626² / (0.010175²/11 + 0.033451²/9) = 14.23, P = 2.5 × 10⁻⁵, 95% CI = [0.829 ; 1.724].
With "Not Gaussian: nonparametric test" (Mann-Whitney): the ranks of A are 1 to 9 and 11 to 13, so R_A = 81, R_B = 172, U_A = 81 − 12 × 13/2 = 3 (three values of A exceed the smallest value of B), U = 3. Without ties, the P value is exact: P = 2.2 × 10⁻⁵. Hodges-Lehmann: 1.363, 95% CI [0.765 ; 1.790]. Kolmogorov-Smirnov: D = 0.9, P = 7.8 × 10⁻⁵.
Sample data "Paired data (before/after)" with "Paired": the ten differences After − Before are −7.5; −9.8; −6.0; −7.8; −11.9; −7.1; −5.2; −8.6; −4.1; −5.1.
d̄ = −7.31 s_d = 2.3713 SE = 2.3713 / √10 = 0.74988
t = −7.31 / 0.74988 = −9.748 df = 9 P = 4.4 × 10⁻⁶
95% CI = −7.31 ± 2.2622 × 0.74988 = [−9.006 ; −5.614]
r (Before, After) = 0.921, one-tailed P = 7.8 × 10⁻⁵: the pairing is effective
With the Wilcoxon test, the ten differences are negative: W+ = 0, W− = 55, W = −55, and the exact P value is 2/2¹⁰ = 0.0020; median of the differences −7.3, Hodges-Lehmann −7.3, 95% CI [−8.95 ; −5.60]. The ratio paired t test gives a geometric mean ratio After/Before of 0.939 (95% CI 0.925 to 0.954), a decrease of about 6%.
Reporting#
- "The measured level was higher in knock-out mice (6.53 ± 0.58, mean ± SD, n = 10) than in wild-type mice (5.25 ± 0.35, n = 12); difference 1.28 (95% CI 0.83 to 1.72; Welch's t test, t = 6.11, df = 14.2, P < 0.0001, two-tailed)."
- "The measured value decreased by 7.31 on average after treatment (95% CI 5.61 to 9.01; paired t test, t = 9.75, df = 9, two-tailed P < 0.0001; n = 10 subjects)."
- Nonparametric: "median 5.27 versus 6.52; Mann-Whitney test, U = 3, exact P < 0.0001; Hodges-Lehmann shift 1.36 (95% CI 0.77 to 1.79)."
Always state the test (Student or Welch, paired or not), whether P is one- or two-tailed, the sample sizes and the difference with its CI, not only the P value.
Common pitfalls#
- Choosing the test after seeing the results (Welch or Student, one- or two-tailed, parametric or not): decide before the analysis.
- One-tailed P value chosen afterwards: if the effect goes in the direction opposite to the one announced, the one-tailed P is large (> 0.5) and the effect cannot be declared significant.
- Ignoring pairing: an unpaired test on paired data often loses much power; conversely, pairing independent groups is wrong.
- Pseudoreplication: several measurements of the same animal are not n animals; use the mean per animal or the nested t test.
- Concluding there is no effect because P > 0.05: look at the CI of the difference; if it is wide, the study cannot conclude.
- Confusing SD and SEM: the "SEM of the difference" is not the scatter of the data.
- Mann-Whitney is not a test of medians when the distributions do not have the same shape; and it does not fix a lack of independence.
- One-tailed Kolmogorov-Smirnov: Variance always computes a two-sided P value for this test.
- Summary data: only the unpaired t tests are possible, and the "Residuals" tab is then empty.
One-Sample Tests#
This analysis compares each column of a One factor table with a theoretical value fixed in advance (μ0): one-sample t test, t test on logarithms (ratio of the geometric mean to the theoretical value) or Wilcoxon signed rank test. It answers questions such as "does the measured ratio differ from 1?", "does the percentage of control differ from 100?". Each data set analyzed is tested separately and occupies one column of the results.
When to use it#
- The reference value is a constant known without error (theoretical value, standard, expected ratio of 1, 100% of control), not the mean of another measured group: that case needs a two-sample test.
- t test: values consistent with a normal distribution. Test on logarithms: positive, skewed values with a multiplicative effect (ratios, fold changes). Wilcoxon: non-normal or ordinal data, distribution symmetric about its median.
- A paired t test is equivalent to a one-sample t test of the differences with μ0 = 0.
Assumptions and checks#
- Independent observations (experimental design).
- t test: normal population distribution (or a large enough sample); check the shape of the data with Analysis › Describe and Explore › Normality Tests or a graph of the individual values.
- Test on logarithms: all values and μ0 must be > 0.
- Wilcoxon: continuous distribution, symmetric about the median; the test then concerns the median.
Step by step in Variance#
- One factor table, one column per sample, raw values (summary data mean/SD/N are not suitable: each result cell then shows an error message).
- Analysis › Compare Groups › One-Sample Tests.
- "Options" tab:
- "Test": "One sample t test", "One sample t test on logarithms (ratio)" or "Wilcoxon signed rank test";
- "Hypothetical value": μ0 (0 by default);
- "Wilcoxon: values equal to the hypothetical value are handled with Pratt's method": treatment of values equal to μ0 (otherwise they are discarded);
- "P value": "Two-tailed", "One-tailed (second group greater)" (here: the sample is above μ0) or "One-tailed (second group smaller)" (below μ0);
- "Confidence level (%)", "Significance level (alpha)", digits and P value format.
- "Data sets" tab: check the columns to test, then OK.
How it is calculated#
One-sample t test (n values, mean ȳ, standard deviation s):
SE = s / √n
t = (ȳ − μ0) / SE df = n − 1
two-tailed P = 2 · Prob(T ≥ |t|) ; "greater": Prob(T ≥ t) ; "smaller": Prob(T ≤ t)
CI of the discrepancy (ȳ − μ0): (ȳ − μ0) ± t* · SE, t* = quantile 1 − (1 − C)/2 of t(n − 1)
t test on logarithms. With u_i = log10(x_i):
t = ( ū − log10 μ0 ) / ( s_u / √n ) df = n − 1
ratio = 10^ū / μ0 (geometric mean / theoretical value)
CI of the ratio = 10^(limits of the CI of ū − log10 μ0)
The row "Actual mean / median" nevertheless shows the arithmetic mean of the raw values.
Wilcoxon test. d_i = x_i − μ0, then exactly the same procedure as the paired Wilcoxon test (previous section): ranks of |d_i|, W+ and W−, exact P value (distribution of W+) without ties or zeros and for at most 50 nonzero differences, otherwise normal approximation with tie correction and without continuity correction; values equal to μ0 are discarded or handled by Pratt's method depending on the check box. Variance shows W = W+ − W−.
For this test, "Discrepancy" is median − μ0, whereas the interval shown ("95% CI") is the confidence interval of the median estimated by Hodges-Lehmann (Walsh averages of the x_i), expressed in the units of the data, not as a deviation from μ0: to get the CI of the discrepancy, subtract μ0 from both limits.
Reading the results#
The "Results" tab has one column per data set:
- "Theoretical value" (μ0), "Actual mean / median" (mean for the t tests, median for Wilcoxon), "Number of values";
- under the title of the test: "t" and "df" (t tests) or "W (signed rank sum)" (Wilcoxon), "P value", "Significance code", "Significant (alpha=0.05)?";
- "Size of the discrepancy": "Discrepancy" (mean − μ0 or median − μ0) or "Ratio (geometric mean / theoretical)" (test on logarithms), then the confidence interval (see the remark above for Wilcoxon).
A CI of the discrepancy that contains 0 (or a CI of the ratio that contains 1) corresponds to a two-tailed P ≥ 1 − C. For Wilcoxon, Variance does not state here whether the P value is exact.
The last tab, "Narrative results", states the test of each column in sentences: the discrepancy between the mean (the median for Wilcoxon, the geometric mean for the test on logarithms) and the theoretical value, with its confidence interval, the P value, the chance of a discrepancy this large if the population had that value, and the conclusion.
Worked example#
Sample data "Two groups (t test)", μ0 = 5 ("Hypothetical value"), t test:
Wild type: n = 12 ȳ = 5.250917 s = 0.349428 SE = 0.349428 / √12 = 0.100871
t = (5.250917 − 5) / 0.100871 = 2.4875 df = 11 P = 0.0302
t*(0.975 ; 11) = 2.2010 → 95% CI of the discrepancy = 0.2509 ± 0.2220 = [0.0289 ; 0.4729]
Knock-out: discrepancy 1.5276 t = 8.352 df = 9 P < 0.0001 95% CI [1.114 ; 1.941]
Test on logarithms: geometric mean / 5 = 1.048 for Wild type (95% CI 1.003 to 1.095; t = 2.350, P = 0.0385).
Wilcoxon test for Wild type: the deviations from 5 are 0.584; 0.303; 0.128; −0.164; 0.718; 0.605; 0.206; 0.238; 0.235; −0.568; 0.348; 0.378. Ranked by absolute value, the two negative deviations have ranks 2 (−0.164) and 9 (−0.568): W− = 11, W+ = 78 − 11 = 67, W = 67 − 11 = 56. Without ties, the P value is exact: 55 of the 2¹² = 4,096 sign patterns give W+ ≤ 11, hence two-tailed P = 2 × 55/4,096 = 0.0269. Variance shows "Discrepancy" = 5.2705 − 5 = 0.2705 and "95% CI" = 5.036 to 5.466 (CI of the median, that is 0.036 to 0.466 for the deviation from 5).
Reporting#
"The mean value of wild-type mice (5.25 ± 0.35, mean ± SD, n = 12) was above the theoretical value of 5 (discrepancy 0.25; 95% CI 0.03 to 0.47; one-sample t test, t = 2.49, df = 11, P = 0.030, two-tailed)."
Common pitfalls#
- Using this test to compare with the mean of another measured group (a two-sample test is needed).
- Comparing with 100 values normalized to the control of the same experiment (see the box).
- Choosing μ0 after looking at the data.
- Reading the CI of the Wilcoxon test as a CI of the discrepancy: it is the CI of the median.
- Testing several columns without accounting for multiple testing.
Row-by-Row t Tests#
This analysis performs a two-group comparison per row of a Two factors table (for example one test per gene, per protein or per time point), then corrects for multiple testing, either by controlling the false discovery rate (FDR) or by controlling the risk of making at least one error in the family of tests (FWER). It produces a table with one test per row and a "volcano plot".
When to use it#
- You have many variables measured in the same two groups (omics data, cytokine panels…) and each row asks a distinct question. FDR control ("FDR" methods) suits screening, where a small proportion of false discoveries is acceptable; FWER control (Holm-Šídák, Šídák, Bonferroni) suits situations where a single false conclusion would be serious.
- If the rows are the levels of an experimental factor (doses, times) and the interaction interests you, prefer two-way ANOVA, which uses all the data to estimate the variance.
Assumptions and checks#
- Those of the test chosen for each row (independence, normality; equal standard deviations for Student's tests), see the t tests section.
- "Unpaired t test, assume same SD for every row" further assumes that all rows have the same standard deviation: the variance is then estimated from the whole table, with many more degrees of freedom. This is powerful if the assumption holds, misleading otherwise (variables on different scales).
- The Benjamini-Hochberg and two-stage procedures assume independent or positively dependent P values; Benjamini-Yekutieli remains valid under any form of dependence.
- Each row must have at least 2 values in each of the two groups, otherwise it is skipped.
Step by step in Variance#
- Two factors table: one row per variable (row label = name of the gene, time…), one data set per group, replicates in subcolumns ("Replicates per point" in the Start window). For paired data, replicate i of A corresponds to replicate i of B.
- Analysis › Compare Groups › Row-by-Row t Tests.
- "Experimental Design" tab:
- "First data set (A)", "Second data set (B)": the two groups (difference B − A);
- "Design": "Unpaired" or "Paired (replicates are matched)"; when paired, the test is always a paired t test per row (the "Test" choice is ignored);
- "Test": "Welch t test (individual variances per row)" (default), "Unpaired t test, assume same SD for every row", "Unpaired t test per row (same SD in both groups)" or "Mann-Whitney test (nonparametric)".
- "Multiple Comparisons" tab:
- "Multiple comparisons": "FDR, two-stage method of Benjamini, Krieger and Yekutieli" (default), "FDR: Benjamini and Hochberg", "FDR: Benjamini and Yekutieli", "Holm-Šídák", "Hochberg (step-up)", "Šídák-Bonferroni", "Bonferroni-Dunn" or "No correction";
- "Desired FDR (Q, %) or alpha (%)": Q for the FDR methods, α for the others, as a percentage (1% by default).
- "Options" tab: significant digits and P value format (all P values of this analysis are two-tailed). OK.
How it is calculated#
For each row, with the values of A and B in that row:
- Welch: Welch's t test (each group's own variance, Welch-Satterthwaite df).
- Student per row: unpaired t test with the pooled variance of the two groups of the row, df = n_A + n_B − 2.
- SD common to all rows:
s² = Σ (cells with ≥ 2 values) Σ (y − ȳ_cell)² / Σ (n_cell − 1)
df = Σ (n_cell − 1) (same df for every row)
SE = √[ s² · (1/n_A + 1/n_B) ] t = (ȳ_B − ȳ_A) / SE
- Paired: paired t test on the pairs of the row, replicate i of A with replicate i of B; a pair with a missing value is left out (at least 2 complete pairs are needed).
- Mann-Whitney: as in the t tests section (exact P without ties, otherwise normal approximation); the "Difference" column then gives the difference between medians (B − A), "t ratio / U" the U statistic, and SE and df stay empty.
All P values are two-tailed. The m P values obtained (one tested row = one P value) are then adjusted. With p(1) ≤ p(2) ≤ … ≤ p(m) the P values sorted in increasing order:
Bonferroni-Dunn p_adj = min(1, m · p)
Šídák-Bonferroni p_adj = 1 − (1 − p)^m
Holm-Šídák p_adj(i) = max over j ≤ i of [ 1 − (1 − p(j))^(m − j + 1) ] (step-down)
Hochberg p_adj(i) = min over j ≥ i of min(1, (m − j + 1) · p(j)) (step-up)
Benjamini-Hochberg q(i) = min over j ≥ i of min(1, m · p(j) / j)
Benjamini-Yekutieli q(i) = min over j ≥ i of min(1, c(m) · m · p(j) / j)
with c(m) = 1 + 1/2 + … + 1/m
Two-stage step-up method of Benjamini, Krieger and Yekutieli (BKY). At level Q:
1. q* = Q / (1 + Q)
2. r1 = number of rejections of the Benjamini-Hochberg procedure at level q*
3. if r1 = 0: no rejection; if r1 = m: all hypotheses are rejected
4. otherwise estimated m0 = m − r1, then step-up procedure with thresholds i · q* / m0
(Benjamini-Hochberg at level q* · m / m0)
The q value of a P value is the smallest Q at which the procedure rejects that test. Variance computes it by bisection (60 iterations) on the number of rejections. Because the method estimates the number m0 of true null hypotheses, a q value can be smaller than the corresponding P value: this is a normal property of adaptive procedures.
Decision: "Discovery?" (FDR methods) or "Significant?" (other methods) reads Yes if the q value (or adjusted P) is ≤ Q/100 (or α/100).
Reading the results#
The "Multiple t tests" tab starts with "Correction: …" (name of the method), then one row per tested row: "Discovery?" or "Significant?", "P value" (unadjusted), "q value" or "Adjusted P", "Mean of …" for A and for B, "Difference" (B − A), "SE of difference", "t ratio / U" and "df".
Declaring discoveries at Q = 1% means that, on average, at most about 1% of the declared discoveries are expected to be false; it is not the error risk of each row.
The output table "Volcano plot" (point graph created automatically) gives, for each row, the difference on X, and −log10(P) and −log10(adjusted P) on Y: the highest points farthest from 0 on X are the differences that are both large and clear-cut.
Worked example#
Sample data of the Two factors table ("Two-way ANOVA (3 rows × 2 data sets, triplicates)"): three doses in rows, Male (A) and Female (B), three replicates. Default settings (Welch, BKY, Q = 1%). Placebo row: Male 20.96; 20.26; 19.82 and Female 22.09; 24.29; 24.01.
ȳ_A = 20.3467 s_A² = 0.33053 q_A = s_A²/3 = 0.11018
ȳ_B = 23.4633 s_B² = 1.43413 q_B = s_B²/3 = 0.47804
SE = √(0.11018 + 0.47804) = 0.7670 t = 3.1167 / 0.7670 = 4.064
df = 0.58822² / (0.11018²/2 + 0.47804²/2) = 2.875 P = 0.0291
Variance gives:
| Row | P value | q value | Difference | t ratio / U | df | Discovery? |
|---|---|---|---|---|---|---|
| Placebo | 0.0291 | 0.0198 | 3.117 | 4.064 | 2.875 | No |
| Low dose | 0.0136 | 0.0138 | 6.563 | 8.462 | 2.004 | No |
| High dose | 0.0009 | 0.0028 | 11.07 | 9.997 | 3.613 | Yes |
The q values can be checked by hand. The sorted P values are 0.000924; 0.013605; 0.029110 (m = 3). The first rejection requires p(1) ≤ q*/3, i.e. q* = 0.002771 and Q = q*/(1 − q*) = 0.00278. With r1 = 1, the estimated m0 = 2 and the second stage rejects the second test if p(2) ≤ 2q*/2, i.e. q* = 0.013605 and Q = 0.01379. The third is rejected (still with r1 = 1) if p(3) ≤ 3q*/2, i.e. q* = 0.019407 and Q = 0.01979: this q value is smaller than the P value of 0.0291. At Q = 1%, only the high dose is a discovery.
With "Unpaired t test, assume same SD for every row", the common variance is estimated from the six cells (df = 12): the P values become 0.0046, 9.3 × 10⁻⁶ and 3.5 × 10⁻⁸, and all three rows are discoveries with Benjamini-Hochberg at Q = 5%. The gain comes from the degrees of freedom (12 instead of 2 to 4), provided the standard deviation really is the same everywhere.
Reporting#
"The two sexes were compared at each dose with Welch's t test; the false discovery rate was controlled at Q = 1% with the two-stage step-up procedure of Benjamini, Krieger and Yekutieli. Only the high dose showed a difference (11.1; q = 0.003)."
Common pitfalls#
- Forgetting that the default threshold is Q = 1%, not 5%.
- Presenting unadjusted P values as results after correcting.
- Confusing FDR and FWER: a q value of 0.01 does not mean "1% risk that this row is a false positive".
- Choosing "assume same SD for every row" for variables with different units or orders of magnitude.
- With 2 or 3 replicates per group, Welch's test has very few degrees of freedom and little power; the Mann-Whitney test cannot go below P = 0.1 with 3 values versus 3.
One-Way ANOVA#
One-way analysis of variance compares the means of three groups or more (columns of a One factor table). Within the same analysis Variance offers: ordinary ANOVA, the Brown-Forsythe and Welch ANOVAs (unequal standard deviations), ANOVA on logarithms, repeated measures ANOVA with the Geisser-Greenhouse correction, the mixed-effects model (REML) for incomplete repeated measures, the nonparametric Kruskal-Wallis and Friedman tests, tests of equal variances (Brown-Forsythe, Bartlett), the test for linear trend and twelve multiple comparison methods with a compact letter display.
When to use it#
- Three groups or more defined by one factor (treatments, genotypes, times), quantitative variable. With two groups, ordinary ANOVA is equivalent to Student's t test (F = t²).
- Independent groups: "No pairing (independent groups)". Same subjects measured in every condition, or matched blocks (one row = one subject or block): "Paired or repeated measures (one subject per row)".
- Very different standard deviations between groups: Welch's or Brown-Forsythe's ANOVA, and Games-Howell or Dunnett T3 comparisons. Skewed positive values: ANOVA on logarithms. Ordinal data or data far from normal: Kruskal-Wallis or Friedman.
- Ordered groups (increasing doses) where only the trend matters: test for linear trend.
Assumptions and checks#
- Independence of observations (between subjects; between rows for repeated measures).
- Normality of residuals: "Residuals" tab (tests and QQ plot). ANOVA is fairly robust with groups of similar, not too small, sizes.
- Equal standard deviations (ordinary ANOVA and the comparisons that use the pooled variance): Variance shows the Brown-Forsythe test (robust) and Bartlett's test (sensitive to non-normality). As with the F test of the t test, it is better to decide in advance; if the standard deviations clearly differ, choose "Unequal SDs: Brown-Forsythe and Welch ANOVA".
- Repeated measures: sphericity (equal variances of all differences between conditions) rarely holds; the Geisser-Greenhouse correction (default) makes it unnecessary. The random-intercept mixed model assumes compound symmetry (same correlation between all conditions).
- Kruskal-Wallis: independent samples, distributions of the same shape if you want to conclude about medians. Friedman: complete, independent rows.
Step by step in Variance#
- One factor table, one column per group, raw values (summary data are not accepted: message "one-way ANOVA needs raw replicate values"). For repeated measures, one row per subject ("Paired or repeated measures: one subject per row"). Example: data "Three groups (one-way ANOVA)".
- Analysis › Compare Groups › One-Way ANOVA.
- "Experimental Design" tab:
- "Experimental design": "No pairing (independent groups)" or "Paired or repeated measures (one subject per row)";
- "Distribution of the residuals": "Gaussian: ANOVA", "Lognormal: ANOVA on logarithms" or "Not Gaussian: nonparametric test (Kruskal-Wallis / Friedman)";
- "Equal SDs assumed": "Equal SDs: ordinary ANOVA" or "Unequal SDs: Brown-Forsythe and Welch ANOVA" (adds these two tests; independent groups only).
- "RM Design" tab (repeated measures):
- "Repeated measures: analysis method": "Mixed-effects model when values are missing, else RM ANOVA (recommended)" (default), "Repeated measures ANOVA (GLM): subjects with missing values are excluded" or "Mixed-effects model (REML)";
- "Repeated measures: assume sphericity?": "Assumed: no correction" or "Not assumed: Geisser-Greenhouse correction" (default).
- "Multiple Comparisons" tab:
- "Multiple comparisons": "No multiple comparisons", "Every pair of column means" (default), "Each column mean against a control column" or "Linear trend of the means across the columns";
- "Control column": the control column (comparisons with a control);
- "Test" (list): "Tukey (recommended for all pairs)", "Šídák", "Bonferroni", "Holm-Šídák", "Hochberg (step-up)", "Dunnett (compare with control)", "Fisher's LSD (no correction)", "Newman-Keuls (discouraged)", "Games-Howell (unequal SDs)", "Dunnett T3 (unequal SDs)", "FDR, two-stage method of Benjamini, Krieger and Yekutieli", "FDR: Benjamini and Hochberg", "FDR: Benjamini and Yekutieli". With the comparison with a control, Tukey is automatically replaced by Dunnett;
- "Compute compact letter display" (checked by default).
- "Options" tab: "Confidence level (%)", "Significance level (alpha)", digits and P value style. OK.
How it is calculated#
Ordinary ANOVA. k groups, n_j values y_ij in group j, means ȳ_j, N = Σ n_j, ȳ grand mean of all values:
SS_between = Σ_j n_j · (ȳ_j − ȳ)² df = k − 1
SS_within = Σ_j Σ_i (y_ij − ȳ_j)² df = N − k
SS_total = SS_between + SS_within df = N − 1
MS = SS / df F = MS_between / MS_within
P = Prob( F(k − 1, N − k) ≥ F ) R² = SS_between / SS_total
Brown-Forsythe test (equal variances). Compute z_ij = |y_ij − median_j|, then the one-way ANOVA F statistic on the z_ij, df (k − 1, N − k).
Bartlett's test (groups with at least 2 values, nonzero variances s_j²):
s_p² = Σ (n_j − 1)·s_j² / (N − k)
C = 1 + [ Σ 1/(n_j − 1) − 1/(N − k) ] / [ 3(k − 1) ]
B = [ (N − k)·ln s_p² − Σ (n_j − 1)·ln s_j² ] / C P = Prob( χ²(k − 1) ≥ B )
Welch's ANOVA:
w_j = n_j / s_j² W = Σ w_j ȳ_w = Σ w_j·ȳ_j / W
A = Σ w_j·(ȳ_j − ȳ_w)² / (k − 1)
Λ = Σ (1 − w_j/W)² / (n_j − 1)
F_W = A / [ 1 + 2(k − 2)·Λ / (k² − 1) ] df1 = k − 1 df2 = (k² − 1) / (3Λ)
Brown-Forsythe ANOVA (F* statistic):
F* = Σ n_j·(ȳ_j − ȳ)² / Σ (1 − n_j/N)·s_j²
c_j = (1 − n_j/N)·s_j² / Σ_i (1 − n_i/N)·s_i²
df1 = k − 1 df2 = 1 / Σ [ c_j² / (n_j − 1) ] (Satterthwaite)
With equal sample sizes, F* has the same value as F; only df2 changes. Welch's ANOVA, the Brown-Forsythe ANOVA and Bartlett's test use only the groups of at least two values (a single value has no variance).
Test for linear trend (ordinary ANOVA, at least 3 groups; groups receive the scores x_j = 1, 2, …, k in column order):
x̄_w = Σ n_j·x_j / N
S_xy = Σ n_j·(x_j − x̄_w)·(ȳ_j − ȳ) S_xx = Σ n_j·(x_j − x̄_w)²
slope = S_xy / S_xx SS_trend = S_xy² / S_xx
F = SS_trend / MS_within, df (1, N − k) R² = SS_trend / SS_total
Lognormal option. All values (> 0) are replaced by their log10 before the analysis: the means, differences and CIs of the results are then in log10 units (a difference d of logarithms corresponds to a ratio 10^d).
Repeated measures ANOVA (complete rows only; n subjects × k conditions):
SS_total = Σ_i Σ_j (y_ij − ȳ)² df = nk − 1
SS_treatment = n · Σ_j (ȳ_.j − ȳ)² df = k − 1
SS_subjects = k · Σ_i (ȳ_i. − ȳ)² df = n − 1
SS_residual = SS_total − SS_treatment − SS_subjects df = (n − 1)(k − 1)
F = MS_treatment / MS_residual F_matching = MS_subjects / MS_residual
R² = SS_treatment / (SS_treatment + SS_residual)
Geisser-Greenhouse correction. S is the k × k matrix of covariances between columns (denominator n − 1), s̄_d the mean of its diagonal, s̄ the mean of all its elements and s̄_i. the mean of row i:
ε = k²·(s̄_d − s̄)² / [ (k − 1)·( Σ_ij s_ij² − 2k·Σ_i s̄_i.² + k²·s̄² ) ] bounded to [1/(k − 1) ; 1]
corrected P = Prob( F(ε·(k − 1), ε·(n − 1)(k − 1)) ≥ F )
F itself is unchanged; only its degrees of freedom are multiplied by ε. Variance computes ε from the doubly centered matrix (c_ij = s_ij − s̄_i. − s̄_.j + s̄): the same value, without the loss of digits of the expanded denominator. When this matrix is zero (data additive in subjects and conditions), ε = 1.
Mixed-effects model (REML). All values present are used, including those of incomplete subjects:
y_ij = μ + τ_j + u_i + e_ij u_i ~ N(0, σ²_s) (subject) e_ij ~ N(0, σ²)
The fixed effects are coded with an intercept and k − 1 indicators (the first column is the reference). With λ = σ²_s/σ², σ² is profiled out and the restricted likelihood (REML) is maximized over λ ≥ 0: grid over ln λ from −12 to 8 in steps of 0.5, continued beyond 8 while the likelihood still rises (very small residual variance), refinement by golden-section search, and comparison with λ = 0. When the values are exactly additive in subjects and conditions, the residual variance is zero and the restricted likelihood has no maximum: the model is refused ("no residual variance"). The conditions are tested with a Wald test:
F = β̂' · [Cov(β̂)]⁻¹ · β̂ / (k − 1) (β̂ = the k − 1 condition effects)
df1 = k − 1 df2 = N_values − N_subjects − (k − 1)
With complete data, this F is the one of the uncorrected repeated measures ANOVA. The model assumes compound symmetry and applies no Geisser-Greenhouse correction. The effectiveness of matching is tested by the likelihood ratio χ² = 2·(ℓ_REML − ℓ_REML with σ²_s = 0), with P = ½·Prob(χ²(1) ≥ χ²) (the value 0 lies on the boundary of the parameter space). ℓ_REML is the complete restricted log-likelihood, constant −(N − p)/2·ln 2π included (p = number of fixed effects): the value given by lme4 or SAS. The df2 above are not the Satterthwaite or Kenward-Roger approximations of other software (lmerTest in R, SAS): the F statistic is the same, its P value may differ.
Kruskal-Wallis (all values ranked together, average ranks for ties; R_j rank sum of group j):
H = [ 12 / (N(N + 1)) ] · Σ ( R_j − n_j(N + 1)/2 )² / n_j
= [ 12 / (N(N + 1)) ] · Σ R_j² / n_j − 3(N + 1)
corrected H = H / [ 1 − Σ(t³ − t) / (N³ − N) ] P = Prob( χ²(k − 1) ≥ H )
Variance computes the first form: it is exactly 0 when the mean ranks are equal, whereas the second one leaves a rounding noise that moves P away from 1.
If all the values are equal, the ranks carry no information and the test is not computed.
Friedman (ranks within each row; n complete rows, k columns, R_j rank sum of column j):
Fr = [ 12·Σ R_j² − 3·n²·k·(k + 1)² ] / [ n·k·(k + 1) − Σ(t³ − t) / (k − 1) ]
P = Prob( χ²(k − 1) ≥ Fr )
Both P values come from the chi-square approximation (Variance displays "Approximate").
Dunn's test (after Kruskal-Wallis or Friedman), for each pair:
Kruskal-Wallis: SE = √{ [ N(N + 1)/12 − Σ(t³ − t) / (12(N − 1)) ] · (1/n_i + 1/n_j) }
Friedman : SE = √[ k(k + 1) / (6n) ] (mean ranks = R_j / n)
z = (mean rank_i − mean rank_j) / SE P = 2·Prob(Z ≥ |z|)
The P values are adjusted by the chosen method when it applies to arbitrary P values: Šídák, Holm-Šídák, Hochberg, the FDR methods (q values) or no correction with "Fisher's LSD (no correction)". The methods specific to means (Tukey, Dunnett, Newman-Keuls, Games-Howell, Dunnett T3) and Bonferroni give the Bonferroni correction (× number of comparisons), the usual practice for Dunn's test. As in the other multiple comparison tables, "Significant?" is Yes if the adjusted P value is ≤ α.
Multiple comparisons after ANOVA. For the pair (i, j), with MSE and df_error taken from the ANOVA (MS_within and N − k; MS_residual and (n − 1)(k − 1) for repeated measures; σ² and df2 of the mixed model):
difference = ȳ_i − ȳ_j SE = √[ MSE · (1/n_i + 1/n_j) ] t = difference / SE
unadjusted P = 2·Prob( T(df_error) ≥ |t| )
| Test | Adjusted P | Confidence interval |
|---|---|---|
| Tukey (Tukey-Kramer if unequal n) | Prob(Q(k, df) ≥ q), q = √2·abs(t) | difference ± q*(k, df)/√2 · SE |
| Šídák | 1 − (1 − p)^m | t at 1 − α_S/2, α_S = 1 − C^(1/m) |
| Bonferroni | min(1, m·p) | t at 1 − (1 − C)/(2m) |
| Holm-Šídák | step-down (previous section) | none (SE shown) |
| Hochberg | step-up (previous section) | none (SE shown) |
| Dunnett | 1 − Prob(max abs(T_j) ≤ abs(t)) | difference ± c·SE |
| Fisher's LSD | p (no adjustment) | t at 1 − (1 − C)/2 |
| Newman-Keuls | Prob(Q(r, df) ≥ q) | none |
| Games-Howell | Prob(Q(k, df_ij) ≥ q), Welch SE | difference ± q*(k, df_ij)/√2 · SE |
| Dunnett T3 | studentized maximum modulus (m, df_ij) | difference ± c_SMM·SE |
| FDR (BKY, BH, BY) | q values (previous section) | none |
Details:
- m is the number of comparisons in the family; Q(k, df) is the studentized range of k means. Variance computes its probabilities and quantiles by numerical integration (Gauss-Legendre) and bisection, without tables.
- Dunnett: the statistics T_j of the m comparisons with the control follow a multivariate t distribution with correlations ρ_jl = λ_j·λ_l, λ_j = √(n_j / (n_j + n_0)), where n_0 is the size of the control group; the P value and the two-sided critical value c (such that Prob(max abs(T_j) ≤ c) = C) are obtained by numerical integration, which remains exact with unequal sample sizes. Dunnett only makes sense with the comparison with a control.
- Newman-Keuls: r is the number of means spanned by the pair in the ordered list of means; each pair is judged on its own P value, without the sequential stopping rule of the classical procedure. This method does not control the familywise error rate.
- Games-Howell and Dunnett T3 do not use MSE: SE = √(s_i²/n_i + s_j²/n_j) and the Welch-Satterthwaite df_ij for each pair; Dunnett T3 uses the studentized maximum modulus distribution of m independent comparisons (critical value c_SMM).
- "Significant?" (or "Discovery?") reads Yes if the adjusted P (or q) is ≤ α. The CIs use the "Confidence level (%)": decision and CI agree only if C = 1 − α.
Compact letter display. When all pairs are compared and the box is checked, Variance builds the letters with Piepho's (2004) "insert-and-absorb" algorithm from the significant pairs: two groups sharing a letter are not significantly different. The (lowercase) letters are assigned in column order.
Reading the results#
Ordinary ANOVA, "ANOVA results" tab:
- "ANOVA summary": "F", "P value", "Significance code", "Means differ significantly at α = 0.05", "R squared";
- with "Equal SDs assumed" = "No": "Brown-Forsythe ANOVA test" ("F*", "DFn", "DFd", "P value") and "Welch's ANOVA test" ("W", "DFn", "DFd", "P value");
- "Brown-Forsythe test (equal variances)": "F", "DFn", "DFd", "P value", "SDs differ significantly at α = 0.05" (with the α chosen instead of 0.05);
- "Bartlett's test": "Bartlett's statistic (corrected)", "DF", "P value".
"ANOVA table" tab: "SS", "DF", "MS", "F", "DFd" (denominator degrees of freedom of F, the numerator ones being in "DF"), "P value" for "Between groups", "Within groups (residual)" and "Total". "Test for linear trend" tab (when requested): "Slope" (change in the mean from one column to the next), "R squared", "F (1, DFd)", "P value", "Is there a linear trend (P < 0.05)?".
Repeated measures (ANOVA): "Repeated measures ANOVA" with "Sphericity assumed (equal variances of the differences)", "F", "P value" (Geisser-Greenhouse corrected if the correction is requested), "Geisser-Greenhouse's epsilon", "R squared"; then "Effectiveness of the matching" ("F", "P value", "Significant matching at α"). The "ANOVA table" tab has the rows "Between groups", "Between subjects (rows)", "Residual" and "Total"; its F and P are those of the uncorrected test.
Mixed model: "Mixed-effects model (REML)" ("F", "DFn", "DFd", "P value"…), "Random effects" ("SD of subjects", "Variance of subjects", "SD of the residual", "Variance of the residual"), "Effectiveness of the matching" ("Chi-square (likelihood ratio)", "P value"), "Data summary" ("Subjects (rows)", "Number of values analysed", "Missing values", "Restricted log-likelihood").
Nonparametric: "Kruskal-Wallis test" or "Friedman test" ("P value", "P value method", "Medians differ significantly at α = 0.05", "Number of groups", statistic), "Data summary" ("Mean rank of …"); "Multiple comparisons" tab with "Dunn's multiple comparisons test (…)", columns "Difference of mean ranks", "Significant?", "Summary", "Adjusted P Value".
Multiple comparisons (ANOVA): "Multiple comparisons" tab ("Mean Diff.", CI or "SE of difference", "Significant?" or "Discovery?", "Summary", "Adjusted P Value" or "q value"); "Multiple comparisons (details)" tab ("Mean Diff.", "SE of difference", "t or q" (q for Tukey, Games-Howell and Newman-Keuls, t otherwise), "DF", "Unadjusted P"; the columns "Mean 1" and "Mean 2" are left empty); "Compact letter display" tab.
Other outputs: "Residuals" and "Descriptive statistics" tabs (no Residuals tab for the nonparametric tests), tables "Forest plot: multiple comparisons (95% CI)", "Residuals: QQ plot" and "Forest plot: data set means (95% CI)" (each mean with its t-based CI, ȳ ± t*(n − 1)·SEM).
Interpretation: a small overall P value indicates that not all means are equal, without saying which ones differ; the multiple comparisons (or the trend test) answer that question. Conversely, comparisons can be significant with a non-significant overall F, or the reverse: the two approaches do not test the same hypothesis.
The last tab, "Narrative results", states the test in sentences: the share of the variance due to the differences between the groups (R²), the P value, the chance of observing differences this large if all the groups had the same mean (the same distribution for Kruskal-Wallis and Friedman), the conclusion and, with repeated measures, whether the matching was effective.
Worked example#
Sample data "Three groups (one-way ANOVA)" (8 values per group):
Control : 36.4 34.64 33.55 31.72 37.23 36.53 34.04 34.23
Treated A : 42.22 37.2 42.92 43.11 41.01 45.49 40.41 41.22
Treated B : 48.38 55.87 53.1 54.66 54.52 46.43 52.28 55.34
Hand calculation:
ȳ_1 = 34.7925 ȳ_2 = 41.6975 ȳ_3 = 52.5725 ȳ = 43.0208
s² = 3.3478 ; 5.8188 ; 11.7649
SS_between = 8 × [ (−8.2283)² + (−1.3233)² + 9.5517² ] = 1285.53 df = 2
SS_within = 7 × (3.3478 + 5.8188 + 11.7649) = 146.52 df = 21
F = (1285.53/2) / (146.52/21) = 642.76 / 6.9772 = 92.12 P = 4.0 × 10⁻¹¹
R² = 1285.53 / 1432.05 = 0.8977
Tukey comparisons: SE = √(6.9772 × (1/8 + 1/8)) = 1.3207. For Control vs. Treated A, difference −6.905, t = −5.228, q = √2 × 5.228 = 7.394; the critical value q*(0.95; 3; 21) is 3.5646, so the half-width of the CI is 3.5646/√2 × 1.3207 = 3.329. Variance shows:
Tukey multiple comparisons test
Mean Diff. 95% CI Significant? Summary Adjusted P Value
Control vs. Treated A -6.905 -10.23 to -3.576 Yes *** 0.0001
Control vs. Treated B -17.78 -21.11 to -14.45 Yes **** <0.0001
Treated A vs. Treated B -10.88 -14.2 to -7.546 Yes **** <0.0001
and the letters a, b, c (the three groups differ pairwise). The variances do not clearly differ (Brown-Forsythe F(2, 21) = 0.805, P = 0.46; Bartlett 2.59, P = 0.27). With "Unequal SDs: Brown-Forsythe and Welch ANOVA": Welch W(2, 13.26) = 83.64, P = 3.0 × 10⁻⁸; Brown-Forsythe F*(2, 16.72) = 92.12 (equal to F, equal sample sizes). Comparison with the control (Dunnett): critical value c = 2.370, adjusted P values 6.8 × 10⁻⁵ and 1.7 × 10⁻¹¹. Trend test: slope 8.89 per column, F(1, 21) = 181.2, P < 0.0001.
Kruskal-Wallis on the same data: rank sums 37, 99 and 164 (mean ranks 4.625; 12.375; 20.5), H = 12/(24 × 25) × (37² + 99² + 164²)/8 − 3 × 25 = 20.165, P = 4.2 × 10⁻⁵. Dunn: SE = √(24 × 25/12 × 2/8) = 3.536; Control vs. Treated A: z = −7.75/3.536 = −2.19, P = 0.0284, adjusted × 3 = 0.085 (not significant), whereas Tukey declared it significant: rank tests lose power with small groups.
Repeated measures: type this table (6 subjects in rows, 3 conditions T1, T2, T3) and choose "Paired or repeated measures (one subject per row)":
T1: 45 42 36 39 51 44 T2: 50 42 41 35 55 49 T3: 55 45 43 40 59 56
SS_total = 858.94 SS_treatment = 143.44 SS_subjects = 658.28 SS_residual = 57.22
F = (143.44/2) / (57.22/10) = 71.72 / 5.722 = 12.53 df (2, 10) uncorrected P = 0.0019
ε = 0.638 → corrected df (1.28, 6.38) → P (Geisser-Greenhouse) = 0.0090
Matching: F = 131.66 / 5.722 = 23.01 (5, 10), P < 0.0001 R² = 0.715
Tukey (MSE = 5.722, df = 10): T1 vs. T2 P = 0.22; T1 vs. T3 P = 0.0015; T2 vs. T3 P = 0.026; letters a, a, b. The forced mixed model gives the same F (12.53; df 2 and 10), σ²_s = 41.98, σ² = 5.722, matching χ² 16.1 (P < 0.0001). If you delete the T3 value of the 4th subject, the default setting switches to the mixed model: F(2, 9) = 12.76, P = 0.0024, with 17 values. The Friedman test gives Fr = 10.17 (correction for the tie of the 2nd subject), P = 0.0062.
Reporting#
"The three groups differed (one-way ANOVA, F(2, 21) = 92.1, P < 0.0001, R² = 0.90). Tukey's comparisons showed that each treatment increased the value relative to control (Treated A: +6.9, 95% CI 3.6 to 10.2; Treated B: +17.8, 95% CI 14.5 to 21.1) and that B exceeded A (+10.9, 95% CI 7.5 to 14.2); adjusted P values: 0.0001 for Treated A versus control, < 0.0001 for the other two comparisons."
For repeated measures: "Repeated measures ANOVA with the Geisser-Greenhouse correction (ε = 0.64): F(1.28, 6.38) = 12.5, P = 0.009."
Common pitfalls#
- Running t tests between all pairs instead of an ANOVA followed by corrected multiple comparisons.
- Choosing the comparison method after seeing the results; Fisher's LSD and Newman-Keuls do not protect against familywise false positives.
- Tukey to compare with a control: use the comparison with a control (Dunnett), which is more powerful; conversely, Dunnett with "Every pair of column means" makes no sense.
- Unequal standard deviations: checking "Unequal SDs: Brown-Forsythe and Welch ANOVA" does not change the multiple comparison test; choose Games-Howell or Dunnett T3 yourself.
- Ignoring the matching of repeated measures, or treating technical replicates as subjects (see nested ANOVA).
- Missing values in repeated measures: with "Repeated measures ANOVA (GLM)", incomplete subjects are excluded from the ANOVA but the means used by the multiple comparisons include all values; keep the default setting (mixed model).
- Reading the "ANOVA table" tab of repeated measures: its P value is not corrected; the corrected P is in "ANOVA results".
- Lognormal option with matching: the "Residuals" tab is then computed on the untransformed values; examine the residuals of the logarithms yourself instead.
- Trend test: it assumes equally spaced scores 1, 2, 3… in column order; it does not take actual, unequally spaced doses into account.
Two-Way ANOVA#
Two-way ANOVA analyzes a Two factors table: one factor defines the rows (doses, times…), the other the data sets (sex, genotype…), and the replicates are in subcolumns. It tests the effect of each factor and their interaction (does the effect of one factor depend on the level of the other?), then compares cell means. Variance handles the ordinary design (type III sums of squares, valid with unequal sample sizes), repeated measures on the row factor or on both factors (repeated measures ANOVA for a complete balanced design) and the mixed-effects model (REML) when values are missing.
When to use it#
- Two crossed factors, every combination (cell) being observed, with a quantitative variable: for example three doses × two sexes.
- Without matching: "No matching: ordinary two-way ANOVA". Each subject of a column measured at every row (time course, several doses in the same animal): "Each column represents a subject group measured at every row (RM by row factor)". Each subject measured in every cell: "Both factors are repeated measures".
- To compare two groups at each row while treating each row as a separate question (screening), see multiple t tests instead.
Assumptions and checks#
- Independent observations (or subjects, for repeated measures).
- Normality of residuals and equal variances in all cells: the residual variance is common to all cells. This analysis has no "Residuals" tab; check the scatter of each cell visually (graph of the replicates) or analyze the residuals with other tools.
- Repeated measures: sphericity for the repeated factor. Variance shows the Geisser-Greenhouse ε of the repeated factor but does not apply a correction to the P values of two-way ANOVA; an ε clearly below 1 signals P values that are too optimistic.
- Mixed model: random intercept per subject (compound symmetry).
Step by step in Variance#
- Create a Two factors table with replicates ("Replicates per point" in the Start window); row labels = levels of the row factor, one data set per level of the column factor. For repeated measures, each subcolumn is a subject: with "RM by row factor", subcolumn 1 of data set A and subcolumn 1 of data set B are two different subjects; with "Both factors are repeated measures", subcolumn 1 is the same subject in all data sets. Example: "Two-way ANOVA (3 rows × 2 data sets, triplicates)".
- Analysis › Compare Groups › Two-Way ANOVA.
- "RM Design" tab:
- "Repeated measures": "No matching: ordinary two-way ANOVA" (default), "Each column represents a subject group measured at every row (RM by row factor)" or "Both factors are repeated measures";
- "Repeated measures: analysis method": "Mixed-effects model when values are missing, else RM ANOVA (recommended)" (the mixed model is used as soon as the cells do not all have the same number of values), "Repeated measures ANOVA (GLM): subjects with missing values are excluded" or "Mixed-effects model (REML)".
- "Model" tab: "Fit the full model (with interaction)" (checked by default; unchecked, the model is additive, without interaction).
- "Factor Names" tab: "Name of the row factor" and "Name of the column factor" (names used in the ANOVA table).
- "Multiple Comparisons" tab:
- "Multiple comparisons": "None", "Pairs of cells within each row" (default), "Pairs of cells within each column", "Column means (main effect of the columns)" or "Row means (main effect of the rows)";
- "Test": "Tukey", "Šídák" (default), "Bonferroni", "Holm-Šídák", "Hochberg (step-up)", "Fisher's LSD", "FDR, two-stage method (BKY)" or "FDR: Benjamini and Hochberg";
- "Family": "One family per row (or column)" (default) or "A single family of comparisons".
- "Options" tab: "Confidence level (%)", "Significance level (alpha)", digits and P value style. OK.
How it is calculated#
Ordinary design: type III sums of squares. Each factor is coded with sum-to-zero contrasts (effect coding: level j < last gets 1 in its column, the last level gets −1 everywhere); the interaction is coded by the products of these columns. The full model is fitted by least squares; the sum of squares of a term is the increase in the residual sum of squares when the columns of that term are removed from the full model:
SS_term = RSS(model without the term) − RSS(full model)
df_term = rank(full) − rank(without the term)
df_resid = N − rank(full) MS_resid = RSS(full) / df_resid
F = (SS_term / df_term) / MS_resid P = Prob( F(df_term, df_resid) ≥ F )
Share of the total variation (%) = 100 · SS_term / SS_total
With equal sample sizes in all cells (a rows, b columns, n replicates), the classical formulas are recovered:
SS_rows = b·n · Σ_i (ȳ_i.. − ȳ)² df = a − 1
SS_columns = a·n · Σ_j (ȳ_.j. − ȳ)² df = b − 1
SS_interaction = n · Σ_i Σ_j (ȳ_ij. − ȳ_i.. − ȳ_.j. + ȳ)² df = (a − 1)(b − 1)
SS_residual = Σ_i Σ_j Σ_k (y_ijk − ȳ_ij.)² df = a·b·(n − 1)
With unequal sample sizes, type III SS do not add up: their sum, and that of the "Share of the total variation (%)", may differ from SS_total and from 100%.
Sums of squares no larger than the rounding noise of the computation, (64ε)²·Σy² (ε = 2.2·10⁻¹⁶), are treated as zero: with replicates identical within each cell, F is then infinite (undefined when the effect is zero too) rather than a ratio of rounding errors. The same rule applies to one-way and repeated measures ANOVA.
Repeated measures, balanced design (GLM). Let A be the column factor (a levels), B the row factor (b levels) and s the number of subjects per column (subcolumns); Variance uses the first s values of each cell, s being the smallest cell size. The full model is always fitted: the choice of the additive model applies only to the ordinary design and to the mixed model. The sums of squares are computed on the values minus the first one (an exact subtraction for nearby values), the residual directly.
"RM by row factor" (subjects nested within the levels of A, measured at all levels of B):
SS_A, SS_B, SS_AB as above (n = s)
SS_subjects = b · Σ_i Σ_k (ȳ_subject ik − ȳ_i)² df = a·(s − 1)
SS_residual = SS_total − SS_A − SS_B − SS_AB − SS_subjects df = a·(s − 1)·(b − 1)
F_A = MS_A / MS_subjects F_B = MS_B / MS_residual F_AB = MS_AB / MS_residual
F_subjects = MS_subjects / MS_residual
"Both factors are repeated measures" (the same s subjects in every cell):
SS_S = a·b · Σ_k (ȳ_k − ȳ)² df = s − 1
SS_A×S = b · Σ_i Σ_k (ȳ_ik − ȳ_i − ȳ_k + ȳ)² df = (a − 1)(s − 1)
SS_B×S = a · Σ_j Σ_k (ȳ_jk − ȳ_j − ȳ_k + ȳ)² df = (b − 1)(s − 1)
SS_residual = SS_total − SS_A − SS_B − SS_AB − SS_S − SS_A×S − SS_B×S
df = (a − 1)(b − 1)(s − 1)
F_A = MS_A / MS_A×S F_B = MS_B / MS_B×S F_AB = MS_AB / MS_residual F_S = MS_S / MS_residual
The row "Geisser-Greenhouse's epsilon (RM factor)" gives the ε of the row factor (formula of the previous section), computed from the pooled within-group covariance matrix ("RM by row factor") or from the subject × level-of-B means ("Both factors"). The P values are not corrected.
Mixed model (REML). Same effect coding, random intercept per subject, REML fit as for one-way ANOVA; each term is tested with a Wald F (F = β̂'·Cov(β̂)⁻¹·β̂ / q for the q coefficients of the term). Denominator degrees of freedom (N values, S subjects, p fixed effects):
"RM by row factor": interaction and row factor: N − [S + (b − 1) + (a − 1)(b − 1)]
column factor: S − a
"Both factors" : all terms: N − (S + p − 1)
This model has a single random effect (the subject): with "Both factors", it does not model the subject × factor interactions that the repeated measures ANOVA uses as error terms, so its results can differ from those of the ANOVA.
Multiple comparisons. Each comparison uses the mean and size of each cell (or of each whole column or row for main effects, raw mean of all its values) and a common error variance: MS_residual of the ordinary ANOVA, σ² and its df for the mixed model, MS of the within-subject error term ("Residual") for repeated measures. SE = √[MSE·(1/n_i + 1/n_j)], t = difference/SE, then the adjustment chosen (see one-way ANOVA; for Tukey, k is the number of means compared in the family). With "One family per row (or column)", each row (or column) forms a family; with "A single family of comparisons", all unadjusted P values are re-adjusted together with the corresponding method (Šídák for Tukey and Šídák, Bonferroni, Holm-Šídák, none for Fisher, the FDR chosen), and the confidence intervals keep the width computed family by family. For repeated measures, Variance uses the within-subject error term even for comparisons between levels of the non-repeated factor (a simplification). With the model without interaction, these raw cell means differ from the means adjusted by the model that other software compares (emmeans in R).
Reading the results#
"ANOVA table" tab, columns "SS", "DF", "MS", "F", "DFd", "P value", "Summary", "Share of the total variation (%)"; rows "Interaction", row factor, column factor (with the names chosen), "Residual", "Total". For repeated measures, "Subject", the "… × Subject" terms (both factors repeated) and "Geisser-Greenhouse's epsilon (RM factor)" are added; with the mixed model, only DF, F, P and Summary are filled, and a last row "Mixed-effects model (REML)" gives the number of subjects and values.
Interpret the interaction first: if it is important, the effect of one factor depends on the other, and the main effects (averaged over the other factor) are hard to interpret on their own; look then at the comparisons within rows or columns.
"Cell means" tab: mean of each cell. "Multiple comparisons" tab: title of the test, then, for each row (or column, or "Main effect"), the comparisons "X vs. Y" with "Mean Diff.", CI, "Significant?", "Summary" and "Adjusted P Value" (the CI is empty for Holm-Šídák and the FDR methods). Only the comparisons within rows are stored for annotating a graph.
The last tab, "Narrative results", restates in sentences each tested row of the ANOVA table: "Is there an effect of Dose? Dose explains 80.8% of the total variance. P < 0.0001. If Dose has no overall effect, the probability of observing an effect at least this large by chance alone in an experiment of this size would be less than 0.01%. The effect is highly significant (P < 0.001)." When the interaction is significant, it points out that the P values of the main effects are difficult to interpret; when the model is fitted without interaction, it recalls what this choice assumes; with repeated measures, it says whether the matching was effective.
Worked example#
Data "Two-way ANOVA (3 rows × 2 data sets, triplicates)"; factor names "Dose" and "Sex":
Male Female
Placebo 20.96 20.26 19.82 22.09 24.29 24.01
Low dose 28.02 28.09 28.09 33.08 35.37 35.44
High dose 35.61 37.4 35.36 46.69 45.95 48.95
Grand mean ȳ = 31.6378; dose means 21.905; 31.348; 41.660; sex means 28.179 and 35.097; cell means: Placebo 20.347 and 23.463, Low dose 28.067 and 34.630, High dose 36.123 and 47.197.
SS_Dose = 6 × [ (21.905 − 31.638)² + (31.348 − 31.638)² + (41.660 − 31.638)² ] = 1171.53 df 2
SS_Sex = 9 × [ (28.179 − 31.638)² + (35.097 − 31.638)² ] = 215.35 df 1
SS_interaction = 3 × Σ (ȳ_ij − ȳ_i − ȳ_j + ȳ)² = 47.76 df 2
SS_residual = sum of squared deviations from the cell means = 14.50 df 12
MS_residual = 14.50 / 12 = 1.2083
F_interaction = (47.76/2) / 1.2083 = 19.76 P = 0.00016
F_Dose = 585.77 / 1.2083 = 484.8 P < 0.0001
F_Sex = 215.35 / 1.2083 = 178.2 P < 0.0001
Doses explain 80.8% of the total variation, sex 14.9% and the interaction 3.3%. The interaction is significant: the gap between sexes grows with the dose. Šídák comparisons within each row (one comparison per row, hence no adjustment): SE = √(1.2083 × (1/3 + 1/3)) = 0.8975, df = 12; Placebo: Male − Female = −3.117, t = −3.473, P = 0.0046, 95% CI −3.117 ± 2.1788 × 0.8975 = [−5.07 ; −1.16]; Low dose: −6.563, P < 0.0001; High dose: −11.07, P < 0.0001. With "A single family of comparisons", the Placebo P becomes 1 − (1 − 0.00461)³ = 0.0138.
If the three replicates of each sex were three animals followed at the three doses ("RM by row factor"), sex would be tested against the variability between animals: F(1, 4) = 105.0, P = 0.0005; Dose F(2, 8) = 744.6 and interaction F(2, 8) = 30.4, P = 0.0002; ε = 0.568 (shown, not applied).
Reporting#
"A two-way ANOVA (dose × sex, n = 3 per cell) showed a significant interaction (F(2, 12) = 19.8, P = 0.0002); dose (F(2, 12) = 484.8) and sex (F(1, 12) = 178.2) also had main effects (P < 0.0001). Females had higher values at every dose (Šídák comparisons; difference at placebo 3.1, 95% CI 1.2 to 5.1, P = 0.005)."
Common pitfalls#
- Interpreting main effects in the presence of a strong interaction.
- Forgetting the matching: repeated measures analyzed as independent give wrong P values for both the between-subjects and the repeated factor.
- Reading repeated measures P values as corrected: the Geisser-Greenhouse ε is only displayed.
- Adding up the "Share of the total variation (%)" of an unbalanced design (type III SS).
- With "Repeated measures ANOVA (GLM)" and incomplete cells, Variance keeps only the first values of each cell: prefer the mixed model (default setting).
- Multiplying families of comparisons without saying so: state whether each row is a family or whether all comparisons form a single family.
Three-Way ANOVA#
Three-way ANOVA analyzes a Two factors table whose rows are the levels of factor A and whose data sets cross two other factors, B and C. It tests the three main effects, the three two-way interactions and the three-way interaction, with type III sums of squares (valid for unequal sample sizes). When the same subjects (or blocks) are measured at several levels of one, two or three factors, it fits a mixed model. It offers seven schemes of multiple comparisons and can prepare a consolidated table for a two-way ANOVA, when one of the data set factors matters little.
When to use it#
- Three crossed factors, all combinations observed with independent replicates: for example treatment (A) × sex (B) × genotype (C).
- Repeated measures: the same subject is measured in several rows, or in several data sets ("RM Design" tab).
- If a three-way interaction is present, the interaction of two factors depends on the level of the third: then analyze the sub-tables (two-way ANOVA for each level of one factor).
Assumptions and checks#
- Independent observations, except for the matching declared in the "RM Design" tab: the values of the same subject then share a random effect, which assumes the same correlation between all the measurements of a subject (sphericity).
- Normality of residuals and a variance common to all cells (no "Residuals" tab: examine the scatter of each cell).
- At least one value per cell and enough replicates to estimate the residual variance (df_resid = N − number of parameters of the model).
Step by step in Variance#
- Two factors table with replicates. Rows = levels of A. The data sets are arranged as levels of B nested within levels of C: B1C1, B2C1, B1C2, B2C2… (with 2 levels of B and 2 of C, four data sets in this order). The number of data sets must be a multiple of the number of levels of B, and at least twice that number.
- Analysis › Compare Groups › Three-Way ANOVA.
- "Model" tab: "Number of levels of the data set factor B" (2 by default; the tooltip recalls the order B1C1, B2C1, B1C2, B2C2…) and "Fit the full model (all interactions)" (checked by default; unchecked, the model contains only the three main effects, with no interaction at all).
- "RM Design" tab (nothing checked by default): "Each subject is measured at every level of factor B (same row and subcolumn)", "Each subject is measured at every level of factor C (same row and subcolumn)" and "Each subject is measured in every row (factor A)". A subject is identified by its subcolumn and by the levels of the factors that are not matched: with A matched, subcolumn 2 of data set B1C1 is the same subject in every row; with B matched, subcolumn 2 of row 1 is the same subject in B1C1 and B2C1, but another one in B1C2 and B2C2.
- "Factor Names" tab: "Factor A (rows)", "Factor B", "Factor C" and "Name of the matched set (subject, block)" ("Subject" by default).
- "Multiple Comparisons" tab: "Number of comparisons" offers "No multiple comparisons" (the default), "Every pair of cells", "Compare the control cell mean (first row, first data set) with the other cell means", "Pairs of cells differing in a single factor", "Each cell of row 1 against the cell below it", "Every pair of row means" and "Each row mean against a control row" (with "Control row", 1 by default). "Test": Tukey (the default), Šídák, Bonferroni, Holm-Šídák, Hochberg (step-up), Dunnett (only for comparisons with a control; Šídák otherwise), Fisher's LSD, two-stage FDR or Benjamini and Hochberg FDR.
- "Consolidate" tab: "Don't create a consolidated table" (the default), "Combine the levels of factor B (rows × factor C)" or "Combine the levels of factor C (rows × factor B)".
- "Options" tab: confidence level, α threshold, digits and P value format. OK.
How it is calculated#
Same method as the ordinary two-way ANOVA: effect (sum-to-zero) coding of each factor, interaction columns = products of the columns of the factors involved, least-squares fit of the full model (intercept + 7 terms), and for each term:
SS_term = RSS(model without the columns of the term) − RSS(full model)
df_term = product of (number of levels − 1) of the factors of the term
F = MS_term / MS_resid df (df_term, N − rank of the full model)
P = Prob( F(df_term, df_resid) ≥ F ) Share of the total variation (%) = 100 · SS_term / SS_total
For a two-level factor in a balanced design, SS = N · (difference of the two marginal means)² / 4.
Matching. With a matched factor, Variance fits a mixed model by REML: the same fixed effects, plus one random effect per subject (an intercept, with variance σ²_subject). Each term is tested by a Wald F. Its denominator df are those of the within-subject effects (N − number of subjects − number of columns of the terms that contain a matched factor) when the term contains a matched factor, those of the between-subject effects (number of subjects − 1 − number of columns of the other terms) otherwise. With complete, balanced data and a single matched factor, these F are those of the classical split-plot ANOVA (effects of the matched factor tested against its interaction with the subjects, the others against the subjects), as long as the estimated subject variance is not zero. "Effectiveness of the matching" is the likelihood ratio test of σ²_subject = 0 (P = half the tail of a χ² with 1 df, 0 lying on the boundary of the parameter space).
Multiple comparisons. Without matching, each comparison of two cell means (or row means, computed from all the values of the row) uses MS_resid and its df, as in two-way ANOVA. With matching, the difference and its standard error are those of the contrast of the means estimated by the mixed model, with the within-subject df when the two cells differ only by matched factors, the between-subject df otherwise; Dunnett is then replaced by Šídák. All the comparisons form a single family; for Tukey, k is the number of means that appear in its comparisons (with "Each cell of row 1 against the cell below it", the cells of the first two rows, not every cell of the table).
Consolidated table. Combining the levels of B gathers, in each row, all the values of the data sets with the same level of C into one data set, titled with the titles of the combined data sets separated by "+" (likewise for C). The "Combined data" output table is a Two factors table (rows × remaining levels) that is analyzed and plotted like the other output tables (chapter 5), for example with a two-way ANOVA.
Reading the results#
The "ANOVA table" tab lists, from top to bottom: the A × B × C interaction, then B × C, A × C, A × B, then C, B, A (with the names chosen), "Residual" and "Total", with the columns "SS", "DF", "MS", "F", "DFd", "P value", "Summary" and "Share of the total variation (%)". Read from top to bottom: an important higher-order interaction makes the lower-order terms hard to interpret on their own. The "Cell means" tab gives the mean of each cell (rows × data sets).
With matching, the "SS", "MS" and "Share of the total variation (%)" columns stay empty (the mixed model does not split the total variance), "DFd" gives the within- or between-subject df of each F, and the table ends with "Mixed-effects model (REML)" (numbers of subjects and of values), "Random effects" ("SD of Subject", with the name chosen, and "SD of the residual") and "Effectiveness of the matching" ("Chi-square (likelihood ratio)", "P value").
The "Multiple comparisons" tab gives, for each pair ("row:data set vs. row:data set", or the row labels), "Mean Diff.", the confidence interval, "Significant?", "Summary" and "Adjusted P Value"; with matching, the line "Standard errors from the mixed model" recalls it. The comparisons between cells of the same row are added to the annotations of grouped graphs. The consolidated table appears under ⊞ "Combined data", and the last tab, "Narrative results", states each term in sentences: the interactions, then the main effects, then the matching.
Worked example#
Type this Two factors table (2 rows A1, A2; data sets "B1 C1", "B2 C1", "B1 C2", "B2 C2"; 3 replicates) and keep 2 levels for B:
B1 C1 B2 C1 B1 C2 B2 C2
A1 10.1 11.3 9.8 12.4 13.0 12.1 11.0 10.4 11.9 15.2 14.6 15.9
A2 13.2 12.5 13.9 15.1 16.0 14.8 14.3 13.5 14.0 19.8 20.4 18.9
Marginal means of A: A1 = (10.4 + 12.5 + 11.1 + 15.233)/4 = 12.308 and A2 = 15.533, so SS_A = 24 × (15.533 − 12.308)²/4 = 6 × 3.225² = 62.40. Variance gives:
| Source | SS | DF | F | DFd | P value |
|---|---|---|---|---|---|
| A × B × C | 1 | 1 | 2.322 | 16 | 0.1471 |
| B × C | 12.18 | 1 | 28.28 | 16 | <0.0001 |
| A × C | 1.084 | 1 | 2.515 | 16 | 0.1323 |
| A × B | 1 | 1 | 2.322 | 16 | 0.1471 |
| C | 27.52 | 1 | 63.88 | 16 | <0.0001 |
| B | 74.55 | 1 | 173 | 16 | <0.0001 |
| A | 62.4 | 1 | 144.8 | 16 | <0.0001 |
| Residual | 6.893 | 16 | |||
| Total | 186.6 | 23 |
(MS_resid = 6.893/16 = 0.4308.) Only the B × C interaction is clear: the effect of B (B2 − B1) is 2.1 at level C1 and 4.95 at level C2.
If the three replicates of each data set were the same three subjects measured in A1 and in A2 ("Each subject is measured in every row (factor A)", hence 12 subjects), the F would be unchanged but computed on 8 df instead of 16: P = 0.1661 for A × B × C and 0.0007 for B × C. The estimated subject variance is zero ("SD of Subject" = 0; "Effectiveness of the matching": P = 0.5000): these data show no subject effect, and the matching only costs degrees of freedom. With "Each cell of row 1 against the cell below it" (Tukey), A1 − A2 is −2.8 in B1 C1 and in B2 C1 (adjusted P = 0.0107), −2.833 in B1 C2 (0.0100) and −4.467 in B2 C2 (0.0005).
Reporting#
"A three-way ANOVA (A × B × C, n = 3 per cell, type III sums of squares) showed main effects of A, B and C (P < 0.0001) and a B × C interaction (F(1, 16) = 28.3, P < 0.0001); the other interactions were not significant (P ≥ 0.13)."
Common pitfalls#
- Arranging the data sets in the wrong order (B must vary fastest: B1C1, B2C1, B1C2, B2C2…): factors B and C would be mixed up.
- Forgetting to declare the matching ("RM Design" tab) when the same subjects are measured several times: their measurements would be treated as independent.
- Placing the subjects inconsistently: the same subject must occupy the same subcolumn in all the cells where it is measured.
- Unchecking "Fit the full model (all interactions)" thinking it removes only the three-way interaction: all interactions are removed.
- Concluding about a main effect while an interaction containing it is strong.
Nested t Test#
The nested t test compares two groups when each group contains several experimental units (animals, cultures, patients) and each unit was measured several times (technical replicates). It accounts for both sources of variability, between units and between replicates of the same unit, and thus avoids pseudoreplication: it is the number of units, not the total number of measurements, that sets the precision of the comparison. Variance fits it with a mixed-effects model (REML) and estimates the variance components.
When to use it#
- Hierarchical design: group → units → replicates, for example 2 treatments × 3 animals × 4 measurements per animal. The treatment was assigned to the units, not to the measurements.
- If you have only one value per unit, use an ordinary t test. If the replicates of a unit are different conditions (before/after), this is repeated measures, not a nested design.
- More than two groups: nested ANOVA (next section; Variance actually chooses the test from the number of groups analyzed, whichever menu item is used).
Assumptions and checks#
- Units independent of each other; replicates independent within a unit.
- Unit effects and measurement errors normally distributed, the same residual variance in all units, the same between-unit variance in both groups.
- Enough units: with 3 units per group, the test has only 4 degrees of freedom, whatever the number of replicates.
Step by step in Variance#
- Nested table: one data set per group, one subcolumn per experimental unit, the technical replicates of a unit one below the other in its subcolumn (Start window, "Nested" type, "Units per group"). Example: "Nested design (2 treatments × 3 animals × 4 measurements)".
- Analysis › Compare Groups › Nested t Test.
- "Options" tab:
- "When the variance between subcolumns is estimated as zero or negative": "Keep the random term (mixed model, REML; recommended)" (default), "Remove the random term and pool the replicates" or "Allow a negative variance (NOBOUND, as SAS): analysis of the subcolumn means";
- "P value" (two- or one-tailed), "Confidence level (%)", "Significance level (alpha)", digits and P value format.
- The "Multiple Comparisons" tab is used only by nested ANOVA (more than two groups).
- OK.
How it is calculated#
Mixed model (default option). For the value y of a replicate of unit u in group g:
y = μ + β·[g = B] + a_u + e a_u ~ N(0, σ²_units) e ~ N(0, σ²_replicates)
β is the difference B − A; the model is fitted by restricted maximum likelihood (REML), like the mixed model of one-way ANOVA (optimization of λ = σ²_units/σ² ≥ 0).
t = β̂ / SE(β̂) df = number of units − number of groups
P = 2·Prob( T ≥ |t| ) (always two-tailed in this case)
CI of β: β̂ ± t*·SE(β̂), t* = quantile 1 − (1 − C)/2 of t(df)
intraclass correlation coefficient ICC = σ²_units / (σ²_units + σ²_replicates)
test of the random term: χ² = 2·(ℓ_REML − ℓ_REML without the term), P = ½·Prob( χ²(1) ≥ χ² )
With the same number of replicates in every unit and a positive estimate of the between-unit variance, this test is identical to Student's t test on the unit means. In this mode the "P value" option is not used: P is two-tailed.
"Remove the random term and pool the replicates". If the between-unit variance is estimated as zero (σ²_units ≤ 10⁻¹⁰·σ²), the random term is removed and Variance computes Student's unpaired t test on all pooled replicates (df = N − 2, P according to the "P value" option); otherwise the result is that of the mixed model.
"Allow a negative variance (NOBOUND, as SAS)". Student's unpaired t test on the unit means (df = units − 2, P according to the "P value" option), and variance components by the method of moments, unbounded (they can be negative):
σ²_replicates = Σ_units Σ (y − ȳ_unit)² / Σ_units (n_unit − 1)
n̄ = N / number of units
MS_units = n̄ · [ Σ_groups Σ (ȳ_unit − mean of the ȳ_unit of the group)² / Σ (units of the group − 1) ]
σ²_units = (MS_units − σ²_replicates) / n̄
Mixed model that cannot be estimated. When the replicates do not vary within the units (a single replicate per unit, or identical replicates), the restricted likelihood has no maximum: Variance then analyses the means of the units, as with NOBOUND, and the row recalling this analysis is displayed. The t test on the means needs at least two units with data in each group (the rule of the unpaired t test).
Reading the results#
"Nested results" tab: "Input table", then "Nested t test (mixed model, REML)": "t", "df", "P value", "Significance code", "Difference significant at α = 0.05", "Difference between means (B - A)" and its CI; "Variance components (REML)": "Variance between subcolumns (units)", "Variance within subcolumns (replicates)", "Intraclass correlation", "Likelihood ratio χ² (variance between subcolumns)" and "P value (variance between subcolumns)" (the test of the random term, in numeric cells), and "Number of experimental units". With NOBOUND, a row recalls the analysis of the subcolumn means and the components are those of the method of moments; when the random term is removed, a row says so.
A high ICC means that the replicates of the same unit resemble each other: adding replicates then brings little information, adding units brings much. A non-significant test of the random term does not justify removing it to "gain" degrees of freedom.
Worked example#
Data "Nested design (2 treatments × 3 animals × 4 measurements)":
Control: animal 1 10.44 10.35 10.2 10.64 Treated: animal 1 12.17 12.77 12.54 12.67
animal 2 10.41 10.42 10.42 10.02 animal 2 12.7 13.17 13.41 12.85
animal 3 10.24 10.07 10.43 10.02 animal 3 12.65 13.25 12.67 12.8
Animal means: Control 10.4075; 10.3175; 10.19 (mean 10.305); Treated 12.5375; 13.0325; 12.8425 (mean 12.8042). The data are balanced, so the mixed-model test is that of the animal means:
pooled variance of the means = (0.0238875 + 0.1247167) / 4 = 0.037151
SE = √(0.037151 × (1/3 + 1/3)) = 0.15738 difference = 2.4992
t = 2.4992 / 0.15738 = 15.88 df = 6 units − 2 groups = 4 P = 9.2 × 10⁻⁵
95% CI = 2.4992 ± 2.7764 × 0.15738 = [2.062 ; 2.936]
σ²_replicates = 0.059421 MS_units = 4 × 0.037151 = 0.148604
σ²_units = (0.148604 − 0.059421) / 4 = 0.022296 ICC = 0.2728
The test of the random term gives χ² = 1.642, P = 0.10. An ordinary t test on the 24 measurements, wrongly treated as independent, would give t = 22.3 with 22 df: pseudoreplication exaggerates precision.
Reporting#
"Values were higher in the treated group (difference 2.50; 95% CI 2.06 to 2.94; nested t test, REML mixed model, t = 15.9, df = 4, P < 0.0001; 3 animals per group, 4 measurements per animal; intraclass correlation 0.27)."
Common pitfalls#
- Entering each measurement as a unit (a single subcolumn per group): this is the pseudoreplication the test is meant to avoid.
- Believing that adding technical replicates increases power as much as adding units.
- Removing the random term because its test is not significant.
- Asking for a one-tailed P value with the mixed model: it stays two-tailed.
Nested One-way ANOVA#
Nested one-way ANOVA extends the nested t test to three groups or more: each group contains several experimental units, each measured several times. Variance tests the group effect with a mixed-effects model (REML), estimates the variance components and, with the NOBOUND option, provides multiple comparisons on the unit means.
When to use it#
- Hierarchical design with at least three groups (for example 3 doses × 3 cultures × 3 wells).
- With two groups, Variance computes the nested t test (same analysis).
Assumptions and checks#
The same as for the nested t test: independent units, normality of unit effects and errors, equal variances in all groups, enough units per group.
Step by step in Variance#
- Nested table: one data set per group, one subcolumn per unit, the replicates in the subcolumn.
- Analysis › Compare Groups › Nested One-way ANOVA.
- "Options" tab: "When the variance between subcolumns is estimated as zero or negative" (same three choices as for the nested t test), "P value", "Confidence level (%)", "Significance level (alpha)", digits and P value format.
- "Multiple Comparisons" tab: "Multiple comparisons", "Control column", "Test" and "Compute compact letter display" (same choices as for one-way ANOVA). These comparisons are computed only with the NOBOUND option (see the calculations).
- OK.
How it is calculated#
Mixed model (default). y = μ + τ_g + a_u + e, fixed group effects (intercept and g − 1 indicators), random unit effect, REML fit. The group effect is tested with a Wald F:
F = β̂' · Cov(β̂)⁻¹ · β̂ / (g − 1) df1 = g − 1 df2 = units − groups
The variance components, the ICC and the likelihood ratio test of the random term are computed as for the nested t test. No multiple comparisons are computed in this mode.
Removing the random term. If the between-unit variance is estimated as zero, ordinary one-way ANOVA on all pooled replicates; otherwise, mixed model.
NOBOUND. Ordinary one-way ANOVA on the unit means (df = g − 1 and units − g), then multiple comparisons with the MSE and df of this ANOVA (methods of one-way ANOVA), compact letter display, and variance components by the method of moments (unbounded). In this analysis, the comparison with a control always takes the first data set as the control, and the choice "Linear trend of the means across the columns" does not compute a trend test: it gives the comparisons of all pairs.
Reading the results#
"Nested results" tab: "Nested one-way ANOVA (mixed model, REML)" with "F", "DFn", "DFd", "P value", "Significance code", "Significant (P < α)?", then "Variance components (REML)" (as for the nested t test). With NOBOUND: "Nested one-way ANOVA" (F and P of the ANOVA of unit means), "Variance components (method of moments, unbounded)", and the "Multiple comparisons", "Multiple comparisons (details)" and "Compact letter display" tabs described in the one-way ANOVA section.
Worked example#
Type this Nested table (3 groups, 3 units per group, 3 replicates):
Control : 5.1 5.4 4.9 | 6.0 5.7 6.2 | 5.5 5.2 5.6
Low : 6.8 7.1 6.5 | 6.1 6.4 6.6 | 7.3 7.0 7.5
High : 8.2 7.9 8.4 | 7.6 7.2 7.7 | 8.8 9.1 8.6
Unit means: Control 5.133; 5.967; 5.433 (mean 5.511); Low 6.800; 6.367; 7.267 (6.811); High 8.167; 7.500; 8.833 (8.167). Balanced design: the F of the mixed model is that of the ANOVA of unit means:
grand mean = 6.8296
MS_between = 3 × [ (5.511 − 6.830)² + (6.811 − 6.830)² + (8.167 − 6.830)² ] / 2 = 5.2898
MS_within (between units of the same group) = 0.27506 df = 9 − 3 = 6
F = 5.2898 / 0.27506 = 19.23 df (2, 6) P = 0.0025
REML components: σ²_units = 0.2535, σ²_replicates = 0.0648, ICC = 0.80 (χ² = 17.6, P < 0.0001). With NOBOUND and Tukey (SE = √(0.27506 × 2/3) = 0.4282, df = 6): Control vs. Low −1.300 (95% CI −2.614 to 0.014, P = 0.052), Control vs. High −2.656 (P = 0.0020), Low vs. High −1.356 (P = 0.044); letters a, a, b.
Reporting#
"The dose effect was significant (nested ANOVA, REML mixed model, F(2, 6) = 19.2, P = 0.0025; 3 cultures per dose, 3 wells per culture; intraclass correlation 0.80)."
Common pitfalls#
- Expecting multiple comparisons with the default option: they are computed only with NOBOUND.
- Counting replicates as units (inflated df).
- Choosing the control in "Control column": in this analysis, the control is always the first data set.
References#
Books:
- Motulsky H. Intuitive Biostatistics, 4th ed. Oxford University Press, 2018.
- Zar JH. Biostatistical Analysis, 5th ed. Pearson Prentice Hall, 2010.
- Altman DG. Practical Statistics for Medical Research. Chapman & Hall, 1991.
- Sokal RR, Rohlf FJ. Biometry, 4th ed. W. H. Freeman, 2012.
- Maxwell SE, Delaney HD. Designing Experiments and Analyzing Data, 2nd ed. Lawrence Erlbaum, 2004.
- Hsu JC. Multiple Comparisons: Theory and Methods. Chapman & Hall, 1996.
- Pinheiro JC, Bates DM. Mixed-Effects Models in S and S-PLUS. Springer, 2000.
- D'Agostino RB, Stephens MA (eds). Goodness-of-Fit Techniques. Marcel Dekker, 1986.
Articles:
- Welch BL. The generalization of "Student's" problem when several different population variances are involved. Biometrika 1947;34:28-35.
- Welch BL. On the comparison of several mean values: an alternative approach. Biometrika 1951;38:330-336.
- Satterthwaite FE. An approximate distribution of estimates of variance components. Biometrics Bulletin 1946;2:110-114.
- Brown MB, Forsythe AB. Robust tests for the equality of variances. Journal of the American Statistical Association 1974;69:364-367.
- Brown MB, Forsythe AB. The small sample behavior of some statistics which test the equality of several means. Technometrics 1974;16:129-132.
- Bartlett MS. Properties of sufficiency and statistical tests. Proceedings of the Royal Society of London A 1937;160:268-282.
- Greenhouse SW, Geisser S. On methods in the analysis of profile data. Psychometrika 1959;24:95-112.
- Mann HB, Whitney DR. On a test of whether one of two random variables is stochastically larger than the other. Annals of Mathematical Statistics 1947;18:50-60.
- Wilcoxon F. Individual comparisons by ranking methods. Biometrics Bulletin 1945;1:80-83.
- Pratt JW. Remarks on zeros and ties in the Wilcoxon signed rank procedures. Journal of the American Statistical Association 1959;54:655-667.
- Hodges JL, Lehmann EL. Estimates of location based on rank tests. Annals of Mathematical Statistics 1963;34:598-611.
- Stephens MA. Use of the Kolmogorov-Smirnov, Cramér-von Mises and related statistics without extensive tables. Journal of the Royal Statistical Society B 1970;32:115-122.
- Kruskal WH, Wallis WA. Use of ranks in one-criterion variance analysis. Journal of the American Statistical Association 1952;47:583-621.
- Friedman M. The use of ranks to avoid the assumption of normality implicit in the analysis of variance. Journal of the American Statistical Association 1937;32:675-701.
- Dunn OJ. Multiple comparisons using rank sums. Technometrics 1964;6:241-252.
- Kramer CY. Extension of multiple range tests to group means with unequal numbers of replications. Biometrics 1956;12:307-310.
- Dunnett CW. A multiple comparison procedure for comparing several treatments with a control. Journal of the American Statistical Association 1955;50:1096-1121.
- Dunnett CW. Pairwise multiple comparisons in the unequal variance case. Journal of the American Statistical Association 1980;75:796-800.
- Games PA, Howell JF. Pairwise multiple comparison procedures with unequal n's and/or variances: a Monte Carlo study. Journal of Educational Statistics 1976;1:113-125.
- Šidák Z. Rectangular confidence regions for the means of multivariate normal distributions. Journal of the American Statistical Association 1967;62:626-633.
- Holm S. A simple sequentially rejective multiple test procedure. Scandinavian Journal of Statistics 1979;6:65-70.
- Benjamini Y, Hochberg Y. Controlling the false discovery rate: a practical and powerful approach to multiple testing. Journal of the Royal Statistical Society B 1995;57:289-300.
- Benjamini Y, Yekutieli D. The control of the false discovery rate in multiple testing under dependency. Annals of Statistics 2001;29:1165-1188.
- Benjamini Y, Krieger AM, Yekutieli D. Adaptive linear step-up procedures that control the false discovery rate. Biometrika 2006;93:491-507.
- Piepho HP. An algorithm for a letter-based representation of all-pairwise comparisons. Journal of Computational and Graphical Statistics 2004;13:456-466.
- Royston P. Remark AS R94: a remark on algorithm AS 181: the W-test for normality. Applied Statistics 1995;44:547-551.
- D'Agostino RB, Belanger A, D'Agostino RB Jr. A suggestion for using powerful and informative tests of normality. The American Statistician 1990;44:316-321.
- Patterson HD, Thompson R. Recovery of inter-block information when block sizes are unequal. Biometrika 1971;58:545-554.
- Self SG, Liang KY. Asymptotic properties of maximum likelihood estimators and likelihood ratio tests under nonstandard conditions. Journal of the American Statistical Association 1987;82:605-610.
- Lazic SE. The problem of pseudoreplication in neuroscientific studies: is it affecting your analysis? BMC Neuroscience 2010;11:5.
- Cohen J. Statistical Power Analysis for the Behavioral Sciences, 2nd ed. Lawrence Erlbaum, 1988.
- Hedges LV, Olkin I. Statistical Methods for Meta-Analysis. Academic Press, 1985.
- Schuirmann DJ. A comparison of the two one-sided tests procedure and the power approach for assessing the equivalence of average bioavailability. Journal of Pharmacokinetics and Biopharmaceutics 1987;15:657-680.