Hypothesis is a statement about the population that might be true.The beauty of these Hypotheses is that they can be TESTED!
To understand this topic we will take help of data.
Example: We have a hypothesis that ‘the average salary of the Data Scientists in Bay Area and Montreal is different’.
Most of the times we have certain assumptions about population parameters, hypothesis testing is a way to decide whether these assumptions stand true based on the data from sample.
There are two types of statistical hypotheses:
Alternate Hypothesis [H1] — is a hypothesis which researcher tries to prove. It Predicts that there is statistical significance or relation between variables in the hypothesis under study. So Therefore, in our case the Alternative Hypothesis is : “The average salary of Data Scientists in Bay Area and Montreal is different”.
Null Hypothesis[H0] — is a hypothesis which researchers tries to disapprove or nullify. It Predicts, there is no statistical significance or relation between variables in the hypothesis under study. It assumes nothing interesting is going on between whatever variables you are testing. So therefore, in our case the Null Hypothesis is ‘The average salary of Data Scientists in Bay Area and Montreal is same’.
Important: Only 1 Hypothesis out of Null and Alternate can be true. The null hypothesis is assumed to be true and statistical evidence is required to reject it in favour of an alternative hypothesis.
When we make a conclusion from a statistical test there are two types of errors that we could make. They are called: Type I and Type II Errors.
Type I error — reject H0 when H0 is true.
Type II error — do not reject H0 when H0 is false.
Example 1: Decision Errors in a Legal Trial . What are H0 and H1?
H0: Defendant is innocent.
H1: Defendant is not innocent, i.e. guilty
Which type (Type I or Type II) to minimise?
In modern society the social cost of sending an innocent person to prison and denying them their personal freedom is considered as an almost unbearable act and hence in this case Type I error should be the focus.
Example 2: In cancer detection two types of errors can arise. What are H0 and H1?
H0: Patient does not have cancer.
H1: Patient has cancer.
So, which error can be more disastrous? Obviously the second situation i.e. Type II error. In this case our choice of error to reduce must be the Type II error by reducing the number of patients having cancer but detected as cancer free (False Negatives).
Type I and Type II errors are inversely related i.e. increasing one decreases the other and vice-versa. So, In general the choice of error type to reduce depends on the business problem at hand.
Lets understand few more terminologies of hypothesis testing before solving a problem.
Significance level (‘α’): It specifies the size of region where null hypothesis should be rejected and region is called as Critical or Rejection Region.
Critical Value: It separates critical region from non-critical region. To obtain the critical value, the researcher must choose the significance level and know the distribution of the test value.
The hypothesis for the tests that we have discussed earlier are called as Two-tailed test. lets discuss more on type of tests we can have.
Two-tailed test — the null hypothesis should be rejected when the test value is in either of two critical regions on either side of the distribution of the test value
One-tailed test — indicates that the null hypothesis should be rejected when the test value is in the critical region on one side. There are two types in it.
- Left-tailed test — when the critical region is on the left side of the distribution of the test value.
2. Right-tailed test — when the critical region is on the right side of the distribution of the test value
One more concept to understand is z-test & t- test.
z-statistic: Here we assume that the population standard deviation (‘σ’) is know to us, but in reality that is hardly the case. Below is the formula to calculate it.
t-statistic: We generally don’t have information about the population and that is when we use a t-statistic, given by
‘σ’ : Population standard deviation
‘xˉ’: Sample mean
‘μ’: population Mean
‘s’: Sample standard deviation
’n’: Sample size
Now lets take few problems to solve.
Problem Statement 1: The average IQ for the adult population is 100 with a standard deviation of 15. A researcher believes this value has changed. The researcher decides to test the IQ of 75 random adults. the average IQ of the sample is 105. Is there enough evidence to suggest the average IQ has changed?
Solution: So we have following given data and lets solve step by step.
σ’= 15, μ = 100, n = 75, xˉ=105
Step 1: select H0 and H1, H0: μ= 100, H1: ̸= 100 (Two tailed test)
Step 2: Choose level of significance (α), if its not given in problem statement then most commonly used is 5% i.e. α = 0.05. As this problem is an example of two tailed test so will have α/2 = 0.025 on either side.
Step 3: Find Critical value. From Z-table, for Area in one tail (0.025) z-score is 1.960. For left tail value is -1.960 and for right tail 1.96.
Step 4: Find test statistics. As we have population standard given we will go for z -test. after substituting the value of σ’= 15, μ = 100, n = 75, xˉ=105 in z-test formula we get the value of z = 2.89
Step 5: Draw the conclusion. As the critical value we have is 1.96 and calculated value is 2.89, which will be ahead of critical value i.e. it will be in rejected region. Therefore we will reject the null hypothesis and Alternate hypothesis is accepted.
Problem Statement 2: The average IQ of the adult population is 100. A researcher believes the average IQ of adults is lower. A random sample of 5 adults is tested and scored 69,79,89,99,109. Standard deviation of sample is 15.81. is there enough evidence to suggest the average IQ is lower?
Step 1: select H0 and H1, H0: μ= 100, H1:μ < 100 (One tailed test)
Step 2: Choose level of significance (α), if its not given in problem statement then most commonly used is 5% i.e. α = 0.05. As this is one tailed test we have 0.05 on left side as the value is less than current mean value as per researchers.
Step 3: Find Critical value. As we have standard deviation of population given, So we use t-test. From t-table, for an Area in one tail (0.05) t-score is 2.132. As the value is of left side of mean it will be -2.132.
Note: As we had 5 observation so degree of freedom will be (n-1) i.e. 4.
Step 4: Find test statistics. As we do not have population standard given we will go for t-test. after substituting the value of s= 15.81, μ = 100, n = 5, xˉ=89 i.e.((69+79+89+99+109) / 5), in t-test formula we get the value of t= -1.56.
Step5: Draw the conclusion. As the critical value we have is -2.132 and calculated value is -1.56. T-test value lies in between mean and critical value and as it is less than critical value, So it will be in non rejected region. Therefore we will accept the null hypothesis and Alternate hypothesis is rejected.