You are on page 1of 36

Eng Stat I 2104253

Hypothesis Testing
Part 2

1
Eng Stat I 2104253

Two Types of Errors


There are two types of errors which can
occur in a statistical test.
Actual Fact H0 true H0 false
Actual Fact Innocent Guilty Your
Jury’s Decision
Decision
H0 true Correct Type II Error
Innocent Correct Error
(Accept H0)
Guilty Error Correct H0 false Type I Error Correct
(Reject H0)

Define:
a = P(Type I error) = P(reject H0 when H0 is true)
b = P(Type II error) = P(do not reject H0 when H0 is false) 2
Eng Stat I 2104253

Type I and II errors


Accept Ho
Test H0 : 𝜇 = 𝜇0
Ha : 𝜇 > 𝜇0

Type I error
a

m0
Ho

Type II Error Power of Test


b

m1 3
Ho
Eng Stat I 2104253

Two Types of Errors


• We want to keep the probabilities of
error as small as possible.
• The value of a is the significance level, and is
controlled by the experimenter.
• The value of b is dependent on sample size,
difference of true mean from 𝜇0 , and a.
• Rather than “accepting H0” as true without being
able to provide a measure of goodness, we choose
to “not reject” H0.
We write: There is insufficient evidence to reject H0. 4
Eng Stat I 2104253

Type II Error (b) Determination


Reject H0 if Z > Z1−𝛼
Test H0 : 𝜇 = 𝜇0 ሜ > 𝜇0 + 𝑍1−𝛼 ⋅ 𝜎/ 𝑛
Reject H0 if X
Ha : 𝜇 > 𝜇0

𝜷 = P do not reject H𝟎 when H𝟎 is false


Test Statistic
= P (𝐗ሜ < 𝝁𝟎 + 𝐙𝟏−𝜶 ⋅ 𝝈/ 𝒏 when 𝝁 > 𝝁𝟎 )
X - m0
z=
/ n = P (𝐗ሜ < 𝝁𝟎 − 𝐙𝜶 ⋅ 𝝈/ 𝒏 when 𝝁 = 𝝁′ )

−Z𝜶 ⋅ 𝝈/ 𝒏 + 𝝁𝟎 − 𝝁′
= P (𝐙 < )
𝝈/ 𝒏

𝝁𝟎 − 𝝁′
= P (𝐙 < −𝐙𝜶 + )
𝝈/ 𝒏 5
Eng Stat I 2104253

Type II Error (b) Determination

Test H0 : 𝜇 = 𝜇0 Test Statistic


Ha : one − tailed test
X - m0
z=
/ n

6
Eng Stat I 2104253

Type II Error (b) Determination


Test Statistic
Test H0 : 𝜇 = 𝜇0
Ha : two − tailed test X - m0
z=
/ n

7
Eng Stat I 2104253

Example 4: b for Upper-Tailed Test


The Federal Drug Administration considers a concentration of
PCBs (Polychlorinated biphenyls) higher than 5 ppm. in food to
be dangerous for human consumption. 38 food samples produced
an average of 7.2 ppm. with a standard deviation of 6.2 ppm.
With a = 0.01, calculate b if the true mean ppm. of PCBs is 6 ppm.
(Ans. 0.9082)
For upper−tailed test
𝜇0 − 𝜇 ′
𝛽 = P(Z < Z1−𝛼 + )
𝜎/ 𝑛
𝟓−𝟔
= P Z < 𝟐. 𝟑𝟑 +
𝟔. 𝟐
𝟑𝟖
= P(Z < 𝟏. 𝟑𝟑)
= 0.9082
8
Eng Stat I 2104253

Example 5: b for Two-Tailed Test


• From the chemical plant exercise, calculate b and the power of
the test when µ is actually equal to 870 tons. Use a = 0.01.
H 0 : m = 880 For two−tailed test
𝜇0 −𝜇′ 𝜇0 −𝜇′
H a : m  880 𝛽 = P Z < −Z𝛼 + 𝜎 − P Z < Z𝛼 + 𝜎
2 𝑛 2 𝑛

