0% found this document useful (0 votes)
47 views31 pages

Hypothesis Testing

Uploaded by

trish200382
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views31 pages

Hypothesis Testing

Uploaded by

trish200382
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 31

HIT2102:Statistics for Engineers

Oliver Mhlanga

Harare Institute of Technology


omhlanga@hit.ac.zw 0712531415

November 2, 2021

Hypothesis Testing
Hypothesis Testing

I A statistical hypothesis is an assertion or conjecture about


the distribution of one or more random variables. The letter H
is used to denote a statistical hypothesis.
I Null hypothesis H0 : refers to a general or default position
that there is no relationship between measured phenomena or
that a potential medical treatment has no effect.
I Alternative hypothesis H1 : is a hypothesis used in
hypothesis testing that is contrary to the null hypothesis.
Hypothesis Testing

I Test of a statistical hypothesis: A test of a statistical


hypothesis H, is a rule or criterion stating when to reject and
when to accept H.
I Type I error: type I error occurs when one rejects the null
hypothesis when it is in fact true. Level of significance: is the
probability of a type I error and is denoted by α.
I Type II error: occurs when one accepts the null hypothesis
when it is false. The size of the type II error is denoted by β.
I The power of a statistical test is the probability of rejecting
the null hypothesis when the alternative hypothesis is true.
Hypothesis Testing
Use of the following sequence of steps in applying
hypothesis-testing methodology is recommended.
1. From the problem context, identify the parameter of interest.
2. State the null hypothesis, H0 .
3. Specify an appropriate alternative hypothesis, H1 .
4. Choose a significance level .
5. Determine an appropriate test statistic e.g
X̄ −µ
√ , Z = X̄ −µ
t = s/ n

σ/ n
6. State the rejection region for the statistic.
7. Compute any necessary sample quantities, substitute these
into the equation for the test statistic, and compute that
value.
8. Decide whether or not H0 should be rejected and report that
in the problem context.
I Steps 1 − 4 should be completed prior to examination of the
sample data.
I The P-value is the smallest level of significance that would
lead to rejection of the null hypothesis with the given data.
Hypothesis Testing

Example
The strength of steel wire made by an existing process is normally
distributed with a mean of 1250 and a standard deviation of 150.
A batch of wire is made by a new process, and a random sample
consisting of 25 measurements gives an average strength of 1312.
Assume that the standard deviation does not change. Is there
evidence at the 1% level of significance that the new process gives
a larger mean strength than the old?
Solution
H0 : µ = 1250 vs H1 : µ > 1250, one tailed test because the
question asks about a larger mean strength.
X̄ −µ
The test statistic is Zcal = σ/ √
n
Hypothesis Testing

The critical value of z for a one-tailed test for 1% level of


significance corresponds to z = 2.33. Reject H0 , if Zcal > z = 2.33
Zcal = 1312−1250

150/ 25
= 2.07 < 2.33 = z.
Since 2.07 < 2.33 , the result is not in the rejection region; we
have insufficient evidence to reject the null hypothesis. There is
not enough evidence at the 1% level of significance to say that the
new process gives a larger mean strength than the old.
TESTS ON THE MEAN OF A NORMAL
DISTRIBUTION, VARIANCE UNKNOWN

X̄ −µ
Test statistic:t = s/ √
n
Exampe 1. A 1992 article in the Journal of the American Medical
Association (”A Critical Appraisal of 98.6 Degrees F, the Upper
Limit of the Normal Body Temperature, and Other Legacies of
Carl Reinhold August Wundrlich”) reported body temperature,
gender, and heart rate for a number of subjects. The body
temperatures for 25 female subjects follow:
97.8, 97.2, 97.4, 97.6, 97.8, 97.9, 98.0, 98.0, 98.0, 98.1, 98.2, 98.3, 98.3,
98.4, 98.4, 98.4, 98.5, 98.6, 98.6, 98.7, 98.8, 98.8, 98.9, 98.9, and
99.0.
Test the hypothesis H0 : µ = 98.6 versus H1 : µ 6= 98.6, using
α = 0.05. Find the P-value.
TESTS ON THE MEAN OF A NORMAL
DISTRIBUTION, VARIANCE UNKNOWN

Solution. The parameter of interest is the true mean female body


temperature, µ.
H0 : µ = 98.6
H1 : µ 6= 98.6, at α = 0.05
X̄ −µ
t = s/ √
n
Reject H0 if |t| > t0.025,24 where t0.025,24 = 2.064
x̄ = 98.264, s = 0.04821, n = 25
98.264−98.6
t = 0.04821/ √
25
= −3.48
Since 3.48 > 2.064, reject the null hypothesis and conclude that
there is sufficient evidence to conclude that the true mean female
body temperature is not equal to 98.60 F at α = 0.05. P-value
= 2 ∗ 0.001 = 0.002
Two independent samples: Tests Concerning the difference
of two means

