The one-way analysis of variance (ANOVA) test which is also known as one factor Anova test.
It is an extension of independent two-sample t-test which is used to comparing means in a situation where there are more than two groups and determine whether statistically significant differences between the means.
Simply it tests the null hypothesis.
There are two Anova test hypothesis and they are described below:
Null-hypothesis (H0): It states the mean of the different groups is the same.
Where µ = group mean and k = number of groups.
We can accept the alternative hypothesis (HA) if the one-way ANOVA returns a statistically significant result
Alternative hypothesis say that there are at least two means that are statistically significantly different from each other which are from different groups.
Alternative hypothesis (HA): It states that at least one sample mean is not equal to the others.
But before we see Anova test in action let’s just first set up a proper environment for R programming.
To install R programming tool go to the following link and download the software and install it.
For Windows Users:
For Linux Users:
If you are on Linux platform then you can use this fast and easy command used in Linux which can be used to install R. The yum command is used for installing like this:
$ yum install R
For Ubuntu Linux or other Debian-related OSs, a more direct method is:
$ apt-get install r-base
Now Let’s Start using the RGui (64 -bit) which will be installed in the Installation folder which we had selected while installing the software.
Let’s us this test in action in the following example:
# Get the dataset.
input <- mtcars
#mtcars is a pre existing dataset that we can readily use in R programming
print(head(mtcars))
Output:
# Create the regression models.
result1 <- aov(mpg~hp*am,data = input)
result2 <- aov(mpg~hp+am,data = input)
# Compare the two models.
print(anova(result1,result2))
Output:
Syllabus of Data Science training in Mumbai