chapter 8 tests of hypotheses based on a single …baek.math.umbc.edu/stat355/ch8_written.pdffour...

28
Chapter 8 Tests of Hypotheses Based on a Single Sample Seungchul Baek STAT 355 Introduction to Probability and Statistics for Scientists and Engineers Seungchul Baek STAT 355 Introduction to Probability and Statistics for Scientists and Engineers 1

Upload: others

Post on 04-Aug-2020

13 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Chapter 8 Tests of Hypotheses Based on a Single …baek.math.umbc.edu/stat355/ch8_written.pdfFour Steps for Hypothesis Test 1 State the null (H 0) and alternative (Ha or H 1) hypotheses

Chapter 8 Tests of Hypotheses Based on a SingleSample

Seungchul Baek

STAT 355 Introduction to Probability and Statistics for Scientists andEngineers

Seungchul Baek STAT 355 Introduction to Probability and Statistics for Scientists and Engineers 1

Page 2: Chapter 8 Tests of Hypotheses Based on a Single …baek.math.umbc.edu/stat355/ch8_written.pdfFour Steps for Hypothesis Test 1 State the null (H 0) and alternative (Ha or H 1) hypotheses

Statistical Hypothesis

Definition: a statistical hypothesis is a statement about the parameters ofone or more populations.

Example:

The proportion of underweight milk is more than 3% in a local farm.

More than 7% of the landings for a certain airline exceed the runway.

The defective rate of the water filter is less than 5%.

The rate of failing STAT 355 class is 10%.

Seungchul Baek STAT 355 Introduction to Probability and Statistics for Scientists and Engineers 2

← :÷

i:i÷.

Page 3: Chapter 8 Tests of Hypotheses Based on a Single …baek.math.umbc.edu/stat355/ch8_written.pdfFour Steps for Hypothesis Test 1 State the null (H 0) and alternative (Ha or H 1) hypotheses

Four Steps for Hypothesis Test

1 State the null (H0) and alternative (Ha or H1) hypotheses.

2 Collect the data and calculate test statistic assuming H0 is true.

3 Assuming the H0 is true, calculate the p-value.4 Make a decision based on the p-value. We either reject H0 or fail to

reject H0.

Let us look at an example to illustrate these steps.

Seungchul Baek STAT 355 Introduction to Probability and Statistics for Scientists and Engineers 3

O-D -

ga- e-

-

Page 4: Chapter 8 Tests of Hypotheses Based on a Single …baek.math.umbc.edu/stat355/ch8_written.pdfFour Steps for Hypothesis Test 1 State the null (H 0) and alternative (Ha or H 1) hypotheses

Example: Defective Water Filters

Historically, the defective rate of water filters is 7% in a certain factory.A new quality control system is introduced to reduce the defective rate.Suppose that we randomly choose 300 water filters, and calculatep̂ = 0.041. We want to test whether the new system reduce thedefective rate or not.

Let p be the proportion of defective water filters in the factory afterintroducing the new system.

Seungchul Baek STAT 355 Introduction to Probability and Statistics for Scientists and Engineers 4

god

Page 5: Chapter 8 Tests of Hypotheses Based on a Single …baek.math.umbc.edu/stat355/ch8_written.pdfFour Steps for Hypothesis Test 1 State the null (H 0) and alternative (Ha or H 1) hypotheses

Step 1: Null and Alternative Hypotheses

Null hypothesis is denoted by H0, which represents what we assumeto be true. Under null hypothesis, the exact value of the parameter isspecified.

Alternative hypothesis is denoted by Ha or H1, which represents theresearcher’s interest.

In most situations, researchers want to reject null hypothesis in favor ofthe alternative hypothesis by performing some experiments.

In defective water filters example,

H0 : p = 0.07Ha : p < 0.07

Ha implies that the new system reduces the defective rate.

Seungchul Baek STAT 355 Introduction to Probability and Statistics for Scientists and Engineers 5

⇒e---

o

o÷o¥

Page 6: Chapter 8 Tests of Hypotheses Based on a Single …baek.math.umbc.edu/stat355/ch8_written.pdfFour Steps for Hypothesis Test 1 State the null (H 0) and alternative (Ha or H 1) hypotheses

Step 2: Calculate Test Statistic

How should we make a decision based on the sample?

We reject H0, if ‚p is far less than 0.07, which is not likely to happen ifassuming p = 0.07.

We need the sampling distribution to quantify how far is REALLY far.

Seungchul Baek STAT 355 Introduction to Probability and Statistics for Scientists and Engineers 6

' co - og