I variances unknown but assumed equal:n1 , n2 ≥ 30


We use Z = (x¯1 −x¯q
2 )−(µ1 −µ2 )
1 1
sp n1
+n
2
I variances unknown but assumed equal:n1 , n2 < 30
We use t = (x¯1 −x¯q
2 )−(µ1 −µ2 )
1 1
follows tn1 +n2 −2
sp n1
+n
2
(n1 −1)s12 +(n2 −1)s22
where sp2
= n1 +n2 −2 is the pooled variance from the
two samples.
Two independent samples: Tests Concerning the difference
of two means

Confidence Interval forµ1 − µ2


where variances unknown but assumed equal, a 100(1 − α)% CI for
µ1 − µ2 is given by q
(x¯1 − x¯2 ) − t α2 ,n1 +n2 −2 .sp n11 + n12 < µ1 − µ2 <
q
(x¯1 − x¯2 ) + t α2 ,n1 +n2 −2 .sp n11 + n12
Two independent samples: Tests Concerning the difference
of two means

Example 2. The average blood pressure for a control group C of 10


patients was 77.0 mmHg. The average blood pressure in a similar
group T of 10 patients on a special diet was 75.0 mmHg. Carry
out a statistical test to assess whether patients on the special diet
have lower blood pressure.
You are given that 10
P 2
P10 2
i=1 Ci = 59420, i=1 Ti = 56390
Two independent samples: Tests Concerning the difference
of two means
Solution: we are testing H0 : µC = µT vs H1 : µC > µT at 5%
level of significance.
If we assume that blood pressures are normally distributed and that
the variance of the underlying distribution for each group is the
same, then under H0
(C̄ −T̄ )−(0)
t = q 1 1 follows tn1 +n2 −2
sp n1
+n
2
Using the observed values of
n1 = n2 = 10, C̄ = 77.0, T̄ = 75.0, sp = 3.873
tcal = (77−75)−(0)
q
1 1
= 1.15
3.873 10
+ 10
1.15 < 1.734 the upper 5% point of the t18 distribution. So we
have insufficient evidence to reject H0 at the 5% level. Therefore it
is reasonable to conclude that patients on the special diet have the
same blood pressure.
Two independent samples: Tests Concerning the difference
of two means

H/W: A car manufacturer runs tests to investigate the fuel


consumption of cars using a newly developed fuel additive. Sixteen
cars of the same make and age are used, eight with the new
additive and eight as controls. The results, in miles per gallon over
a test track under regulated conditions, are as follows:
Control 27.0 32.2 30.4 28.0 26.5 25.5 29.6 27.2
Additive 31.4 29.9 33.2 34.4 32.0 28.7 26.1 30.3
If µC is the mean number of miles per gallon achieved by cars in
the control group, and µA is the mean number of miles per gallon
achieved by cars in the group with fuel additive, test:
1. H0 : µA − µC = 0 vs H1 : µA − µC > 0
2. H0 : µA − µC = 6 vs H1 : µA − µC 6= 6
Two independent samples: Tests Concerning the difference
of two means

I variances unknown but assumed unequal:n1 , n2 ≥ 30


We use Z = (x¯1 −r
x¯2 )−(µ1 −µ2 )
2 2
s s
1+ 2
n1 n2

I variances unknown but assumed unequal:n1 , n2 < 30


We use t = (x¯1 −r
x¯2 )−(µ1 −µ2 )
2 2
follows tn1 +n2 −2
s s
1+ 2
n1 n2
Two dependent samples: Tests Concerning the difference
of two means

1. Paired/matched data: n ≥ 30.


Z = sD̄−µ
√D follows N(0, 1)
/ n
D

2. Paired/matched data:n < 30, use


t = sD̄−µ
√D follows a tn−1 distribution.
/ n
D
Example 3. The average blood pressure B̄ for a group of 10
patients was 77.0 mmHg. The average blood pressure Ā after they
were put on a special diet was 75.0 mmHg. Carry out a statistical
test to assess whether
P10the special diet reduces blood pressure.
2
You are given that i=1 (Bi − Ai ) = 68.0
Two dependent samples: Tests Concerning the difference
of two means
Solution. We are testing H0 : µA = µB vs H1 : µA < µB where A is
after and B is before.
We can calculate the difference in blood pressure within each pair,
i.e. Di = Ai − Bi . If we assume that blood pressures are normally
distributed, then under H0 , the Di0 s also have a normal
distribution. So we can apply a one-sample t-test to the Di0 s,
based on the sample variance sD2
D̄−(µA −µB )

sD / n
follows tn−1
D̄ = Ā − B̄ = 75.0 − 77.0 = −2.0hP i
1 P10 2 = 1 10
sD2 = n−1 i=1 (D i − D̄) n−1 D
i=1 i
2 − nD̄ 2 =

