Hypothesis Testing
Hypothesis Testing
Hypothesis Testing
Hypothesis test:
A hypothesis test is a formal way to make a decision based on statistical analysis. A hypothesis
test has the following general steps:
• Set up two contradictory hypotheses. One represents our assumption.
• Perform an experiment to collect data.
• Analyze the data using the appropriate distribution.
• Decide if the experimental data contradicts the assumption or not.
• Translate the decision into a clear, non-technical conclusion.
We will build up all the pieces we need, then put them together to test hypothesis.
Parameter: It is the unknown constant characteristic of the population observations. Function of
population, population mean (µ), population variance ( 2 ) are parameters.
Statistic: It is the function of sample observations. Sample mean ( x ), sample variance ( s 2 ) are
statistic.
Hypothesis: A hypothesis is a statement about one or more of parameter(s) of a population
which we want to verify on the basis of information contained in a sample.
Example: Internet server claims that computer users in AIUB spend on the average 15 hours per
week on browsing. We conduct a survey based on a sample of 250 users to arrive at a correct
decision. Here, the server's claim is referred to as a hypothesis.
1
Test of Hypothesis
Null hypothesis: It is a statement which tells us that no difference exits between the parameter
and the statistic, i.e., given the test scores of two random samples , does one group differ from
the other? A possible null hypothesis is, 𝐻0 : 𝜇1 = 𝜇2, [𝜇1 = mean of population 1, 𝜇2 = mean of
population 2].
Alternative hypothesis: The alternative hypothesis is the logical opposite of the null hypothesis.
The rejection of a null hypothesis leads to the acceptance of the alternative hypothesis, i.e.,
Possible alternative hypothesizes are, 𝐻1 : 𝜇1 ≠ 𝜇2 , or, 𝐻1 : 𝜇1 > 𝜇2 or, 𝐻1 : 𝜇1 < 𝜇2.
Test statistic: It is the function of sample observations which is used to verify the null
hypothesis.
Level of significance: It is the probability with which we want to risk rejecting the null
hypothesis even though it is true. We denote it by α; usually α = 0.05.
Acceptance region: If the value of the test statistic falls into the probability space of the
distribution of the test statistic and lead us to accept the null hypothesis then the probability
space is called the acceptance region.
Critical Region: The probability space in which the test statistic falls and leads us to reject the
null hypothesis is called critical region or rejection region. In the given figure the critical and
acceptance region are shown.
If Z ≥ Zα/2, H0 is rejected in favor of H1.
If − Z ≤ − Zα/2, H0 is rejected in favor of H1.
If lZl ≥ Zα/2, H0 is rejected in favor of H1.
2
Test of Hypothesis
Type I error: It is the probability of rejecting the null hypothesis when the null hypothesis is
true.
Type II error: It is the probability of accepting the null hypothesis when the null hypothesis is
false.
Example: Consider a defendant in a trial. The null hypothesis is "defendant is not guilty;" the
alternate is "defendant is guilty." A Type I error would correspond to convicting an innocent
person; a Type II error would correspond to setting a guilty person free.
Reality
Not guilty Guilty
Verdict Guilty Type I Error: Innocent goes jail Correct Decision
Not guilty Correct Decision Type II Error: Guilty goes free
Test of hypothesis:
It is the statistical process of verifying the null hypothesis using any test statistic. The steps are:
State the null hypothesis, 𝐻0 .
State the alternative hypothesis, 𝐻1 .
Choose the level of significance, α.
Select an appropriate test statistic.
Calculate the value of the test statistic.
Determine the critical region.
Reject 𝐻0 if the value of the test statistics falls in the critical region; otherwise accept 𝐻0 .
3
Test of Hypothesis
Example 9.1: A random sample of 10 persons is selected and their level of education (in
completed years of schooling) is recorded. The sample observations are,
𝑥: 5, 2, 0, 4, 16, 14, 10, 10, 6, 5. Do you think that the average schooling years of the persons in
population is 5?
Solution: Let, 𝑥~ 𝑁 (µ, 𝜎 2 ), 𝜎 2 is unknown.
We need to test, 𝐻0 : µ = 𝜇0 = 5 vs 𝐻1 : µ ≠ 𝜇0 .
1 72 1 (∑𝑥)2 1 722
𝑥̅ = ∑𝑥 = = 7.2, 𝑠 2 = [ ∑𝑥 2 − ] = (758 – ) = 26.62.
𝑛 10 𝑛−1 𝑛 9 10
𝑥̅ −𝜇0 7.2 − 5
Test statistic: 𝑡 = = = 1.35. Since |𝑡|<𝑡9 = 2.262. So 𝐻0 is accepted.
𝑠/√𝑛 5.16/√10
Hence, we can conclude that the average schooling years can be considered as 5.
Example 9.2: The number of computer graduates coming out from two different universities A
and B are employed in different organizations to do job related to computer.
University Number of graduates employed in computer related job
𝐴 𝑥1 ∶ 18, 16, 15, 20, 18, 15, 12
𝐵 𝑥2 : 20, 14, 12, 22, 16, 14, 15, 10, 12, 18, 10
Do you think that the employment facility for both the universities is similar?
Solution: Let, 𝑥1 ~𝑁(𝜇1 , 𝜎12 ) , 𝑥2 ~𝑁(𝜇2 , 𝜎22 ). Also, let 𝜎12 = 𝜎22 = 𝜎 2 .
We need to test, 𝐻0 : 𝜇1 = 𝜇2 vs 𝐻1 : 𝜇1 ≠ 𝜇2 .
Both 𝑛1 = 7 and 𝑛2 = 11 are small (< 30) and 𝜎 2 is not known.
̅𝑥̅̅1̅ − ̅𝑥̅̅2̅
Test statistic: 𝑡 = 1 1
~ 𝑡(𝑛1 −1)+ (𝑛2−1) .
2
√𝑠 (𝑛 + 𝑛 )
1 2
Since |𝑡|<𝑡16 = 2.12, 𝐻0 is accepted. Employment facility for students of both universities is same.
4
Test of Hypothesis
ANOVA TABLE
𝑆𝑆
Sources of variation 𝑑𝑓 𝑆𝑆 𝑀𝑆 = 𝐹 𝐹4,20
𝑑𝑓
14.94
𝐶𝑜𝑚𝑝𝑎𝑛𝑦 𝑘– 1 = 5 − 1 = 4 14.94 4
= 3.73
6.43 2.87
11.73
𝐸𝑟𝑟𝑜𝑟 𝑛 – 𝑘 = 25 − 5 = 20 11.73 20
= 0.58
5
Test of Hypothesis
Example 9.4: A sample of 15 students is selected from a group of 100 students and their grade
in SSC examination is recorded as follows:
Students 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Grade B C A D B C D A B C D B C C D
Do you think that 10% students get grade A?
Since |𝑧|< 1.96, 𝐻0 is accepted. It can be considered that 10% students got grade A.
6
Test of Hypothesis
Example 9.5: Is the severity of the drug problem in high school the same for boys and
girls? 85 boys and 70 girls were questioned and 34 of the boys and 14 of the girls admitted to
having tried some sort of drug. What can be concluded at the 0.05 level?
34 14 48
𝑝1 = 85 = 0.4, 𝑝2 = 70 = 0.2, 𝑝 = = 0.31, 𝑞 = 0.69
155
0.4 − 0.2
𝑧 = = 2.68
1 1
√(0.31)(0.69)( + 70)
85
Since |𝑧|> 1.96, 𝐻0 is rejected. We conclude that gender does make a difference for drug use.
7
Test of Hypothesis
Test of independence:
Let us consider that a researcher has n units in a sample. The sample observations are classified
according to qualitative characters, say A and B as follows:
A B B Not B 𝑇𝑜𝑡𝑎𝑙 (𝑅𝑖 )
A 𝑂11 = 𝑎 𝑂12 = 𝑏 𝑅1 = 𝑎 + 𝑏
Not A 𝑂21 = 𝑐 𝑂22 = 𝑑 𝑅2 = 𝑐 + 𝑑
Total (𝐶𝑗 ) 𝐶1 = 𝑎 + 𝑐 𝐶2 = 𝑏 + 𝑑 𝑛 = 𝑅1 + 𝑅2 + 𝐶1 + 𝐶2
We need to test, 𝐻0 : The characters A and B are independent vs 𝐻1 : They are not independent.
2
𝑂𝑖𝑗 2
Test statistic: 𝜒 2 = ∑∑ – 𝑛 ~ 𝜒(𝑟 −1) ( 𝑐 −1) . Here, r = no. of rows and c = no. of columns.
𝐸𝑖𝑗
𝑛(𝑎𝑑−𝑏𝑐)2
For r = 2 and c = 2, 𝜒 2 = (𝑎+𝑏)(𝑎+𝑐)(𝑏+𝑑)(𝑐+𝑑) ~ 𝜒12 .
Example 9.7: 150 computer graduates are interviewed and are classified according to their result
and job satisfaction. Do you think that the graduates with good result are satisfied with their job?
Job satisfaction
Result Total
Yes No
Good 22 58 80
Not good 20 50 70
Total 42 108 150
Since χ2 < χ12 = 3.84, 𝐻0 is accepted. So, job satisfaction does not depend on good result.
8
Test of Hypothesis
Example 9.8: The following are number of emails of different organizations, where emails are
classified according to local and foreign emails. The classified results are shown below:
O1 O2 O3 O4 Total
Local 8 22 25 20 75
Foreign 17 73 25 10 125
Total 25 95 50 30 200
Is there any association between origin of emails and organizations?
Since χ2 > χ23 = 7.815, 𝐻0 is rejected. Hence, origin of emails depends on organization.
Hints 𝑅1 𝐶1 75 × 25
𝐸11 = = = 9.375
𝑛 200
9
Test of Hypothesis
Exercise 9
9.1 Among 157 African-American men, the mean systolic blood pressure was 146 mm Hg with a
standard deviation of 27. We wish to know if on the basis of these data, we may conclude that
the mean systolic blood pressure for a population of African-American is 140.
9.2 Are the proportions of road accidents similar in various highways of Bangladesh?
Highways 1 2 3 4 Total
No. of road accidents (Oi) 50 42 32 82 206
10
Test of Hypothesis
9.3 Is there any association between subjects taught and job satisfaction?
Job Subjects taught (Oij)
Total
satisfaction BBA EEE CS CSE SE
Yes 12 22 18 15 20 87
No 18 32 30 15 25 120
Total 30 54 48 30 45 207
9.4 Are the proportions of female students similar in various departments of AIUB?
Departments 1 2 3 4 Total
No. of female students (Oi) 250 450 150 150 1000
11
Test of Hypothesis
9.5 For a sample of size 36, ∑x = 761.6, ∑x2 = 16125.5. Is the population mean 21?
9.6 A company claims that its batteries have a mean life of 100 hours. You try to verify this for a
sample of size 21 with mean 97 hours and variance 9 hours.
9.7 Out of 25 students, 8 are female. Is the overall proportion of female students 0.40 in AIUB?
12
Test of Hypothesis
9.8 A researcher claims that 10-year old children watch 6.6 hours of TV daily on average. You
try to verify this for a sample of size 100 with mean 6.1 hours and standard deviation 2.5 hours.
9.9 Is the probation problem the same for boys and girls at AIUB? CGPA of 100 boys
and 125 girls were randomly checked. 25 boys and 18 girls were under probation.
13
Test of Hypothesis
9.10 The information about daily temperature (in 0 Celsius) of two months are as:
Month 1 𝑛1 = 31 ∑𝑥1 = 1032 𝑠1 2 = 1.41
Month 2 𝑛2 = 30 ∑𝑥2 = 1035 𝑠2 2 = 1.09
Do you think that the temperature of both the months are similar?
14
Test of Hypothesis
9.12 A group of students are classified by their residential origin and full attention to learning:
Full attention
Residential origin Total
Yes No
Rural 138 64 202
Urban 64 84 148
Total 202 148 350
Is there any association between origin and full attention?
15
Test of Hypothesis
9.17 The information about salary of two different institutions (in taka) are as:
Institution 1 𝑛1 = 15 ∑𝑥1 = 16875 𝑠1 2 = 5625
Institution 2 𝑛2 = 20 ∑𝑥2 = 26500 𝑠2 2 = 50625
Do you think that the salary information of both institutions are similar?
9.18 A toothpick manufacturer wants every box to contain exactly (on average) 500 toothpicks.
In a random sample of 25 boxes, mean is 498 toothpicks and standard deviation is 9 toothpicks.
16
Test of Hypothesis
17
Test of Hypothesis
18
Test of Hypothesis
Sample MCQs
1. A quality control specialist took a random sample of n = 10 pieces of gum and measured their
thickness and found the mean 7.6 and standard deviation 0.10. Do you think that the mean
thickness of the spearmint gum it produces is 7.5?
2. The information about daily temperature (in ° Celsius) of two months are as:
Month 1 𝑛1 = 31 Σ𝑥1 = 2042 𝑠12= 2.31
Month 2 𝑛2 = 30 Σ𝑥2 = 2045 𝑠22= 2.19
Do you think that the temperature of both the months are similar?
3. The information about daily temperature (in ° Celsius) of two cities of different days are as:
City 1 𝑛1 = 11 Σ𝑥1 = 204 𝑠12= 4
City 2 𝑛2 = 15 Σ𝑥2 = 209 𝑠22= 5
Do you think that the temperature of both the cities are similar?
4. Is gender independent of education level? A random sample of 395 people were surveyed, and
each person was asked to report the highest education level they obtained. The data that resulted
from the survey is summarized in the following table:
19