Test statistic: 𝟖𝟖𝟎−𝟖𝟕𝟎 𝟖𝟖𝟎−𝟖𝟕𝟎

x − m0
= P Z < −(−𝟐. 𝟓𝟕𝟓) + 𝟐𝟏 − P Z < −𝟐. 𝟓𝟕𝟓 + 𝟐𝟏

z
𝟓𝟎 𝟓𝟎

s/ n = P(Z < 5.94) − P(Z < 0.79)


871 − 880
= = 0.2148
𝑷𝒐𝒘𝒆𝒓 = 𝟏 − 𝛽
21/ 50
= − 3.03 =1 – 0.2148
= 0.7852
9
Eng Stat I 2104253

Sample Size
One important thing in hypothesis testing is to
choose the appropriate sample size according to
▪ the cost
▪ the time consuming
▪ the accepted errors
✓ type I error
✓ type II error

10
Eng Stat I 2104253

Sample Size Determination


According to the calculation of type II errors,
𝜇0 − 𝜇′ m0 − m 
𝛽 = P(𝑍 < −𝑍𝛼 + ) P ( Z  Z b ) = P ( Z  − Za + )
𝜎/ 𝑛 / n
m0 − m 
Z b = − Za +
/ n
The sample size of the m0 − m 
= Za + Z b
upper-sided normal test / n
can be calculated as ( m 0 − m ) n = ( Za + Z b )

follows: ( Za + Z b ) 2  2
n=
( m 0 − m ) 2
11
Eng Stat I 2104253

Sample Size
Determination
This formula for determining sample is used for the
Z test of hypotheses,

For one - tailed test


( Za + Z b ) 2  2 For two − tailed test
n= ( Za / 2 + Z b ) 2  2
( m 0 − m ) 2 n=
( m 0 − m ) 2

12
Eng Stat I 2104253

Notes about a , b and n


▪ Size of critical region and a can always be reduced
by appropriate selection of confidence level.
▪ a and b are related, A decrease in a results in an
increase in b, given that n does not change.
▪ An increase in n reduces b, provided a is held
constant.
▪ When H0 is false, b increases as the true value of
parameters approaches the value hypothesized in H0.

13
Eng Stat I 2104253

Exercise 6: Two-Sided Test with


b and n calculation
A melting point test of n = 15 samples of binder used in
manufacturing a rocket propellant resulted in x-bar = 68 C.
Assume that the melting point is normally distributed with 
= 0.83C
• Test H0: m = 68.3 versus Ha: m ≠ 68.3 using a = 0.01.
(Ans. Z= -1.40)
• What is p-value for this test? (Ans. 0.1616)
• What is b if the true mean is 𝜇′ = 68.5? (Ans. 0.9495)
• What value of n would be required if we want b ≤ 0.1, when
m = 68.5? Assume that a = 0.01. (Ans. 257)
14
Eng Stat I 2104253

Example 6: Two-Sided Test

H0 : 𝜇 = 𝟔𝟖. 𝟑. Test statistic:


𝑥lj − 𝜇0 𝟔𝟖 − 𝟔𝟖. 𝟑
Ha : 𝜇 ≠ 𝟔𝟖. 𝟑 Zob = = = −𝟏. 𝟒𝟎
/ 𝑛 𝟎. 𝟖𝟑/ 𝟏𝟓

C𝒓𝒊𝒕𝒊𝒄𝒂𝒍 𝒗𝒂𝒍𝒖𝒆 = 𝑧𝛼/2 = 𝑧𝟎.𝟎𝟏/2 = 𝑧𝟎.𝟎𝟎𝟓 = −2.575

Since Zob > 𝑧𝛼/2 , thus we do not reject H0


p-value/2 = 0.0808
and conclude that the mean melting point
α/2 = 0.005
is equal to 68.3.
Zα/2 = -2.575 Zob = -1.40

