ANOVA implementation in Elixir.
ANOVA, or Analysis of Variance is a widely used statistical technique for comparing means among multiple groups, providing insights into whether observed differences are due to actual effects or simply random variability. It's an extension of the t-test, allowing for comparisons among multiple groups simultaneously. One-Way ANOVA compares means of three or more independent groups for one factor.
The package can be installed by adding anova to your list of dependencies in mix.exs:
def deps do
[
{:anova, "~> 0.6.1"}
]
endgroups = [[1,2,3,4,5], [6,7,8,9,10], [11,12,13,14,15]]
alpha = 0.05
groups
|> ANOVA.one_way()
|> TukeyHSD.test(alpha)One-way ANOVA (Analysis of Variance) is used to test the null hypothesis that the means of several groups are equal against the alternative hypothesis that at least one group mean is different.
One-way ANOVA partitions the total variability in the data into two sources: variability between groups (due to the factor) and variability within groups (due to random error). It then compares these two sources of variability using the F-statistic. A large F-statistic suggests that the between-group variability is much larger than the within-group variability, indicating a significant difference between at least two group means. Post-hoc tests: If the one-way ANOVA result is significant (meaning at least two groups have different means), post-hoc tests are often used to determine which specific groups differ significantly from each other.
-
Tukey's HSD (Honestly Significant Difference):
- Most commonly used post-hoc test
- Controls family-wise error rate
- Good balance of power and Type I error control
-
Bonferroni Correction
- When you have few comparisons planned in advance
- Divides alpha by number of comparisons
- Simple but often too conservative
-
Holm-Bonferroni (Step-down)
- More powerful than standard Bonferroni, good general choice
- Sequential testing procedure
- Still controls family-wise error rate
-
Scheffé Test
- Most conservative test
- Allows for any contrast (not just pairwise)
- Best when you have many planned contrasts
-
Fisher's LSD (Least Significant Difference)
- Least conservative (should only be used when ANOVA F is significant)
- No correction for multiple comparisons
- Highest power but higher Type I error risk
Currently we have a full implementation of Tukey's HSD and working on the others.
- Independent Variable (Factor): The variable that defines the groups being compared.
- Dependent Variable: The variable that is measured and compared between groups.
- Groups: The different levels or categories within the independent variable.
- Null Hypothesis: The assumption that all group means are equal (no difference).
- Alternative Hypothesis: The statement that at least two group means are different.
- F-statistic: A calculated value that summarizes the variability between groups compared to the variability within groups.
- p-value: The probability of observing the results (or more extreme results) if the null hypothesis is true.
- alpha: Significance level, represents the probability of incorrectly rejecting a true null hypothesis.
- Fisher, R. A. (1925). Statistical Methods for Research Workers. Oliver & Boyd.
- Montgomery, D. C. (2019). Design and Analysis of Experiments (10th ed.). Wiley.
- Howell, D. C. (2013). Statistical Methods for Psychology (8th ed.). Cengage Learning.
- Tukey, J. W. (1949). Comparing individual means in the analysis of variance. Biometrics, 5(2), 99–114. https://doi.org/10.2307/3001913
- Hsu, J. C. (1996). Multiple Comparisons: Theory and Methods. Chapman & Hall.