HYPOTHESIS TESTING
Hypothesis Testing
Introduction:
A Hypothesis test is a statistical test that is used to determine whether there is enough evidence in a sample of data to infer that a certain condition is true for the entire population.
When your car breakdown you will make an educated guess that there may be not enough petrol or may be some technical problem. Then you will take car to the nearest workshop to validate your guess/assumption/hypothesis. Depend on Mechanic answer you will reject one hypothesis and accept another hypothesis.
Here Null hypothesis is “not enough petrol”; Alternate hypothesis is may be some technical problem.
A hypothesis test examines two opposing hypotheses about a population: the null hypothesis and the alternative hypothesis.
Null hypothesis (H0):
The null hypothesis states that a population parameter is equal to a value. The null hypothesis is often an initial claim that researchers specify using previous research or knowledge.
Alternative Hypothesis (H1):
The alternative hypothesis states that the population parameter is different than the value of the population parameter in the null hypothesis. The alternative hypothesis is what you might believe to be true or hope to prove true.
Based on the sample data, the test determines whether to reject the null hypothesis. You use a p-value, to make the determination. If the p-value is less than or equal to the level of significance, which is a cut-off point that you define, and then you can reject the null hypothesis.
A common misconception is that statistical hypothesis tests are designed to select the more likely of two hypotheses. Instead, a test will remain with the null hypothesis until there is enough evidence (data) to support the alternative hypothesis.
Examples of questions you can answer with a hypothesis test:
- Does the mean height of undergraduate women differ from 66 inches?
- Is the standard deviation of their height equal less than 5 inches?
- Do male and female undergraduates differ in height?
Simple Example to understand hypothesis testing:
You can follow six basic steps to correctly set up and perform a hypothesis test. For example, the manager of a pipe manufacturing facility must ensure that the diameters of its pipes equal 5cm. The manager follows the basic steps for doing a hypothesis test.
- Specify the hypotheses.
First, the manager formulates the hypotheses. The null hypothesis is: The population mean of all the pipes is equal to 5 cm. formally, this is written as: H0: μ = 5
Then, the manager chooses from the following alternative hypotheses:
Because they need to ensure that the pipes are not larger or smaller than 5 cm, the manager chooses the two-sided alternative hypothesis, which states that the population mean of all the pipes is not equal to 5 cm. formally, this is written as H1: μ ≠ 5
2. Determine the power and sample size for the test.
The manager uses a power and sample size calculation to determine how many pipes they need to measure to have a good chance of detecting a difference of 0.1 cm or more from the target diameter.
3. Choose a significance level (also called alpha or α).
The manager selects a significance level 0.05, which is the most commonly used significance level.
4. Collect the data.
They collect a sample of pipes and measure their diameters.
5. Compare the p-value from the test to the significance level.
After they perform the hypothesis test, the manager obtains a p-value of 0.004. The p-value is less than the significance level of 0.05.
6. Decide whether to reject or fail to reject the null hypothesis.
The manager rejects the null hypothesis and concludes that the mean pipe diameter of all pipes is not equal to 5cm.
Test to validate hypothesis:
1. ANNOVA
2. Chi-square
3. T-Test
4. F-Test
5. A/B testing
Hypothesis tests can be used to evaluate many different parameters of a population. Each test is designed to evaluate a parameter associated with a certain type of data. Knowing the difference between the types of data, and which parameters are associated with each data type, can help you choose the most appropriate test.
ANNOVA
Introduction:
ANOVA is a statistical method that stands for analysis of variance. ANOVA was developed by Ronald Fisher in 1918 and is the extension of the t and the z test. Before the use of ANOVA, the t-test and z-test were commonly used. But the problem with the T-test is that it cannot be applied for more than two groups ANNOVA is used to do the analysis of variance between and within the groups whenever the groups are more than two. ANOVA creates a way to test several null hypotheses at the same time.
Get Mayank Aggarwal’s stories in your inbox
Join Medium for free to get updates from this writer.
The logic behind this procedure has to do with how much variance there is in the population. It is likely the researcher will not know the actual variance in the population, but they can estimate this by sampling and calculating the variance in the sample. You compare the differences in the samples to see if they are the same or statistically different while still accounting for sampling error.
Use of ANNOVA in different ways:
Commonly, we can use ANOVA in three ways: one-way ANOVA, two-way ANOVA, and N-way Multivariate ANOVA.
One-Way: When we compare more than two groups, based on one factor (independent variable), this is called one way ANOVA. For example, it is used if a manufacturing company wants to compare the productivity of three or more employees based on working hours. This is called one way ANOVA.
Two-Way: When a company wants to compare the employee, productivity based on two factors (2 independent variables), then it said to be two-way (Factorial) ANOVA. For example, based on the working hours and working conditions, if a company wants to compare employee productivity, it can do that through two-way ANOVA. Two-way ANOVA’s can be used to see the effect of one of the factors after controlling for the other, or it can be used to see the INTERACTION between the two factors. This is a great way to control for extraneous variables as you are able to add them to the design of the study.
N-Way: When the factor comparison is taken, then it said to be n-way ANOVA. For example, in productivity measurement if a company takes all the factors for productivity measurement, then it is said to be n-way ANOVA.
General procedure to calculate ANNOVA:
In an ANOVA, first sets up the null and alternative hypothesis.
H0: The null hypothesis assumes that there is no significant difference between the groups.
H1: Alternative hypothesis assumes that there is a significant difference between the groups.
After cleaning the data, we must test the above assumptions and see if the data meets them. They must then do the necessary calculation and calculate the F-ratio. After this, we must compare the critical value of the F-ratio with the table value or simply look at the p value against the established alpha. If the calculated critical value is greater than the table value, the null hypothesis will be rejected, and the alternative hypothesis is accepted. Rejecting the null hypothesis, we will conclude that the mean of the groups is not equal. If the calculated value is less than the table value, we will accept the null hypothesis and reject the alternative hypothesis. This will tell you that there is a difference in what you were testing but does not tell you WHERE the difference is. This is to say, if we were testing several groups against one another, we would know that there is a difference between the means of the groups but not which individual groups are different.
Applications:
ANOVA is used very commonly in business, medicine or in psychology research.
· In business, ANOVA can be used to compare the sales of different designs based on different factors.
· A psychology researcher can use ANOVA to compare the different attitude or behavior in people and whether or not they are the same depending on certain factors.
· In medical research, ANOVA is used to test the effectiveness of a drug.
Additional information:
Data level and assumption plays a very important role in ANOVA. In ANOVA, the dependent variable can be continuous or on the interval scale. Factor variables in ANOVA should be categorical. Like the T-test, ANOVA is also a parametric test and has some assumptions, which should be met to get the desired results. ANOVA assumes that the distribution of data should be normally distributed.
ANOVA also assumes the assumption of homogeneity, which means that the variance between the groups should be equal. ANOVA also assumes that the cases are independent to each other or there should not be any pattern between the cases. As usual, when planning any study, extraneous and confounding variables need to be considered. ANOVA is a way to control these types of undesirable variables.
Chi-square Analysis
Introduction:
There are two types of chi-square tests. Both use the chi-square statistic and distribution for different purposes:
· A chi-square goodness of fit test determines if a sample data matches a population.
· A chi-square test for independence compares two variables in a contingency table to see if they are related. In a more general sense, it tests to see whether distributions of categorical variables differ from each another.
o A very small chi square test statistic means that your observed data fits your expected data extremely well. In other words, there is a relationship.
o A very large chi square test statistic means that the data does not fit very well. In other words, there isn’t a relationship.
Chi-square test can be used for checking variable independencies, Homogeneity, goodness of fit.
A chi-square statistic is one way to show a relationship between two categorical variables. In statistics, there are two types of variables: numerical (countable) variables and non-numerical (categorical) variables. The chi-squared statistic is a single number that tells you how much difference exists between your observed counts and the counts you would expect if there were no relationship at all in the population.
There are a few variations on the chi-square statistic which one you use depends upon how you collected the data and which hypothesis is being tested. However, all of the variations use the same idea, which is that you are comparing your expected values with the values you actually collect. One of the most common forms can be used for contingency tables:
Where O is the observed value, E is the expected value and “i” is the “ith” position in the contingency table.
A high value for the chi-square statistic means there is a high correlation between your two sets of data. Deciding whether a chi-square test statistic is “large enough” isn’t as easy it seems. It would be nice if we could say a chi-square test statistic >10 means a correlation but unfortunately that isn’t the case. Being able to decide whether the statistic is large enough requires you to have a good grasp of hypothesis testing.
In order to decide if your test value is high enough, first state the null hypothesis and the alternate hypothesis. Then generate a chi-square curve for your results along with a p-value.
The Chi-square Test for Association which is a non-parametric test; therefore, it can be used for nominal data too. It is a test of statistical significance widely used bivariate tabular association analysis. Typically, the hypothesis is whether or not two populations are different in some characteristic or aspect of their behaviour based on two random samples. This test procedure is also known as the Pearson Chi-square test.
Example:
First case
· Is your manager’s mood associated with the weather?
· This appears to be no association between your manager’s mood and the weather here because the row percentages are in same in each column.
Second case
· Is your manager’s mood associated with the weather?
· There appears to be an association here because the row percentage is different in each column.
Additional information:
The Chi-square statistic can only be used on numbers. They can’t be used for percentages, proportions, means or similar statistical value. For example, if you have 10 percent of 200 people, you will need to convert that to a number (20) before you can run a test statistic.