𝑝−value = 𝟐𝑷(𝑧 < −𝟏. 𝟒𝟎) = 2 𝟎. 0𝟖𝟎𝟖 = 𝟎. 𝟏𝟔𝟏𝟔


15
Eng Stat I 2104253

Example 6: b for Two-Tailed Test


• With 𝜇′ = 68.5, 𝜇0 = 68.3,  = 0.83, n = 15, a = 0.01.

For two−tailed test


𝜇0 −𝜇′ 𝜇0 −𝜇′
𝛽 = P Z < −Z𝛼 + 𝜎 − P Z < Z𝛼 + 𝜎
2 𝑛 2 𝑛

𝟔𝟖.𝟑−𝟔𝟖.𝟓 𝟔𝟖.𝟑−𝟔𝟖.𝟓
= P Z < −(−𝟐. 𝟓𝟕𝟓) + 𝟎.𝟖𝟑 − P Z < −𝟐. 𝟓𝟕𝟓 + 𝟎.𝟖𝟑
𝟏𝟓 𝟏𝟓

= P(Z < 1.64) − P(Z < -3.5)

= 0.9495

16
Eng Stat I 2104253

Example 6: n for Two-Tailed Test


• With 𝜇′ = 68.5, 𝜇0 = 68.3, b = 0.1,  = 0.83, and a = 0.01.

For two − tailed test


(𝑍𝛼/2 + 𝑍𝛽 )2 𝜎 2
𝑛=
(𝜇0 − 𝜇′ )2
(𝑍𝟎.𝟎𝟏/2 +𝑍𝟎.𝟏 )2 (𝟎.𝟖𝟑)2
=
(𝟔𝟖.𝟑−𝟔𝟖.𝟓)2

(−𝟐.𝟓𝟕𝟓+(−𝟏.𝟐𝟖))2 (𝟎.𝟖𝟑)2
=
(𝟔𝟖.𝟑−𝟔𝟖.𝟓)2

= 256.3
Then, round up to 257.
17
Eng Stat I 2104253

Case III
• A normal population distribution/  is unknown
• When n is small (n < 30), the basic procedures are the
same as those used for large samples.
𝑥lj − 𝜇0
Test H0 : 𝜇 = 𝜇0 test statistic: 𝑡𝒐𝒃 =
𝑠/ 𝑛
Ha Rejection Region 𝑝 − value
Ha : 𝜇 > 𝜇0 𝑡𝒐𝒃 > 𝑡𝛼,𝑛−1 P (𝑡 > 𝑡𝒐𝒃 )

Ha : 𝜇 < 𝜇0 𝑡𝒐𝒃 < −𝑡𝛼,𝑛−1 P (𝑡 < 𝑡𝒐𝒃 )

Ha : 𝜇 ≠ 𝜇0 𝑡𝒐𝒃 > 𝑡𝛼,𝑛−1 or 𝑡 < −𝑡𝛼,𝑛−1 2 * P (𝑡 < |𝑡𝒐𝒃 |)


2 2
18
Eng Stat I 2104253

Example 7: Upper Tailed t-test


A sprinkler system is designed so that the average time for the
sprinklers to activate after being burned on is no more than 15
seconds. A test of 6 systems gave the following times:
17, 31, 12, 17, 13, 25
Is the system working as specified? Test using a = .05.

 xi 115
x= = = 19.167
n 6
(  x ) 2
115 2
 x2 − 2477 −
s= n = 6 = 7.387
n −1 5
19
Eng Stat I 2104253

Example 7: Upper Tailed t-test


H0 : 𝜇 = 15 (working as specified)
Ha : 𝜇 > 15 (not working as specified)

Test statistic: Degrees of freedom:


𝑥lj − 𝜇0 19.167 − 15
𝑡𝒐𝒃 = = = 1.38 𝑑𝑓 = 𝑛 − 1 = 6 − 1 = 5
𝑠/ 𝑛 7.387/ 6

