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); x = x + normrnd (0, 1, 6, 6); anova1 (x, [], 'off'); ANOVA Table Source SS df MS F Prob>F ------------------------------------------------------ Groups 128.9120 5 25.7824 34.13 0.0000 Error 22.6632 30 0.7554 Total 151.5752 35 |
x = meshgrid (1:6); x = x + normrnd (0, 1, 6, 6); [p, atab] = anova1(x); ANOVA Table Source SS df MS F Prob>F ------------------------------------------------------ Groups 102.5418 5 20.5084 14.39 0.0000 Error 42.7504 30 1.4250 Total 145.2923 35 |
x = ones (50, 4) .* [-2, 0, 1, 5]; 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 1290.5622 3 430.1874 104.87 0.0000 Error 803.9915 196 4.1020 Total 2094.5537 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 |