Two-way ANOVA with interaction (Type III default, Type II) and simple effects, version 1.0.1
two-way-anova@1.0.1: this version's equations with their symbols, each constant's value, their sources and whether each was read, a worked example where the record holds one, its level and what it was checked against, the number of cases, and what was not checked. This version's record is not rewritten; a correction is added under Changes.
What this page can and cannot show
Level: Checked against a reference; published cases balanced only, where Type II and III agree; unbalanced Type II and III checked against R only. Reference kind: not recorded. This level uses the apps' wider definition on the levels page.
Not fully recorded, and not independently reviewed. Items marked "Not recorded" are missing from this project's records for the version named. Apart from any worked example shown, the cases and their values are not printed, so a reader cannot re-run these checks. No independent scientist has yet reviewed these methods or checks.
Every version of this method · Every method · What the levels mean
Version 1.0.1
Level: Checked against a reference; published cases balanced only, where Type II and III agree; unbalanced Type II and III checked against R only. Reference kind: not recorded. This level uses the apps' wider definition on the levels page. two-way-anova@1.0.1
What this page can and cannot show
What was checked
Checked against R 4.4.3 on 22 cases of the 0.11.0 fixture (car 3.1-5 Anova, Type III with sum contrasts and Type II): sums of squares and F within 1e-9 relative; simple effects as the post-hoc methods (2026-10-13). R only; SciPy not run.
Cases: no case set is linked to two-way-anova@1.0.1.
What was not checked
The simple effects (Tukey, Dunnett, Holm, Šidák and Bonferroni comparisons of B within each level of A) are part of this method and are not anchored on a source read here, nor worked by hand. The source's supplementary material, which defines the sigma-restricted coding, was not read; the engine's sum-to-zero contrasts are taken to be that coding, and the hand case confirms it numerically: Type III by model comparison in sum-to-zero coding equals the source's Q on equally weighted cell means exactly, and both equal R's values. The source read is a tutorial; the first sources of the Type II and Type III sums of squares (it cites Searle 1987 and Yates 1934 among others) were not read. The p values are not worked by hand. Every case is synthetic: values generated by this project from the model itself with a recorded noise vector. No measured data set from another party is among the cases. No published case set names two-way-anova@1.0.1 by its exact key. The hand case is a draft worked by an AI session on 12 November 2026 from the source's equation; this session also ran it through the tool on this repository's head and the tool agreed, a check made once and not kept as a test. No case runs this method through the served tool on its production runtime. No person has worked these cases or read these sources; the reading and checks recorded here were made by AI sessions.
Equations
Equation 1
Type III (the default), with sum-to-zero contrasts: SS_A = SSE(μ, β, γ) − SSE(μ, α, β, γ)
SS_B = SSE(μ, α, γ) − SSE(μ, α, β, γ)
SS_A×B = SSE(μ, α, β) − SSE(μ, α, β, γ). These are the source's Table 7, R(α̇ | μ, β̇, γ̇), R(β̇ | μ, α̇, γ̇) and R(γ̇ | μ, α̇, β̇), with its R(α | μ) = SSE(μ) − SSE(μ, α)
the dots mark sigma-restricted (sum-to-zero) coding, which the source says these comparisons require.
| Symbol | Meaning and unit |
|---|---|
| SSE(…) | sum of squared errors of the least-squares fit of the model holding the terms named, 1 |
| μ, α, β, γ | the constant, the effects of factor A and of factor B, and their interaction, 1 |
Source: McFarquhar M. Testable Hypotheses for Unbalanced Neuroimaging Data. Front Neurosci 2016;10:270., table 7, section 2.6, 3.3, Europe PMC full-text XML of PMC4911391 (the publisher's article); the equations are MathML in the file. The article's supplementary material, which describes the sigma-restricted coding, was not read; read in full on 2026-11-12 by an AI-assisted session; not yet checked by a person.
Equation 2
Type II: SS_A = SSE(μ, β) − SSE(μ, α, β)
SS_B = SSE(μ, α) − SSE(μ, α, β)
SS_A×B = SSE(μ, α, β) − SSE(μ, α, β, γ). These are the source's Table 5: R(α | μ, β), R(β | μ, α) and R(γ | μ, α, β).
| Symbol | Meaning and unit |
|---|---|
| SSE(…) | sum of squared errors of the least-squares fit of the model holding the terms named, 1 |
| μ, α, β, γ | the constant, the effects of factor A and of factor B, and their interaction, 1 |
Source: McFarquhar M. Testable Hypotheses for Unbalanced Neuroimaging Data. Front Neurosci 2016;10:270., table 5, section 2.6, 3.2, Europe PMC full-text XML of PMC4911391 (the publisher's article); the equations are MathML in the file. The article's supplementary material, which describes the sigma-restricted coding, was not read; read in full on 2026-11-12 by an AI-assisted session; not yet checked by a person.
Equation 3
F = (SS/df)/σ̂², σ̂² = SSE(μ, α, β, γ)/(n − cells), the full model's mean squared error for every term
p is the upper tail of F on df and n − cells degrees of freedom. The source's F = R/(r·σ̂²), r the degrees of freedom of the hypothesis.
| Symbol | Meaning and unit |
|---|---|
| df | levels of A less one, levels of B less one, or their product, 1 |
| n − cells | residual degrees of freedom: observations less the number of cells, 1 |
Source: McFarquhar M. Testable Hypotheses for Unbalanced Neuroimaging Data. Front Neurosci 2016;10:270., section 2 (σ̂² from the residuals), 2.5 and 2.6 (F), Europe PMC full-text XML of PMC4911391 (the publisher's article); the equations are MathML in the file. The article's supplementary material, which describes the sigma-restricted coding, was not read; read in full on 2026-11-12 by an AI-assisted session; not yet checked by a person.
Constants
Constants: none used.
Worked example
Worked example: one case of two-way-anova@1.0.1, from its inputs through each step to the answer. Values are written as a person writes them; the working carries more digits, so your own figure may differ in the last digit shown.
Inputs
- factorA[0] = Male
- factorA[1] = Female
- factorB[0] = Vehicle
- factorB[1] = Low
- factorB[2] = High
- cells[0][0][0] = 10.2
- cells[0][0][1] = 11.1
- cells[0][1][0] = 12.4
- cells[0][1][1] = 13
- cells[0][1][2] = 12.1
- cells[0][1][3] = 12.8
- cells[0][1][4] = 13.3
- cells[0][2][0] = 11
- cells[0][2][1] = 10.4
- cells[0][2][2] = 11.6
- cells[1][0][0] = 13.1
- cells[1][0][1] = 12.6
- cells[1][0][2] = 13.8
- cells[1][0][3] = 12.9
- cells[1][0][4] = 13.5
- cells[1][0][5] = 12.2
- cells[1][1][0] = 15.2
- cells[1][1][1] = 14.6
- cells[1][1][2] = 15.9
- cells[1][2][0] = 12
- cells[1][2][1] = 12.8
- cells[1][2][2] = 11.7
- cells[1][2][3] = 12.4
- unit = independent
- type = 3
Steps
- cells: cell sizes and means = Male Vehicle: n 2, mean 10.65000; Male Low: n 5, mean 12.72000; Male High: n 3, mean 11.00000; Female Vehicle: n 6, mean 13.01667; Female Low: n 3, mean 15.23333; Female High: n 4, mean 12.22500, from A = Male, Female, B = Vehicle, Low, High.
- sse-full: SSE(μ, α, β, γ) = Σ (y − cell mean)² = 5.27550000.
- ms-error: σ̂² = SSE(μ, α, β, γ)/(n − cells) = 0.310323529, from n = 23, cells = 6.
- sse-a: SSE(μ, α): one-way by A = 30.3859231.
- sse-b: SSE(μ, β): one-way by B = 28.0937500.
- sse-additive: SSE(μ, α, β): the additive model, by its normal equations = 6.99424561.
- type2-A: R(α | μ, β) = SSE(μ, β) − SSE(μ, α, β) = 21.0995044, gives type2.A.
- type2-B: R(β | μ, α) = SSE(μ, α) − SSE(μ, α, β) = 23.3916775, gives type2.B.
- interaction: R(γ | μ, α, β) = SSE(μ, α, β) − SSE(μ, α, β, γ), the same in both types = 1.71874561, gives type2.A:B, type3.A:B.
- type3-A-contrast: Lμ̂ = mean of A1's cell means − mean of A2's = -2.03500000.
- type3-A: Q = (Lμ̂)²/Σ c²/n over the six cells, c = ±1/3; equal to R(α̇ | μ, β̇, γ̇) = 20.8996402, gives type3.A.
- type3-B-contrasts: Lμ̂: column means of the cell means, B1 − B3 and B2 − B3 = 0.220833333, 2.36416667.
- type3-B-variance: L·D·L′, D the diagonal of 1/n: [[v11, v12], [v12, v22]] = v11 0.312500000, v22 0.279166667, v12 0.145833333.
- type3-B: Q = (Lμ̂)′(L·D·L′)⁻¹(Lμ̂); equal to R(β̇ | μ, α̇, γ̇) = 24.3737456, gives type3.B.
- F-type2-A: F = (SS/1)/σ̂², on 1 and 17 degrees of freedom = 67.9919580.
- F-type2-B: F = (SS/2)/σ̂², on 2 and 17 degrees of freedom = 37.6891780.
- F-type2-AxB: F = (SS/2)/σ̂², on 2 and 17 degrees of freedom = 2.76928020.
- F-type3-A: F = (SS/1)/σ̂², on 1 and 17 degrees of freedom = 67.3479070.
- F-type3-B: F = (SS/2)/σ̂², on 2 and 17 degrees of freedom = 39.2715075.
- F-type3-AxB: F = (SS/2)/σ̂², on 2 and 17 degrees of freedom = 2.76928020.
The working, as the case writes it:
R(α | μ) = SSE(μ) − SSE(μ, α). Type II: A = R(α | μ, β), B = R(β | μ, α), A×B = R(γ | μ, α, β). Type III, sigma-restricted coding: A = R(α̇ | μ, β̇, γ̇), B = R(β̇ | μ, α̇, γ̇), A×B = R(γ̇ | μ, α̇, β̇). F = R/(r·σ̂²).
Answer
type2.A= 21.0995044type2.B= 23.3916775type2.A:B= 1.71874561type3.A= 20.8996402type3.B= 24.3737456type3.A:B= 1.71874561
Where these values came from: an outside program, R stats, car, multcomp, nlme (groups.R) as recorded in stored reference values; McFarquhar M. Testable Hypotheses for Unbalanced Neuroimaging Data. Front Neurosci 2016;10:270, Tables 5 and 7 and the equations for R(), Q and F; R's values as recorded in the oracle set.
The build has not run this example through the tool.
Worked by an AI session on 2026-11-21. No person has yet worked this case.
What it refuses, and its input ranges
GROUPS_TOO_FEW: Fewer than two levels of a factor (withheld).EMPTY_CELL: A cell with no value (withheld).CELL_N_TOO_SMALL: A cell with one value (withheld).ZERO_VARIANCE_GROUP: No cell spreads beyond rounding: the residual is rounding only (withheld).SINGULAR_DESIGN: The design is rank-deficient, or leaves no residual degree of freedom (withheld).BEYOND_DOUBLE_RANGE: A sum of squares or mean square in the data's unit is beyond the double range (above about 1.8e308, or nonzero and below about 2.2e-308): the table is withheld; simple effects whose values are representable are given (1.0.1).UNIT_NOT_INDEPENDENT: The replicates are not stated to be independent units: inference is withheld.MISSING_ARGUMENT: Dunnett comparisons asked without a control level of B.
Changes
2026-11-21-two-way-anova@1.0.1-1
2026-11-21 · two-way-anova@1.0.1 · Corrections to our methods
- What was wrong: The two-way ANOVA and its simple effects were computed from residual sums of squares of the values as typed. Where those passed the largest double every simple effect came out with statistic 0 and p 1 (a 2 × 3 design scaled by 1e160, against 6.35 and p 0.002); where they fell below the smallest normal double F came out wrong (18.93 against 18.89 at 1e-160) beside subnormal sums of squares, and at 1e-200 every sum of squares came out 0.
- Affected: stats_two_way_anova and the Assay app's two-way ANOVA in version 1.0.0, only where the values' sums of squares passed about 1e308 or fell below about 2e-308, which needs values above about 1e153 or below about 1e-154. Data whose largest absolute value lies within 2^±100 (about 7.9e-31 to 1.27e30) are computed as 1.0.0 computed them, so they give the same bits; 1,000 seeded realistic calls of each of the four tools gave the same bits, and the cases of the finding's range check (members near 1e-300 beside members near 1e30, and every probe case just inside 2^±100) give 1.0.0's reply.
- What changed: In 1.0.1: Data whose largest absolute value lies within 2^±100 are computed as given, as in 1.0.0; beyond that range the table and the simple effects are computed on the data multiplied by the one power of two that brings the largest value just inside it, and reported multiplied back (a sum of squares and the mean square by the square; a difference, SE and bound by the power). F, the statistics and p are unchanged by a positive scale. A table whose sums of squares cannot be reported in the data's unit is withheld as BEYOND_DOUBLE_RANGE: at 1e±160 and 1e±200 the ANOVA table is withheld so (its sums of squares are about 1e±320 and 1e±400) and the simple effects give the unscaled statistics and p. In a seeded scan of 1,000 calls of the tool at magnitudes from 1e-300 to 1e300, every call whose data share one magnitude and whose reply changed now gives the reply 1.0.0 gives on the same data brought near 1 by a power of two, or withholds as BEYOND_DOUBLE_RANGE; calls mixing magnitudes more than 2^500 apart have no such reference and were not judged.
- How it was found: An audit replay of the served tools at extreme finite inputs (probes through the tool handlers), repeated on 21 November 2026 by stored reference values with the data scaled by 1e±160 and 1e±200, shifted by 1000 and not, against the reply on the unscaled data; the scientific review's ruling of 18 November 2026 said what clears it, and its ruling of 21 November 2026 (route (b)) kept data within 2^±100 unscaled. Reproduced by unit tests that failed before the fix.
- Cases added: stored reference values: the probe's three two-way cases (Type III with Tukey, Type II with Holm, Dunnett) through the tool at 1e±160 and 1e±200, shifted and not; the table withheld as BEYOND_DOUBLE_RANGE and the simple effects as unscaled there, F as unscaled at 1e±150; every number moved exactly by the power at 2^±100 and 2^±400.
Tools that use it
Cite this version
Two-way ANOVA with interaction (Type III default, Type II) and simple effects. Drybench; two-way-anova@1.0.1; https://www.drybench.com/methods/m/two-way-anova/1.0.1 (accessed [date]).