Rejection Region: Reject H0 if 𝑡𝒐𝒃 > 𝑡𝛼,𝑛−1 .


Since 𝑡𝒐𝒃 = 1.38 is less than 𝑡𝛼 = .𝟎𝟓, 𝑛−1=𝟓 = 2.015. Thus, do not reject H0.

Conclusion: There is insufficient evidence to indicate that the average


activation time is greater than 15. 20
Eng Stat I 2104253

21
Eng Stat I 2104253

Example 7: Approximate p-value


For Upper-Tailed Test,
p-value = P (𝑡 > 𝑡𝑜𝑏 ) =P (𝑡 > 1.38)

From the table, we can approximate that p-value > .10.


Since p-value > .10 is greater than a = .05, thus do not reject H0 .
22
Eng Stat I 2104253

Example 7: The exact p-value


• You can get the exact p-value
using some calculators or a computer.
p-value = .113 which
is greater than .10 as
we approximated
using t-Table.

One-Sample T: Times
Test of mu = 15 vs > 15

95%
Lower
Variable N Mean StDev SE Mean Bound T P
Times 6 19.1667 7.3869 3.0157 13.0899 1.38 0.113
23
Eng Stat I 2104253

Example 8: Lower Tailed t-test


A money manager wants to test the declines in the percentage
change in total funds (Net cash inflow – outflow / Total fund)
over the next six months for his existing clients. He begins by
calling a random sample of 10 clients and inquiring about their
planned investment on the fund. As a results, the average
percentage change is 5.5 percent with sd of 10 percent. Is the
percent change in total funds according to this manager clients
decreased from last year performance of 10 percent. Use a =
0.01. (Ans : t = -1.42)

24
Eng Stat I 2104253

Example 8: Lower Tailed t-test


H0 : 𝜇 = 1𝟎
Ha : 𝜇 < 1𝟎
Test statistic: Degrees of freedom:
𝑥lj − 𝜇0 𝟓. 𝟓 − 1𝟎
𝑡= = = −𝟏. 𝟒𝟐 𝑑𝑓 = 𝑛 − 1 = 𝟏𝟎 − 1 = 𝟗
𝑠/ 𝑛 𝟏𝟎/ 𝟏𝟎

Rejection Region: Reject H0 if 𝑡𝒐𝒃 < 𝑡𝟏−𝛼,𝑛−1 .


Since 𝑡𝒐𝒃 = -1.42 is greater than 𝑡𝟏−𝛼 = .𝟗𝟗, 𝑛−1 = 𝟗 = -2.821. Thus, do not
reject H0.

Conclusion: There is insufficient evidence to indicate that the average


percentage change in total funds is less than 10%. 25
Eng Stat I 2104253

Example 8: Find Critical Value


For Lower-Tailed Test, critical value = 𝑡𝟏−𝛼 = .𝟗𝟗, 𝑛−1 = 𝟗
From t table,
P (𝑡 > 2.821) = 0.01
Then, P (𝑡 > −2.821) = 0.99
Or 𝑡𝟏−𝛼 = .𝟗𝟗, 𝑛−1 = 𝟗 = -2.821

26
Eng Stat I 2104253

Example 8: Approximate p-value


For Lower-Tailed Test, p-value = P (𝑡 < 𝑡𝑜𝑏 ) =P (𝑡 < -1.42)
From t table,
P (𝑡 > 1.383) = 0.10 orP (𝑡 < −1.383) = 0.10
P (𝑡 > 1.833) = 0.05 or P (𝑡 < −1.833) = 0.05

Then,
0.05 < P (𝑡 < −1.42) < 0.10

From the table, we can approximate that .05 < p-value < .10.
Since p-value is greater than a = .05, thus do not reject H0 .
27
Eng Stat I 2104253

Interpolation
Given this information, P (𝑡 < −1.383) =P (𝑡 > 1.383) = 0.10
P (𝑡 < −1.833) =P (𝑡 > 1.833) = 0.05

