The Mean Square due to Error or MSE is calculated from the Sum of Squares due to Error or SSE. SSE specifies the variances present in samples. And it is calculated using the following formula:
Here, nk is the number of observations in the kth group. And σk2 is the sample variance present in the kth group.
And the MSE or the Mean Square due to Error and it is calculated as follows:
df is here the degrees of freedom, and it is calculated as (n-k) where n is the total number of observations and k is the total number of groups.
The MST or the Mean Squares due to Treatment can be calculated in the following way:
SST is the Sum of Squares due to Treatment, and dfk is the degrees of freedom which is (the total number of groups – 1) in this case.
The SST is calculated as follows:
Here, nk is the number of observations in the kth group. X̄ is the overall mean across all the groups. x̄ is the mean of the first group, ȳ is the mean obtained by the second group, and so on.
One-way ANOVA test using Python
We can use the f_oneway() function from the scipy.stats module to calculate the p-value of a one-way ANOVA test.
from scipy.stats import f_oneway M1 = [63, 67, 68, 71, 75, 89, 71, 78, 93, 64, 56, 53, 67, 55, 60, 66, 73, 60, 64, 61] M2 = [75, 44, 59, 70, 71, 66, 91, 59, 63, 79, 71, 44, 71, 80, 64, 64, 76, 69, 89, 51] M3 = [83, 48, 74, 68, 68, 86, 82, 84, 82, 76, 66, 61, 87, 80, 88, 79, 67, 67, 70, 46] f_statistic, p_value = f_oneway(M1, M2, M3) print("F-statistic: ", f_statistic) print("p-value: ", p_value) Here, M1, M2, and M3 denote the marks obtained by the first, second and third group of students. Please note that the test statistic in a one-way ANOVA test follows the F-distribution.
The output of the above program will be like the following:
F-statistic: 1.3906585540443808 p-value: 0.2572274003795069






0 Comments