Machine Learning

# One way ANOVA (Analysis Of Variance)

Hello guys, After long time I got time to write something…

So today, I will tell you about ANOVA(ANalysis Of VAriance ).

ANOVA: is a parametric method appropriate for comparing the means for 2 or more independent or dependent groups.

There are 3 types of ANOVA:

1). One Way ANOVA     2). Repeated-Measures ANOVA   3). Factorial ANOVA

One Way ANOVA: The oneway ANalysis Of VAriance (ANOVA) is used to determine whether there are any significant differences between the means of two or more independent (unrelated) groups (although you tend to only see it used when there are a minimum of three, rather than two groups).

Repeated-Measures ANOVA: Repeated measures ANOVA is the equivalent of the one-way ANOVA, but for related, (not independent) groups, and Repeated-Measure is the extension of the dependent t-test(learn about dependent t-test by clicking on the given link).

Factorial ANOVA:  More than one Categorical Independent Variables. Factorial ANOVA measures whether a combination of independent variables predict the value of a dependent variable. The term “way” is often used to describe the number of independent variables measured by an ANOVA test.

In this article I will do One Way ANOVA by hand, but in next article I will teach you how to perform ANOVA in R.

For performing ANOVA we need  data, I have created a data table just for understanding. Here is our table:

Critical significance value  α(alpha) = 0.05.

H(0)[Null Hypothesis] = μ1 = μ2 = μ3.

H(α) = At least one different among the means.

STEP: 1  Find the degree of freedom between or within  repectively df(bet) or df(within):

df(bet) = k-1 [k is number groups]

df(within) = N-k [N is total entries in group]

df(bet) = 3-1 = 2

df(within) = 9-3 = 6

df(total) = df(bet)+df(within) = 2+6 = 8

F(critical) value for df(bet) and df(within)

F(critical) = 7.20

STEP 2:  Calculate the mean for each condition for group.

X1 for group one, X2 for group second X3 for group third

X1= 1+2+5=8          mean of X1 = 8/3 = 2.67

X2 = 2+4+2 = 8       mean of X2 = 8/3 = 2.67

X3 = 2+3+4 = 9       mean of X3 = 9/3 = 3

Grand Mean[GM] = G/N= [1+2+5+2+4+2+2+3+4]/9 = 2.78

G= total number of element of groups

N= total number of groups

STEP 3: Calculate the sum of squares

SS(total) = Σ(x-x(GM))²

After solving the equations we will get SS(total) = 13.6

Now calculate SS(within) = Σ(X1- mean(X1))²+Σ(X2- mean(X2))²+Σ(X3- mean(X3))²

On solving SS(within) equation we will get the value

SS(within)= 13.34

Now, we have SS(total) and SS(within) with the calculated value we will get the SS(bet) value

SS(total) = SS(bet)+SS(within)

SS(bet) = SS(total)-SS(within)

SS(bet) = 13.6-13.34 = 0.26

STEP 4: Calculating Variance between and within

Variance or Mean Square MS(bet) = SS(bet)/df(bet) = 0.26/2 = 0.13

Variance or Mean Square MS(within) = SS(within)/df(within) = 13.34/6 = 2.22

STEP 5: Calculate the F value

F = MS(bet)/MS(within) = 0.13/2.22 = 0.05

Now we have find F and F(critical) value compare these value whether we can reject our null hypothesis or not.

Here what we have

F =  0.05

F(critical) = 7.20

F<<<<F(critical) Based on our calculation we didn’t get to critical region or rejection of Null hypothesis, So we are not able to reject the null hypothesis

H(0)[Null Hypothesis] = μ1 = μ2 = μ3.    Their is no significant difference between the 3 groups of our table.

In my next article I will explain ANOVA using R, Till then stay tuned and enjoy

If you have any doubts please mention in comment box or reach me @ irrfankhann29@gmail.com.

Categories: Machine Learning, R

Tagged as: , , ,

### 6 replies »

1. David says:

Care to share a use case senario? Would it be aplicable for comparing the classroom averages by subject for middle school?

Liked by 1 person

• Irfan says:

Sure David
I would love if you do this thanks man…

Like

2. Amazing blog! Do you have any suggestions for aspiring writers?

I’m planning to start my own website soon but I’m a little lost on everything.

Would you advise starting with a free platform like WordPress or go for a paid option? There are so many options out there that I’m totally overwhelmed ..

Any tips? Appreciate it!

Like

• Irfan says:

Hi @Halina,
Starting a blog or website is always good, I will suggest you to go with the paid wordpress option, there you will be having so many option and many plugins, which will be helpful but in free wordpress plan you will not get this much of opportunity

Like

3. ernest says:

Thanks for this, I’m gonna use this for my study you may contact me at

Like

• irfy says:

Thanks @ernest you are most welcome
And stay tuned for best articles

Like