In this module, we will see what is chi-square test and how important this statistical test is and why do we use it.
So, Chai-square test basically we use if we want to get to know a significant difference between the expected value and the observed value, which means if you have one or more than one category, you can calculate their absorbed value and we have calculated the expected values, both of them have genuinely a relationship between them or not, to get to know that we use chi-square test.
So, simply its purpose is to find out that the relationship between them is by chance or there is some actual relationship that exists between them or not.
At that time, we use chi-square test.
Chi-square test is basically given by a simple formula which we will see through examples, what are the observed values and what are the expected values in it and how we make their submissions? So, the formula is the chi-square is equal to submission of observed minus expected value’s whole square divided by expected values.
So, till now we have seen that what is chi-square test.
How do we perform it? Let's see it now.
So, we will take one interesting food’s example and we will learn in it, we will first see in it basically which are the two types of chi-square tests that we can perform and why.
Plus, which is the method.
In which ways we can step by step make our null and alternate hypothesis and give a decision or a conclusion
example is somewhat of this type.
Suppose, if there is a cafe manager, he wants to know that whoever comes to his café, which types of sauces do they like in their burgers or hot dogs, which means the one category or variable that we have that will be the gender where there will be two categories male and female plus the other variable which is there, with which we have to compare that will be the preferred sauces, it can be ketchup, it can be mayonnaise or some people like to have chilli sauce.
So, these kind of three categories that are there in one variables, ketchup, mayonnaise and chilli sauce versus the variable which is the gender, in it male and female.
Between both these variables we will find one relationship.
Now, we have two variables, it is possible that we have to estimate that both these random variables that are there, obviously why are they random variable? Because we don't know if they have any relation between each other or not or all this is some kind of a myth? The first thing that we wish to estimate is that weather these two variables are independent or not.
Which means are these variables connected to each other or not.
In such cases where we have to know the dependency and independency between two random variables.
Then we use chi- square test for independence.
it is possible that whichever test we have performed, you already have a result
available which we call as observed values and based on that we have created an
How do we do it? We will see it through this example but just to understand that if I want to see the difference in observed and expected values or what is the relationship.
I want to know that or I want to know how closely they are bounded with each other, then we use goodness of fit chi-square test.
So, come let's see how does chi-square test for independence function.
Chi-square test for independence is used when we need to find one significant relationship between two categorical variables from a single population.
In these two very important things you have seen, one is that there should be two categories.
Now the example that we had what were the two categories in it? One was gender and one was preferred sauces.
So, there should be two categories.
If you want to perform this test plus it should be from the single population.
So, let's see once what is the data given to us.
So, this is my table of observed values, if you'll see in this, in my columns there are values given of ketchup, mayonnaise and chilli sauce, their values are given.
Corresponding to the male and female on the left side, in this interesting observation, you must be seeing a different column which is total.
So, this total will be of a lot of use to us.
If we have to calculate our expected values.
We have observed value’s entire chart or table.
First of all, to perform any test is dependent on what is our null and alternate hypothesis.
We are performing independent test.
So, this means that our null hypothesis would be that let's say there is no relationship between gender and referral sauces, which means there is no dependency in any two variables.
And we can say that both the variables are independent.
This is my null hypothesis; alternate hypothesis would be opposite to this that there is a relationship between gender and preferred sauces.
So, we have created null and alternate hypothesis.
The next step would be that we have to calculate the expected values.
What are the expected values? The data which was already available with the manager that would be called my observed value.
But when we perform one analysis, what we assume that our null hypothesis is correct.
So based on the total columns, we calculate our expected values.
In which ways? let's create a table for expected value once, the expected values generatively is calculated on the basis of total.
Why? because we have to find the expected value of the entire table.
So, basically the total who prefer the ketchups.
That value, which is 40.
The ones who lie in male category, which is 48.
We will multiply both these values, the total of the full table which is 100, we will divide by it.
So, if I see in this example, here 40 multiplied by 48 divided by 100 which is 19.2.
second, we see one more example, the mayonnaise’s expected value will come for
What would that be? Which will be equal to 42 multiplied by 48 divided by 100 which is 20.16.
In the same way, we have calculated the entire table expected values.
So, what was the 1st step? We created null and alternate hypothesis,
in the second step we created table of expected values.
If you remember the formula that we had seen of chi-square test.
There we had observed minus expected whole square upon expected values summation.
So, if I want to calculate this thing, so let’s do one thing, whatever value we had seen from the observed table, we will note it in a new table and we will place expected values in the next table.
So, how will this happen? If you will see this table, here my 1st value is 15, we are seeing the observed table
Second is 25, third is 23.
In whichever way you can place it in observed values.
Expected values are the values corresponding to it, like my first value is 19.2.
Second value is 20.8.
In the same way we have noted observed and expected values.
Third column we have created where we did the calculation of observed minus expected.
If you normally keep observed minus expected.
Then it may happen, since there are plus and minus values in it.
So, the final sum that we will get can also reach 0 or it will be a small sum.
So, what do we do to avoid the negative values, let’s take the square of all the observed minus expected values in the fourth column.
When we created this column, last column we created in such a way where we divided this value with the expected value.
So, in this way my complete table was ready.
We basically use the table so that it is easy to understand and the values that have finally come, we can simply place them in our formula.
we do about the last column? Whichever values came, we summed them up, which
means in my last column is 0.91875 is my first value and whatever are the
remaining values, after taking all those values, the summation that we have
done, which is observed minus expected value’s whole square upon expected.
Basically, whatever is the sum is my chi-square calculated.
So, in those cases, my chi-square comes as 2.947.
Now, we have got a calculated chi-square’s value in our third step.
step is where we have to create the decision.
So, we have found the calculated value, chi-square.
Now I want the chi-square from the table as well.
If you remember we had learned degree of freedom.
What is degree of freedom basically for chi-square? Number of rows minus one multiplied by number of columns minus 1.
In this case where I have number of rows are two, where it is mentioned, male and female and the number of columns is three where there are 3 categories made like ketchup, mayonnaise and chilli sauce.
Corresponding to that the degree of freedom that comes as two which will be calculated as 2 minus 1, multiplied by 3 minus1.
So, now when our degree of freedom has come.
And we assume that the significance level is to create 5% error, which means alpha is 0.05.
Now I have alpha as well as degree of freedom.
What we will do is, we will go to the next step and go to the Chai-square table and find its tabular value.
So, if you will see in this, 5.99 comes my tabular value where the degree of freedom is 2 and alpha’s value is 0.05.
We have seen calculated chi-square and tabular chi-square.
We can call the tabular chi-square as critical chi-square as well because we are going to create a decision based on that.
So, if you will see, my final result that comes is in this way, chi-square calculated is less than chi-square tabular or we can say that our critical value that is there of the chi square is big.
Now if the critical value is big, this means that the value that we have calculated that lies in the accepted region.
Whenever any of our values lies in expected region, then our result of any decision, this is we fail to reject our null hypothesis.
So, in this way we cannot reject our null hypothesis, this means that we can say that there is no relationship between gender and the preferred sauces.
In this way we use different approach where we have to calculate our chi-square’s value simply in a small formula.
First of all, by creating null and alternative hypothesis, calculate one value and after that compare it with table value.
Whatever decision that comes, can conclude that we reject the null hypothesis and we fail to reject the null hypothesis.
Share a personalized message with your friends.