1 2 = 3.111 = 1.7642
 
9 68.0 − 10(−2.0)
75−77
So tcal = 1.764/ √
10
= −3.59
Since tcal = −3.59 < −1.833 = t0.025,9 , we have sufficient evidence
to reject H0 at the 5% level. Therefore it is reasonable to conclude
that the special diet does reduce blood pressure.
Tests Concerning a Population Proportion

Let p denote the proportion of individuals or objects in a


population who possess a specified property. If an individual or
object with the property is labeled a success (S),then p is the
population proportion of successes. Tests concerning p will be
based on a random sample of size n from the population. We
assume a simple random sample from a binomial population so
that p = Number of successes
Population size =X
N
and p̂ = Number of Sample
successes in the sample
size = Xn , where p̂ is sample
proportion.
H0 : p = p0
Z = q p̂−p 0
p (1−p )
this holds for large sample sizes where
0 0
n
np̂, n(1 − p̂) ≥ 5.
Tests Concerning a Population Proportion

q
I Confidence Interval for p: p̂ ± Zα/2 p̂(1− n
p̂)

I Testing the value of the difference between two population


proportions
Let p1 = the proportion of successes in population 1
p2 = the proportion of successes in population 2
p1 − p2 = the point estimate of the difference in independent
proportions.
H0 : p1 = p2 and Z = r(p̂1 −p̂2 )−(p1 −p2 )
p̂1 (1−p̂1 ) p̂ (1−p̂ )
n1
+ 2 n 2
2
Confidence Interval for q
p1 − p2 : p̂1 − p̂2 ± Zα/2 p̂1 (1−
n1
p̂1 )
+ p̂2 (1−p̂2 )
n2

Alternative methods are used if either or both samples sizes are


inadequate.
Tests Concerning a Population Proportion

Example 5. Two different types of injection-molding machines are


used to form plastic parts. A part is considered defective if it has
excessive shrinkage or is discolored. Two random samples, each of
size 300, are selected, and 15 defective parts are found in the
sample from machine 1 while 8 defective parts are found in the
sample from machine 2. Is it reasonable to conclude that both
machines produce the same fraction of defective parts, using
α = 0.05? Find the P-value for this test.
Tests Concerning a Population Proportion

Solution: H0 : p1 = p2 vs H1 : p1 6= p2 at α = 0.05
n1 = n2 = 300, x1 = 15, x2 = 8, p̂1 = 0.05, p̂2 = 0.0267
p̂ = nx11 +n
+x2
2
= 0.0383
p̂1 −p̂2 0.05−0.0267
Zcal = q = q = 1.49
p̂(1−p̂)( n1 + n1 ) 1
0.0383(1−0.0383)( 300 1
+ 300 )
1 2
Since 1.96 < 1.49 < 1.96 do not reject the null hypothesis and
conclude that yes the evidence indicates that there is not a
significant difference in the fraction of defective parts produced by
the two machines at the 0.05 level of significance.
P − value = 2(1 − P(Z < 1.49)) = 0.13622
Goodness of fit test
This is another kind of hypothesis in which we do not know the
underlying distribution of the population, and we wish to test the
hypothesis that a particular distribution will be satisfactory as a
population model.
We compare observed frequencies with corresponding expected
frequencies calculated on the basis of a null hypothesis with stated
trial assumptions.
A goodness-of-fit test between observed and expected
frequencies is based on the quantity
k
X (oi − ei )2
χ2cal =
ei
i=1

where χ2cal is a value of a random variable whose sampling


distribution is approximated very close to the chi-squared
distribution with v = k − p − 1 degrees of freedom. Where k is the
number of classes and p is the number of the hypothesized
distribution estimated by sample statistics
Goodness of fit test

The symbols oi and ei represent the observed and expected


frequencies, respectively, for the i th cell. To prevent the error of
approximation in using the χ2 distribution from becoming
appreciable, each expected value of frequency should be at least 5.
QN :Consider the following frequency table of observations on the
random variable X.
Values 0 1 2 3 4
Observed Frequency 24 30 31 11 4
1. Based on these 100 observations, is a Poisson distribution
with a mean of 1.2 an appropriate model? Perform a
goodness- of-fit procedure with α = 0.05.
2. Calculate the P-value for this test.
Goodness of fit test