⇐- -

Page 7: Chapter 8 Tests of Hypotheses Based on a Single …baek.math.umbc.edu/stat355/ch8_written.pdfFour Steps for Hypothesis Test 1 State the null (H 0) and alternative (Ha or H 1) hypotheses

Test Statistic for ProportionRecall that if H0 : p = p0 is true, then

‚p ≥ AN

Q

ap0,

Ûp0(1 ≠ p0)

n

R

b .

In this case, the test statistic can be calculated as

Z = p̂ ≠ p0Òp0(1≠p0)

n

≥ AN (0, 1)

In defective water filter example, assuming H0 is true, the test statisticis calculated as

z0 = p̂ ≠ p0Òp0(1≠p0)

n

= 0.041 ≠ 0.07Ò

0.07(1≠0.07)300

= ≠1.97.

Question: is this number likely to appear if we assume p0 = 0.07 istrue?Seungchul Baek STAT 355 Introduction to Probability and Statistics for Scientists and Engineers 7

=p-spec

: t' '"" to :P-_ po=o

.

o-② ④-

÷÷.

-

- i .

00 'O

Page 8: Chapter 8 Tests of Hypotheses Based on a Single …baek.math.umbc.edu/stat355/ch8_written.pdfFour Steps for Hypothesis Test 1 State the null (H 0) and alternative (Ha or H 1) hypotheses

Step 3: Calculate p-value

The p-value is the probability of getting the sample results you got orsomething more extreme assuming that the null hypothesis is true.

If the p-value is small, we doubt the null hypothesis since it is not likelyto observe such an “extreme” test statistic under H0. This is theevidence against null hypothesis.

On the other hand, if the p-value is large, we have a pretty goodchance to observe the computed test statistic under H0. Hence, thereis no reason to question the H0.

In other words, the p-value for a hypothesis test measures how muchevidence we have against H0, that is,

the smaller the p-value =∆ the more evidence against H0

Seungchul Baek STAT 355 Introduction to Probability and Statistics for Scientists and Engineers 8

I ±÷⇒iii÷f-

-

.

-

-

=

Page 9: Chapter 8 Tests of Hypotheses Based on a Single …baek.math.umbc.edu/stat355/ch8_written.pdfFour Steps for Hypothesis Test 1 State the null (H 0) and alternative (Ha or H 1) hypotheses

Step 3: Calculate p-value Cont’d

In defective water filter example, the p-value of the test is:

P(Z < ≠1.97) = 0.024

Why “ < ”?

In our example, the p-value is 0.024, do you think it is large?

Seungchul Baek STAT 355 Introduction to Probability and Statistics for Scientists and Engineers 9

O

①§-

O -0I

-

① - ¥12717.1).

Page 10: Chapter 8 Tests of Hypotheses Based on a Single …baek.math.umbc.edu/stat355/ch8_written.pdfFour Steps for Hypothesis Test 1 State the null (H 0) and alternative (Ha or H 1) hypotheses

Step 4: Conclusion

If the p-value is small, we reject the null hypothesis and conclude thealternative hypothesis.

If the p-value is not small, we do not reject the null hypothesis and donot conclude the alternative hypothesis.

æ What does it mean???

There is one remaining question, how small should p-value be to beconsidered as “small”? We need level of significance to answer it.

Seungchul Baek STAT 355 Introduction to Probability and Statistics for Scientists and Engineers 10

I O O- -

→a

-

Page 11: Chapter 8 Tests of Hypotheses Based on a Single …baek.math.umbc.edu/stat355/ch8_written.pdfFour Steps for Hypothesis Test 1 State the null (H 0) and alternative (Ha or H 1) hypotheses

Step 4: Conclusion Cont’d

We use – to denote the level of significance.

Level of significance is determined before you see the data.

In practice, we usually set – = 0.05. Other common choices are– = 0.01, or – = 0.1.

We simply compare the p-value with the – level. We reject H0 if thep-value is less than –, and do not reject H0 if the p-value is greaterthan or equal to –

In defective water filter example, p-value= 0.024 < 0.05 (pre-defined),therefore, we reject H0, and conclude that we have su�cient evidenceto conclude the new system reduces the defective rate (note: weconclude Ha in the context of the question.)

Seungchul Baek STAT 355 Introduction to Probability and Statistics for Scientists and Engineers 11

O

- -

-

.

-

o

Page 12: Chapter 8 Tests of Hypotheses Based on a Single …baek.math.umbc.edu/stat355/ch8_written.pdfFour Steps for Hypothesis Test 1 State the null (H 0) and alternative (Ha or H 1) hypotheses

