anova1
Perform a one-way analysis of variance (ANOVA) for comparing the means of two
or more groups of data under the null hypothesis that the groups are drawn
from distributions with the same mean. For planned contrasts and/or
diagnostic plots, use anovan
instead.
anova1 can take up to three input arguments:
vartype
is "equal"
the variances are assumed to be equal
(this is the default). When vartype
is "unequal"
the
population variances are not assumed to be equal and Welch’s ANOVA test is
used instead.
anova1 can return up to three output arguments:
If anova1 is called without any output arguments, then it prints the results in a one-way ANOVA table to the standard output. It is also printed when displayopt is ’on’.
Examples:
x = meshgrid (1:6); x = x + normrnd (0, 1, 6, 6); anova1 (x, [], 'off'); [p, atab] = anova1(x); |
x = ones (50, 4) .* [-2, 0, 1, 5]; x = x + normrnd (0, 2, 50, 4); groups = {"A", "B", "C", "D"}; anova1 (x, groups); |
See also: anova2, anovan, multcompare
Source Code: anova1
x = meshgrid (1:6); randn ("seed", 15); # for reproducibility x = x + normrnd (0, 1, 6, 6); anova1 (x, [], 'off'); ANOVA Table Source SS df MS F Prob>F ------------------------------------------------------ Groups 96.8124 5 19.3625 31.76 0.0000 Error 18.2881 30 0.6096 Total 115.1004 35 |
x = meshgrid (1:6); randn ("seed", 15); # for reproducibility x = x + normrnd (0, 1, 6, 6); [p, atab] = anova1(x); ANOVA Table Source SS df MS F Prob>F ------------------------------------------------------ Groups 96.8124 5 19.3625 31.76 0.0000 Error 18.2881 30 0.6096 Total 115.1004 35 |
x = ones (50, 4) .* [-2, 0, 1, 5]; randn ("seed", 13); # for reproducibility x = x + normrnd (0, 2, 50, 4); groups = {"A", "B", "C", "D"}; anova1 (x, groups); ANOVA Table Source SS df MS F Prob>F ------------------------------------------------------ Groups 1392.4448 3 464.1483 105.41 0.0000 Error 863.0487 196 4.4033 Total 2255.4935 199 |
y = [54 87 45; 23 98 39; 45 64 51; 54 77 49; 45 89 50; 47 NaN 55]; g = [1 2 3 ; 1 2 3 ; 1 2 3 ; 1 2 3 ; 1 2 3 ; 1 2 3 ]; anova1 (y(:), g(:), "on", "unequal"); Welch's ANOVA Table Source F df dfe Prob>F ----------------------------------------- Groups 15.52 2 7.58 0.0021 |