Solution:
Values 0 1 2 3 4
Observed Frequency 24 30 31 11 4
Expected Frequency 30.12 36.14 21.69 8.67 2.60
Since value 4 has an expected frequency less than 5, combine this
category with the previous category:
Values 0 1 2 3-4
Observed Frequency 24 30 31 15
Expected Frequency 30.12 36.14 21.69 11.67
The degrees of freedom are k - p - 1 = 4 - 0 - 1 = 3
The variable of interest is the form of the distribution for X.
H0 : The form of the distribution is Poisson vs H1 : The form of the
distribution is not Poisson atP = 0.05 i )2
The test statistic is χ2cal = ki=1 (oi −e
ei
Reject H0 if χ2cal > χ20.05,3 = 7.81
Goodness of fit test

2 2 2 2
χ2cal = (24−30.12)
30.12 + (30−36.14)
36.14 + (31−21.69)
21.69 + (15−11.67)
11.67 = 7.23
Since 7.23 < 7.81 do not reject H0 . We are unable to reject the
null hypothesis that the distribution of X is Poisson.
QN: Define X as the number of underfilled bottles from a filling
operation in a carton of 24 bottles. Sixty cartons are inspected and
the following observations on X are recorded:
Values 0 1 2 3
Frequency 39 23 12 1
1. Based on these 75 observations, is a binomial distribution an
appropriate model? Perform a goodness-of-fit procedure with
α = 0.05.
2. Calculate the P-value for this test.
Goodness of fit test

Solution: The value of p must be estimated. Let the estimate be


denoted by psample
samplemean = 0(39)+1(23)+2(12)+3(1)
75 = 0.6667
psample = samplen mean = 0.6667
24 = 0.02778
Values 0 1 2 3
Observed 39 23 12 1
Expected 38.1436 26.1571 8.5952 1.8010
Since value 3 has an expected frequency less than 3, combine this
category with that of value 2:
Values 0 1 2-3
Observed 39 23 13
Expected 38.1436 26.1571 10.3962
Goodness of fit test

The degrees of freedom are k − p − 1 = 3 − 1 − 1 = 1. The


variable of interest is the form of the distribution for the number of
under-filled cartons, X.
H0 : The form of the distribution is binomial vs H1 : The form of
the distribution is not binomial
Pk at(oαi −e
= 0.05
2
The test statistic is χcal = i=1 ei i )
2

Reject H0 if χ2cal > χ20.05,1 = 3.84


2 2 2
χ2cal = (39−38.1426)
38.1426 + (23−26.1571)
26.1571 + (13−10.3962)
10.3962 = 1.053
Since 1.053 < 3.84 do not reject H0 . We are unable to reject the
null hypothesis that the distribution of the number of under-filled
cartons is binomial at α = 0.05.
The P-value is between 0.5 and 0.1 using Interpolation P-value =
0.3048
Goodness of fit test-(test for association).

A contingency table involves two different factors in more than one


row and more than one column, giving a two-dimensional array.
Both factors are usually qualitative. We use the chi-squared
distribution to test these two factors for independence: does one of
the factors affect the other? or are they operating independently?
A contingency table with r rows and c columns is referred to as an
r × c table (r × c is read r by c).
H0 : the row-and-column methods of classification are independent
or there is no association.
H1 : there is some interaction between the two criteria of
classification
The general rule for obtaining the expected frequency of any cell is
given by the following formula:
expectedfrequency = (column grand
total)×(row total)
total
Goodness of fit test-(test for association)
A simple formula providing the correct number of degrees of
freedom is v = (r − 1)(c − 1). If H0 if χ2cal > χ2α,(r −1)(c−1) with
v = (r − 1)(c − 1) degrees of freedom, reject the null hypothesis of
independence at the -level of significance; otherwise, fail to reject
the null hypothesis.
2
Test statistic : χ2cal = ki=1 (oi −e i)
P
ei where the summation extends
over all rc cells in the r × c contingency table.
QN: The observed numbers of days on which accidents occurred in
a factory on three successive shifts over a total of 300 days are as
shown below. The numbers of days without accidents for each
shift were obtained by subtraction.

Shift Days with Accidents Days without accidents Total


A 1 299 300
B 7 293 300
C 7 293 300
Total 15 885 900
Goodness of fit test-(test for association)
Is the difference in number of days with accidents between
different shifts statistically significant? That is, is there evidence
that the probability of accidents depends on the shift? Use the 5%
level of significance.
Solution: H0 : The numbers of days with accidents are independent
of the shift.
H1 : Some shifts have greater probability of accidents than others.
The analysis will use the chi-squared test for frequency distribution
2
with χ2cal = ki=1 (oi −e i)
P
ei

Shift Days with Accidents Days without accidents Total


A 1 [5] 299 [295] 300
B 7 [5] 293 [295] 300
C 7[5] 293 [295] 300
Total 15 885 900
Goodness of fit test-(test for association)

χ2cal =
(1−5)2 2 2 2 2 2

5 + (7−5)
5 + (7−5)
5 + (299−295)
295 + (293−295)
295 + (293−295)
295 = 4.88
Since 4.88 < 5.991 = χ0.05,2 , the calculated 4.88 value of χ2cal is
2

not significant at the 5% level of significance. Therefore we have


insufficient evidence to reject the null hypothesis.
The End

You might also like