Example: Flu Outbreak

A certain type of flu outbreaks in northern part of the USA. The historicalrecords shows that there are 7% of the residences in Columbia carrying fluunder usual condition. Researchers want to see whether there is an outbreakin Columbia, there are 30 out of 250 randomly chosen people in the samplecarrying flu.

Can we conclude that there is an outbreak in Columbia? Answer thequestion using hypothesis testing approach with – = 0.05.

Seungchul Baek STAT 355 Introduction to Probability and Statistics for Scientists and Engineers 12

0

Page 13: Chapter 8 Tests of Hypotheses Based on a Single …baek.math.umbc.edu/stat355/ch8_written.pdfFour Steps for Hypothesis Test 1 State the null (H 0) and alternative (Ha or H 1) hypotheses

Inference for p: Hypothesis TestStep 1: State H0 and H1

H0 : p = 0.07Ha : p > 0.07

Step 2: Calculate test statistic assuming H0 is true

Z =‚p ≠ p0Òp0(1≠p0)

n

= 0.12 ≠ 0.07Ò

0.07(1≠0.07)250

= 3.10.

Step 3: Calculate p-value

p-value = P(Z > 3.10) ¥ 0.001.

Step 4: Draw the conclusion: With – = 0.05, the p-value is smallerthan 0.05. We reject H0, and conclude that there is an outbreak inColumbia.Seungchul Baek STAT 355 Introduction to Probability and Statistics for Scientists and Engineers 13

""a:i÷÷i÷,

①.

①I ①

Po -- o.o 't .

Ha : Pzo. 07 Hop :P " - °7plz

'

3. lol . . .

It;i:*:*,CO. 05

Page 14: Chapter 8 Tests of Hypotheses Based on a Single …baek.math.umbc.edu/stat355/ch8_written.pdfFour Steps for Hypothesis Test 1 State the null (H 0) and alternative (Ha or H 1) hypotheses

Method of Evaluating a Test: Type I and Type II Errors

There are two mistakes we can make in a hypothesis test.

Type I error: H0 is rejected but in reality H0 is trueType II error: H0 is not rejected but in reality H0 is false

Seungchul Baek STAT 355 Introduction to Probability and Statistics for Scientists and Engineers 14

- -

- . -

TE

.

E . . .. ..②-0 O

p .

Page 15: Chapter 8 Tests of Hypotheses Based on a Single …baek.math.umbc.edu/stat355/ch8_written.pdfFour Steps for Hypothesis Test 1 State the null (H 0) and alternative (Ha or H 1) hypotheses

Controlling Risk

The probability of type I error is denoted by – (same as the level ofsignificance), i.e.,

– = P(reject H0 | H0 is true).

The type II error is denoted by —, i.e.,

— = P(fail to reject H0 | Ha is true at some value).

The ideal situation is that both type I and type II error is 0, whichmeans we can always make correct decision. However, only oracleknows the true. For us, every decision we make will have associatederror probabilities.

Seungchul Baek STAT 355 Introduction to Probability and Statistics for Scientists and Engineers 15

-

o -

--

-

-

e

Page 16: Chapter 8 Tests of Hypotheses Based on a Single …baek.math.umbc.edu/stat355/ch8_written.pdfFour Steps for Hypothesis Test 1 State the null (H 0) and alternative (Ha or H 1) hypotheses

Controlling Risk

In practice, if we try to decrease the type I error, the type II error willincrease, and vice versa. Remember, there is no free lunch!

Researchers should consider the consequences of type I error and typeII error to help determine the significance level.

Seungchul Baek STAT 355 Introduction to Probability and Statistics for Scientists and Engineers 16

Page 17: Chapter 8 Tests of Hypotheses Based on a Single …baek.math.umbc.edu/stat355/ch8_written.pdfFour Steps for Hypothesis Test 1 State the null (H 0) and alternative (Ha or H 1) hypotheses

Example: Controlling Risk

You are planning to hold a party for our STAT 355 class, and you want toknow at 95% confidence level, whether less than 60% of students willattend.

H0 : p = 0.6Ha : p < 0.6

Describe a Type I error for this problem and the potential consequence.

Describe a Type II error for this problem and the potential consequence.

Seungchul Baek STAT 355 Introduction to Probability and Statistics for Scientists and Engineers 17

H/ reject Ho .

-

-