P (𝑡 < −1.42) =P (𝑡 > 1.42) = 0.05 + (0.10 − 0.05) x (1.833 − 1.42) =


0.0959
(1.833 − 1.383)

t 1.383 1.42 1.833


prob 0.10 ? 0.05

28
Eng Stat I 2104253

Type II Error (b) for t - test


Test Statistic
Test H0 : 𝜇 = 𝜇0
Ha : one or two−tailed test X - m0
t=
s/ n
For upper tailed test
(𝜇0 − 𝜇′ ) For lower tailed test
𝛽 = P(𝑡 < 𝑡𝛼,𝑛−1 + ) (𝜇0 − 𝜇′ )
𝑠/ n 𝛽 = P(𝑡 > −𝑡𝛼,𝑛−1 + )
𝑠/ n

For two−tailed test


(𝜇0 − 𝜇′ ) (𝜇0 − 𝜇′ )
𝛽 = P(−𝑡𝛼,𝑛−1 + < 𝑡 < 𝑡𝛼,𝑛−1 + )
2 𝑠/ n 2 𝑠/ n

29
Eng Stat I 2104253

Determining sample size (n) for


inference of small sample
For one - tailed test
(ta ,n −1 + t b ,n −1 ) s
2 2
For two - tailed test
n=
(m0 − m )  2
(ta / 2,n −1 + t b ,n −1 ) s
2 2

n=
( m 0 − m ) 2

30
Eng Stat I 2104253

Example 9: b Calculation
Referring to Example 7: Sprinkler system, what is the probability
that H0 is not rejected when 𝜇′ = 16, 𝜇0 = 15,  = 7.387, n = 6,
and a = 0.05.
For upper tailed test
(𝜇0 − 𝜇′ )
𝛽 = P(𝑡 < 𝑡𝛼,𝑛−1 + )
𝑠/ n
(15 − 16)
= P(𝑡 < 𝑡.05,5 + )
7.387/ 6
= P(𝑡 < 1.68)

Note that from the t table, 0.05 < P(𝑡 > 1.68) < 0.10

𝑇ℎ𝑢𝑠, 0.90 < P(𝑡 < 1.68) < 0.95 31


Eng Stat I 2104253

Example 9: Sample Size (n) Calculation


Referring to Example 7: Sprinkler system, what is the sample size
needed to collect to obtain b = 0.1 when 𝜇′ = 16, 𝜇0 = 15,
 = 7.387, and a = 0.05.

For one - tailed test


(ta ,n −1 + t b ,n −1 ) 2 s 2
n=
( m 0 − m ) 2

Try n until obtaining,


(𝑡𝛼,𝑛−1 + 𝑡𝛽,𝑛−1 )2 (𝜇0 − 𝜇′ )2
=
𝑛 𝑠2 32
Eng Stat I 2104253

Example 9: Sample Size (n) Calculation

(𝜇0 −𝜇′ )2
Right = 0.293
𝑠2

𝑛 𝑡𝛼,𝑛−1 𝑡𝛽,𝑛−1 (𝑡𝛼,𝑛−1 + 𝑡𝛽,𝑛−1 )2


Left
𝑛
10 1.833 1.383 1.034
20 1.729 1.328 0.467
30 1.699 1.311 0.302
40 1.685 1.304 0.223
32 1.696 1.309 0.282
31 1.697 1.310 0.292
33
Eng Stat I 2104253

A typical OC curve for the t test

(𝜇0 − 𝜇′ )
𝑑=
𝑠 34
Eng Stat I 2104253

OC curve for
the one-sided t-test
OC-Curve _One Sided_t
a = 0.05
1
0.9
Prob. of accepting H0

0.8
n=3
0.7
n=4
0.6
n=5
0.5
0.4
0.3
0.2
0.1
0
0

3
0.

0.

0.

1.

1.

1.

2.

2.

2.

Difference
35
Eng Stat I 2104253

End of Part 2

z-test, t-test for Mean


b and n calculation

36

You might also like