Ha true( fail to reject Ho .

Page 18: Chapter 8 Tests of Hypotheses Based on a Single …baek.math.umbc.edu/stat355/ch8_written.pdfFour Steps for Hypothesis Test 1 State the null (H 0) and alternative (Ha or H 1) hypotheses

Hypothesis Test on Population Mean

Step 1: State the null (H0) and alternative (Ha) hypotheses.

Null hypothesis H0 : µ = µ0

Alternative hypothesis

Right-tail Ha : µ > µ0Left-tail Ha : µ < µ0Two-tail Ha : µ ”= µ0

Step 2: Collect the data and calculate test statistic assuming H0 is true.

‡ known: Z = Y ≠ µ0‡/

Ôn

‡ unknown: t = Y ≠ µ0s/

Ôn

Seungchul Baek STAT 355 Introduction to Probability and Statistics for Scientists and Engineers 18

I"

O

E-

8in:"

Page 19: Chapter 8 Tests of Hypotheses Based on a Single …baek.math.umbc.edu/stat355/ch8_written.pdfFour Steps for Hypothesis Test 1 State the null (H 0) and alternative (Ha or H 1) hypotheses

Hypothesis Test on Population Mean

Step 3: Assuming the null hypothesis is true, calculate the p-value.

Step 4: Draw a conclusion based on the p-value. We either reject H0 orfail to reject H0.

Seungchul Baek STAT 355 Introduction to Probability and Statistics for Scientists and Engineers 19

i""-

Page 20: Chapter 8 Tests of Hypotheses Based on a Single …baek.math.umbc.edu/stat355/ch8_written.pdfFour Steps for Hypothesis Test 1 State the null (H 0) and alternative (Ha or H 1) hypotheses

Example: Pipe Diameter in slides of Chapter 7

Go back to pipe diameter data. Based on past experience, the engineersassume a normal population distribution (for the pipe diameters) withknown population standard deviation 0.02. Researchers want to find outwhether the pipe diameter is 1.31 with a significance level 0.05.

Seungchul Baek STAT 355 Introduction to Probability and Statistics for Scientists and Engineers 20

p - 24 .

✓ g-

-0.02

O-

Page 21: Chapter 8 Tests of Hypotheses Based on a Single …baek.math.umbc.edu/stat355/ch8_written.pdfFour Steps for Hypothesis Test 1 State the null (H 0) and alternative (Ha or H 1) hypotheses

ExampleStep 1: State hypotheses

H0 : µ = 1.31Ha : µ ”= 1.31

Step 2: Test statistic

z0 = 1.30 ≠ 1.310.02/

Ô25

= ≠2.5

Step 3: p-value

p-value = 2P(Z < ≠| ≠ 2.5|) = 2P(Z < ≠2.5) = 0.012

Step 4: Conclusion As p-value=0.012< – = 0.05, we reject H0. Wehave enough evidence to conclude the mean pipe diameter is not 1.31inches.Seungchul Baek STAT 355 Introduction to Probability and Statistics for Scientists and Engineers 21

-

ez j' " ""

--0

-

Page 22: Chapter 8 Tests of Hypotheses Based on a Single …baek.math.umbc.edu/stat355/ch8_written.pdfFour Steps for Hypothesis Test 1 State the null (H 0) and alternative (Ha or H 1) hypotheses

Example: Pipe Diameter in slides of Chapter 7

Go back to pipe diameter data. Assume the pipe diameters are normalitydistributed with unknown population variance. Researchers what to findout whether the pipe diameter is less than 1.308. Assume a significancelevel 0.05.

Is this test di�erent from the previous one? Why?

Seungchul Baek STAT 355 Introduction to Probability and Statistics for Scientists and Engineers 22

O-

Page 23: Chapter 8 Tests of Hypotheses Based on a Single …baek.math.umbc.edu/stat355/ch8_written.pdfFour Steps for Hypothesis Test 1 State the null (H 0) and alternative (Ha or H 1) hypotheses

Example

Step 1: State hypotheses

Step 2: Test statistic

Step 3: p-value

Step 4: Conclusion

Seungchul Baek STAT 355 Introduction to Probability and Statistics for Scientists and Engineers 23

pop . parameter / pop. mean

Hoi Ii -

- no

H , : Mcl.3I

T - toto =¥Ntn

- I

=l . 30 - I . 3 of =e

PIT ?"

- 3. Go) → pti )in R

.

. ::÷:÷i

Page 24: Chapter 8 Tests of Hypotheses Based on a Single …baek.math.umbc.edu/stat355/ch8_written.pdfFour Steps for Hypothesis Test 1 State the null (H 0) and alternative (Ha or H 1) hypotheses

R Code to Produce t-Test

> t.test(pipes,alternative="less", mu=1.308)

One Sample t-test

data: pipes

t = -4.0243, df = 24, p-value = 0.0002478

alternative hypothesis: true mean is less than 1.308

95 percent confidence interval:

-Inf 1.302872

sample estimates:

mean of x

1.29908

Seungchul Baek STAT 355 Introduction to Probability and Statistics for Scientists and Engineers 24

dataHo :p

--1.30€Ha:p

308 M > 1.30L

" greater"

①me - -

hi. feel .3of' ' two-sided

"

O-

so.

=

-

Page 25: Chapter 8 Tests of Hypotheses Based on a Single …baek.math.umbc.edu/stat355/ch8_written.pdfFour Steps for Hypothesis Test 1 State the null (H 0) and alternative (Ha or H 1) hypotheses

Example: Sales

For a long time, the monthly average sales for a product have been $30,000.A company invests a lot of money into new advertising for the product andthen conducts a hypothesis test with a level of significance 0.05 in order tosee if monthly sales of the product have increased. The hypotheses are:H0 : µ = 30, 000 and HA : µ > 30, 000.The conclusion of the test is that monthly sales have increased.

What is the probability of type I error for this test?

Suppose that in reality, monthly sales did not increase and theadvertisement had no e�ect. What type of error occurred?

Seungchul Baek STAT 355 Introduction to Probability and Statistics for Scientists and Engineers 25

-I .

Ho is true:#Hoisting

Type I error .

Page 26: Chapter 8 Tests of Hypotheses Based on a Single …baek.math.umbc.edu/stat355/ch8_written.pdfFour Steps for Hypothesis Test 1 State the null (H 0) and alternative (Ha or H 1) hypotheses

Example : Football Helmets

A researcher claims that at least 10% of all football helmets havemanufacturing flaws that could potentially cause injury to the wearer. Asample of 200 helmets revealed that 16 helmets contained such defects.

Does this finding support the researcher’s claim? Use – = 0.01. Findthe p-value.

Explain how the previous question could be answered with a confidenceinterval.

Seungchul Baek STAT 355 Introduction to Probability and Statistics for Scientists and Engineers 26

3. Plz"

>"

-0.9428)t ' iii÷j

= o.su p -- th Franta D2 . z=o.otno I

4 .

0.82T " o ' = 0.08 .= - 0.9428←⇒fa:ltujut

- -

-

[' I

. § I 2.57* include

what:#Ho ?

To<'

I '@ B. UB )im

4370. I -

Page 27: Chapter 8 Tests of Hypotheses Based on a Single …baek.math.umbc.edu/stat355/ch8_written.pdfFour Steps for Hypothesis Test 1 State the null (H 0) and alternative (Ha or H 1) hypotheses

Example: Lenses

A manufacturer of inter-ocular lenses will qualify a new grinding machine ifthere is evidence that the percentage of polished lenses that contain surfacedefects does not exceed 2%. A random sample of 250 lenses contains 6defective lenses.

Formulate and test an appropriate set of hypotheses to determinewhether the machine can be qualified. Use – = 0.01. Find the p-value.

Explain how the previous question could be answered with a confidenceinterval.

Seungchul Baek STAT 355 Introduction to Probability and Statistics for Scientists and Engineers 27

1. iii."i seize:L2

. hp = % -- 0.024 4 . fail to hit

⇐=

÷."- Hoo

D

- -

qqolo I I 2-51 ⇒ f- o.ooof, o . 0488).✓

er . what?'t ' it %¥J

Page 28: Chapter 8 Tests of Hypotheses Based on a Single …baek.math.umbc.edu/stat355/ch8_written.pdfFour Steps for Hypothesis Test 1 State the null (H 0) and alternative (Ha or H 1) hypotheses

True of False

If we reject H0 : µ = 0 in a study with – = 0.01, then we also reject itwith – = 0.05.

A study about the change in weight on a new diet reportsp-value=0.043 for testing H0 : µ = 0 against H1 : µ ”= 0 under– = 0.05. If the authors report a 95% confidence interval for µ, thenthe interval would contain 0.

A 95% C.I. for µ=population mean IQ is (96, 110). In the test ofH0 : µ = 100 against H1 : µ ”= 100, the p-value would be greater than0.05.

When testing H0 : µ = 100 against H1 : µ ”= 100, the probability of aType II error decreases when the true population mean µ is furtheraway from 100.

Seungchul Baek STAT 355 Introduction to Probability and Statistics for Scientists and Engineers 28

←=

T②

andso . or

-43,013L Fa③IO -

Trued

th