65
Intermediate Statistical Analysis Professor K. Leppel

Intermediate Statistical Analysis Professor K. Leppel

Embed Size (px)

Citation preview

Page 1: Intermediate Statistical Analysis Professor K. Leppel

Intermediate Statistical Analysis

Professor K. Leppel

Page 2: Intermediate Statistical Analysis Professor K. Leppel

Hypothesis Testing

One Sample

Page 3: Intermediate Statistical Analysis Professor K. Leppel

Notation

H0: hypothesis being tested “null hypothesis”

Ha or H1: alternative hypothesis

Example: H0: = 100 versus H1: 100

Page 4: Intermediate Statistical Analysis Professor K. Leppel

Type I and Type II errors

Type I error – rejecting the null hypothesis when it’s true.

Type II error – accepting the null hypothesis when it’s false.

Page 5: Intermediate Statistical Analysis Professor K. Leppel

Situation

H0 is true H0 is false

Decision

accept H0

reject H0

Page 6: Intermediate Statistical Analysis Professor K. Leppel

Situation

H0 is true H0 is false

Decision

accept H0

reject H0

incorrect decision

(type I error)

probability = = level of significance

Page 7: Intermediate Statistical Analysis Professor K. Leppel

Situation

H0 is true H0 is false

Decision

accept H0 correct decision

probability = 1- = confidence level

reject H0

incorrect decision

(type I error)

probability = = level of significance

Page 8: Intermediate Statistical Analysis Professor K. Leppel

Situation

H0 is true H0 is false

Decision

accept H0 correct decision

probability = 1- = confidence level

incorrect decision (type II error)

probability =

reject H0

incorrect decision

(type I error)

probability = = level of significance

Page 9: Intermediate Statistical Analysis Professor K. Leppel

Situation

H0 is true H0 is false

Decision

accept H0 correct decision

probability = 1- = confidence level

incorrect decision (type II error)

probability =

reject H0

incorrect decision

(type I error)

probability = = level of significance

correct decision

probability = 1- = power of the test

Page 10: Intermediate Statistical Analysis Professor K. Leppel

Critical region

Values of the test statistic for which the null hypothesis is rejected. Example: Suppose you are testing whether or not the population mean is 100. Your test statistic is the sample mean. If the sample mean is very far from 100, perhaps less than 90 or more than 110, you reject the hypothesis that the mean is 100.Then your critical region is the set of values of the sample mean that are less than 90 or more than 110.

Page 11: Intermediate Statistical Analysis Professor K. Leppel

Acceptance region Values of the test statistic for which the null hypothesis is accepted. Example: Again suppose you are testing whether the population mean is 100, and your test statistic is the sample mean. You decided to reject the null hypothesis if the sample mean is less than 90 or more than 110.You accept the null hypothesis if the sample mean is between 90 and 110.Then your acceptance region is the set of values of the sample mean that are between 90 and 110.

Page 12: Intermediate Statistical Analysis Professor K. Leppel

Example: Suppose you want to know whether the mean IQ at a particular university is 130. You know the population standard deviation is 5.4.

To test the hypothesis, you take a random sample of 25 observations.

The mean IQ of the sample is 128.

130H and 130H So, 10 ::

Page 13: Intermediate Statistical Analysis Professor K. Leppel

a 130 b

If the null hypothesis is correct, the center of the distribution of the sample mean is 130.

acceptance region

crit. reg.crit. reg.

Our critical and acceptance regions look like this graph.We need to determine what a and b are so that we know when we should accept our null hypothesis and when we should reject it.

X

Page 14: Intermediate Statistical Analysis Professor K. Leppel

a 130 b

Suppose we want our probability of type I error to be at most 0.05.

acceptance region

crit. reg.crit. reg.

We want the probability of rejecting the null hypothesis when it is actually correct to be 0.05. So we are in the critical region when the graph is centered at 130 with probability 0.05.The area in each of the two tails of the critical region is half of 0.05 or 0.025.

X

0.025 0.025

Page 15: Intermediate Statistical Analysis Professor K. Leppel

normal. standard is

n

XZ So,

ndeviation standard and mean with

normal isit rem,limit theo central the toAccording.X ismean sampleOur

.

Page 16: Intermediate Statistical Analysis Professor K. Leppel

130) |aXPr( .025 130) |bXPr(

130

n

a

n

-XPr .025 130

n

-b

n

-XPr

||

130

n

aZPr .025 130

n

-bZPr

||

2545

130aZPr .025

2545

130-bZPr

..

Page 17: Intermediate Statistical Analysis Professor K. Leppel

2545

130aZPr .025

2545

130-bZPr

..

.025 .025

Z

2545

130b 0

2545

130a..

The equation we derived implies this graph of the standard normal or Z distribution.From the Z table, we know that the cut-off points for the tails with area 0.025 must be 1.96 and -1.96.

-1.96 1.96

Page 18: Intermediate Statistical Analysis Professor K. Leppel

1.96

2545

130b and 1.96-

2545

130a So

..

Solving the first equation for a and the second equation for b, we find a = 127.88 and b = 132.12.

Page 19: Intermediate Statistical Analysis Professor K. Leppel

127.88 130 132.12

Returning to our graph for the sample mean, we have this picture.

acceptance region

crit. reg.crit. reg.

So if our sample mean is between 127.88 and 132.12, we accept the null hypothesis that the population mean IQ is 130.

If our sample mean is less than 127.88 or more than 132.12, we reject the null hypothesis and accept the alternative that the population mean is not 130.

X

Page 20: Intermediate Statistical Analysis Professor K. Leppel

127.88 130 132.12

Since the sample mean was 128, what would our decision be?

acceptance region

crit. reg.crit. reg.

X

Accept H0: = 130

If the sample mean was 127 instead, what would our decision be?

130Haccept and 130HReject 10 ::

Page 21: Intermediate Statistical Analysis Professor K. Leppel

In the hypothesis test we just performed, we determined the cut-off points a and b for the sample mean, and then checked to see if our observed values were in the acceptance or critical region.

Another way of doing the hypothesis test is to use the “p-value.”The p-value is the probability that the value of the sample mean is as far away from the hypothesized mean as observed, if the hypothesized mean is actually correct.If the p-value is greater than our test level , we accept the null hypothesis.If the p-value is less than , we reject the null hypothesis. The reasoning when the p-value is less than is this: The probability of seeing the observed value of the sample mean, if the null hypothesis is true, is very small. Since it’s unlikely under the assumption of the null hypothesis, we reject that hypothesis.

Page 22: Intermediate Statistical Analysis Professor K. Leppel

Let’s do the same problem using the p-value method. Recall that the sample mean was 128, the population standard deviation was 5.4, the sample size was 25, and the test level was 0.05.

= 2 (0.5-0.4678)

= 2 (0.0322)

= 0.0644

Using a test level of = 0.05, we accept the null hypothesis, since the p-value > 0.05 .

-1.85 0 1.85 Z

.4678.4678.0322 .0322

130) ismean population thegiven that saw weas 130 fromfar as is X(Pr

130) ismean population thegiven that 132 Xor 128 X(Pr

130) ismean population thegiven that 128 X(2Pr

130 |

n

-128

n

-X2Pr

254.5

130-128

n

-X2Pr

1.85 2Pr Z

Page 23: Intermediate Statistical Analysis Professor K. Leppel

Quick & Dirty Method of Hypothesis Testing

1. Convert the sample mean to a standard normal Z-statistic:

n

-XZ

2. Sketch the critical & acceptance regions in terms of a Z-statistic.

3. Make the decision.

Page 24: Intermediate Statistical Analysis Professor K. Leppel

Same problem one more time: Recall that the sample mean was 128, the population standard deviation was 5.4, the sample size was 25, and the test level was 0.05.

851.

Based on a test level or of 0.05, we have the graph below.

-1.96 0 1.96 Z

.4750.4750.0250 .0250

crit. reg.crit. reg.

Since the Z-value -1.85 is in the acceptance region, we accept the null hypothesis that the population mean is 130.

n

XZ

2545

130128.

128X

Page 25: Intermediate Statistical Analysis Professor K. Leppel

When a hypothesis has only one value such as = 130, we call it a simple hypothesis.When a hypothesis has more than one value,

we call it a composite hypothesis.

Some examples:

130

130

130

Page 26: Intermediate Statistical Analysis Professor K. Leppel

e.alternativ theoffavor in hypothesis null therejected we130,an smaller thmuch or larger much mean was sample theIf

region. critical tailed-2 a had we130,:H and 130:H hypotheses thehad When we 10

130.an smaller thmuch ismean sample theifonly e,alternativ theoffavor in hypothesis null reject the weNow

region. critical tailed-1 a have we130,:H and 130:H hypotheses thehave weif However, 10

130.n larger thamuch ismean sample theifonly e,alternativ theoffavor in hypothesis null reject the We

region. critical tailed-1 a have also we130,:H and 130:H hypotheses thehave weIf 10

The critical region depends on the alternative hypothesis, not the null.If the alternative is “not equal to”, the critical region is 2-tailed.If the alternative is “greater than”, the critical region is the right tail only.If the alternative is “less than”, the critical region is the left tail only.

Page 27: Intermediate Statistical Analysis Professor K. Leppel

1-Tailed Hypothesis Test

at the 5% level if the sample mean is 128 based on a sample of size 25, and the population standard deviation is 5.4.

We will again use these 3 methods to do this problem:1. Determine critical region in terms of the sample

mean.2. P-value3. “Quick & Dirty”

130H versus 130 :Hest T 10 :

Page 28: Intermediate Statistical Analysis Professor K. Leppel

1. Determine critical region in terms of the sample mean.

130

.45

.05crit. reg.

Since the alternative hypothesis is <130, the critical region is the left tail.Since the test level is 5%, the area of the critical region is 0.05.

Acceptance region

We sketch the graph under the assumption that the null hypothesis is true, centering the graph at the most conservative value of that hypothesis, = 130.

a X

130H 130 :H

1

0

:

Page 29: Intermediate Statistical Analysis Professor K. Leppel

0.05 130) |aXPr(

0.05 130

n

a

n

-XPr

|

0.05 130

n

aZPr

|

0.05

2545

130aZPr

.

130

.45

.05

crit. reg.

Acceptance region

a X

0

.45

.05

crit. reg.

Acceptance region

Z

2545

130a.

Using the Z table, we find the cut-off point must be -1.645.

6451

2545

130a So, .

.

Page 30: Intermediate Statistical Analysis Professor K. Leppel

,..

a for 6451

2545

130a Solving

we find a = 128.22.

128.22

Our value of the sample mean was 128.

Since 128 is in the critical region, we reject the null hypothesis and accept the alternative that < 130.

130

.45

.05crit. reg.

Acceptance region

a X

Page 31: Intermediate Statistical Analysis Professor K. Leppel

2. P-value method. Keep in mind that the sample mean is 128, the population standard deviation is 5.4, the sample size is 25, and the test level is 0.05.

= 0.5 – 0.4678

= 0.0322

Using a test level of = 0.05, we reject the null hypothesis and accept the alternative that <130, since the p-value < 0.05 .

Z

130) ismean population thegiven that saw weas 130 belowfar as is X(Pr

130) ismean population thegiven that 128 X(Pr

130 |

n

-128

n

-XPr

254.5

130-128

n

-XPr

1.85 Pr Z0

.0322

-1.85

Page 32: Intermediate Statistical Analysis Professor K. Leppel

3. “Quick & Dirty” Method. Again, remember that the sample mean was 128, the population standard deviation was 5.4, the sample size was 25, and the test level was 0.05.

851.

Based on a test level or of 0.05, we have the graph below.

crit. reg.

Since the Z-value -1.85 is in the critical region, we reject the null hypothesis and accept the alternative that < 130.

n

XZ

2545

130128.

128X

Z0

.05

-1.645

Acceptance region

.45

Page 33: Intermediate Statistical Analysis Professor K. Leppel

Calculating

Recall that is the probability of type I error = Pr( reject H0 | H0 is true), and

is the probability of type II error = Pr( accept H0 | H0 is false).

Page 34: Intermediate Statistical Analysis Professor K. Leppel

1000H versus1000 :H level 5% at the testingare weexample,for Suppose

10 :,

where the population standard deviation is 50 and the sample size is 25.Let’s first determine the critical region, and then calculate , based on a specified value of .

Page 35: Intermediate Statistical Analysis Professor K. Leppel

1000) |aXPr( .025 1000) |bXPr(

1000

n

a

n

-XPr .025 1000

n

-b

n

-XPr

||

1000

n

aZPr .025 1000

n

-bZPr

||

2550

1000aZPr .025

2550

1000-bZPr

a 1000 b

acceptance region

crit. reg.crit. reg.

X

0.025 0.025

Page 36: Intermediate Statistical Analysis Professor K. Leppel

2550

1000aZPr .025

2550

1000-bZPr

.025 .025

Z

2550

1000b 0

2550

1000a

The above equation implies this graph of the standard normal or Z distribution.

-1.96 1.96

From the Z table, we know that the cut-off points for the tails with

area 0.025 must be 1.96 and -1.96

Page 37: Intermediate Statistical Analysis Professor K. Leppel

1.96

2550

1000b and 1.96-

2550

1000a So

Solving the first equation for a and the second equation for b, we find a = 980.4 and b = 1019.6.

So our critical and acceptance regions look like this:

980.4 1000 1019.6

acceptance region

crit. reg.crit. reg.

X

Page 38: Intermediate Statistical Analysis Professor K. Leppel

But what if is actually 990, not 1000?

980.4 990 1019.6

acceptance region

crit. reg.crit. reg.

X

Our cut-off values for the critical and acceptance regions are still the same, but the distribution curve is centered at 990 instead of at 1000.

= Pr(accepting H0| H0 is false, in this case, =990)

= Pr(being in acceptance region| =990)

990)|1019.6XPr(980.4

Page 39: Intermediate Statistical Analysis Professor K. Leppel

)|..( 99061019X4980Pr

2550

99061019

n

X

2550

9904980Pr

..

962Z960Pr ..

We determine from the Z table that the specified area is 0.3315 + 0.4985 = 0.83

-0.96 0 2.96 Z

.3315 .4985

Page 40: Intermediate Statistical Analysis Professor K. Leppel

So, , the probability of accepting the null hypothesis that = 1000, when is actually 990, is 0.83.

With the given standard deviation and sample size, it is difficult to distinguish a distribution with a mean of 990 from a distribution with a mean of 1000.If we had a mean of 900, which is farther from 1000 than 990 is, it would be easier to distinguish it from 1000, and our value of would be smaller.

Page 41: Intermediate Statistical Analysis Professor K. Leppel

In general, we want the probability of type I and type II errors, and , to be small.

How can we make and smaller?Since is the probability of accepting the null hypothesis when it is false, we can make smaller by accepting the null hypothesis less often (shrinking the acceptance region).If we shrink the acceptance region, however, we expand the critical region.That means we reject the null hypothesis more often, increasing the probability of rejecting it when it is correct.So we’ve increased .Similarly, if we try to decrease , we increase .

Page 42: Intermediate Statistical Analysis Professor K. Leppel

Example: Parties

Suppose you have just completed your first semester at college.You are reflecting back on your social experiences of the semester, and thinking that you went to a lot of boring parties.You are thinking that you would like to reduce the number of boring parties that you attend.Think of the decision to attend a party as one involving the null hypothesis that the party is a good one and the alternative hypothesis is that the party is boring.You want to keep down the error probabilities = Pr(skip a party | it’s a good one) and = Pr(attend a party | it’s boring). To reduce , you might go to a lot of parties, but then you risk attending boring ones.To reduce , you might go to very few parties, but then you risk missing some good ones.

Page 43: Intermediate Statistical Analysis Professor K. Leppel

Is there some way that we can decrease both and ?

Yes, we can decrease both and by collecting more data or more information, by increasing the sample size.

Unfortunately, in the real world, collecting more data usually means increasing the cost of the study.

So there’s a tradeoff between accuracy and cost.

Page 44: Intermediate Statistical Analysis Professor K. Leppel

In the context of our party example,

to keep down the number of boring parties you attend as well as the number of good parties you miss, you need to get more information.

You need to talk to more people, find out who’s going, the music that is likely to be played, the food that will be served, etc.

Page 45: Intermediate Statistical Analysis Professor K. Leppel

How do we do hypothesis testing when the population standard deviation is unknown?

We do it similarly to what we’ve done so far, but we replace the population standard deviation by the sample standard deviation

1-n

)X(X s

n

1i

2i

and the Z distribution by the t distribution

n

-X1 s

tn

Page 46: Intermediate Statistical Analysis Professor K. Leppel

Example: Suppose you sample 16 matchboxes. The sample mean number of matches per box is 17 and the sample standard deviation is 2. Test at the 5% level .18: versus18: 10 HH

Use all three methods that we used previously.

Page 47: Intermediate Statistical Analysis Professor K. Leppel

a 18 b

Method 1

acceptance region

crit. reg.crit. reg.

If the null hypothesis is correct, the distribution of the sample mean is centered at 18. We need to find the values of a and b so that the combined area in the two tails is 0.05.

X

0.025 0.025

18) |b XPr( .025 18) |aXPr(

We don’t have to compute a and b separately. We can just compute one of them and figure out the other by symmetry. We’ll do b.

Page 48: Intermediate Statistical Analysis Professor K. Leppel

.025 18) |bXPr(

.025 18 |

n

-b

n

-XPr

ss

.025 18 |

n

-bPr 1

stn

.025

162

18-bPr 15

t

. .025

162

18-aPr Similarly, 15

t

Page 49: Intermediate Statistical Analysis Professor K. Leppel

.025 .025

15 t

162

18 0

162

18 ba

The equation we derived implies this graph of the t distribution.

-2.131 2.131

162

18-aPr.025

162

18-bPr 1515

tt

From the t table, we find that for 15 degrees of freedom, the cut-off points for the two tails with a combined area 0.05 are 2.131 and -2.131.

Page 50: Intermediate Statistical Analysis Professor K. Leppel

2.131

162

18 and 2.131-

162

18 So

ba

Solving the first equation for a and the second equation for b, we find a = 16.93 and b = 19.07, which gives us the acceptance and critical regions shown in the graph.

Since our value for the sample mean is 17, which is in the acceptance region, we accept the null hypothesis that = 18.

18

acceptance region

crit. reg.crit. reg.

X16.93 19.07

Page 51: Intermediate Statistical Analysis Professor K. Leppel

Method 2

Recall that the sample size is 16, the sample mean number of matches is 17, the sample standard deviation is 2, and we’re testing at the 5% level

.18: versus18: 10 HH

Since we’re doing a 2-tailed test, we need a 2-tailed p-value.

Page 52: Intermediate Statistical Analysis Professor K. Leppel

Using Excel, we find that this 2-tailed p-value is 0.064.

So based on a test level of = 0.05, we accept the null hypothesis, since the p-value > 0.05 .

-2.00 0 2.00 t15

.032 .032

18) ismean population thegiven that saw weas 18 fromfar as is X(Pr

18) ismean population thegiven that 19 Xor 17 X(Pr

18) ismean population thegiven that 17 X(2Pr

18 |

n

-17

n

-X2Pr

ss

162

18-17

n

-X2Pr

s

00.2 2Pr 15 t

Page 53: Intermediate Statistical Analysis Professor K. Leppel

Method 3Keep in mind that the sample mean was 17, the sample standard

deviation was 2, the sample size was 16, and the test level was 0.05.

00.2

Based on a test level or of 0.05, we have the graph below.

Since our t15-value, -2.00, is in the acceptance region, we accept the null hypothesis that the population mean is 18.

nsX

t

15

162

1817

17X

-2.131 0 2.131 t15

.0250 .0250

crit. reg.crit. reg. Acceptance region

Page 54: Intermediate Statistical Analysis Professor K. Leppel

New Example: Let X be the number of miles driven when the cumulative repair cost for a car reaches $500. Given a sample of 15 observations, a sample mean of 22,500, and a sample standard deviation of 4,000, test at the 5% level

.000,24: versus000,24: 10 HH

Use all three methods that we used previously.Notice that for this test, the critical region is just the left tail.Also, since we have the sample standard deviation, not the population standard deviation, we’ll be using a t-statistic.

Page 55: Intermediate Statistical Analysis Professor K. Leppel

a 24,000

Method 1

acceptance regioncrit. reg.

If the null hypothesis is correct, the distribution of the sample mean is centered at 24,000. We need to find the value of a so that the area in the left tail is 0.05.

X

0.05

.05 24,000) |aXPr(

Page 56: Intermediate Statistical Analysis Professor K. Leppel

.05 )000,24 |XPr( a

.05 24,000 |

n

-a

n

-XPr

ss

.05 24,000 |

n

-aPr 1

stn

.05

15000,424,000-a

Pr 14

t

Page 57: Intermediate Statistical Analysis Professor K. Leppel

.05

14 t 0

15000,4

000,24a

The equation we derived implies this graph of the t distribution.

-1.761

.05

15000,424,000-a

Pr 14

t

From the t table, we find that for 14 degrees of freedom, the cut-off point for a left tail with an area of 0.05 is -1.761.

Page 58: Intermediate Statistical Analysis Professor K. Leppel

1.761-

15000,4

000,24 So

a

Solving the equation for a, we find a = 22,181. This gives us the acceptance and critical regions shown in the graph.

Since our value for the sample mean is 22,500, which is in the acceptance region, we accept the null hypothesis that = 24,000.

24,000

acceptance regioncrit. reg.

X22,181

Page 59: Intermediate Statistical Analysis Professor K. Leppel

Method 2

Recall that the sample size is 15, the sample mean is 22,500, the sample standard deviation is 4,000, and we’re testing at the 5% level

.000,24: versus000,24: 10 HH

Since we’re doing a 1-tailed test, we need a 1-tailed p-value.

Page 60: Intermediate Statistical Analysis Professor K. Leppel

Using Excel, we find that this p-value is 0.084.

So based on a test level of = 0.05, we accept the null hypothesis, since the p-value > 0.05 .

-1.452 0 t14

.084

24,000) given that saw weas 24,000 belowfar as is X(Pr

24,000) given that 22,500 X(Pr

24,000 |

n

-22,500

n

-XPr

ss

15000,4

24,000-22,500

n

-XPr

s

452.1 Pr 14 t

Page 61: Intermediate Statistical Analysis Professor K. Leppel

Method 3Keep in mind that the sample mean was 22,500,

the sample standard deviation was 4,000, the sample size was 15, and the test level was 0.05.

452.1

Based on a test level or of 0.05, we have the graph below.

Since our t14-value, -1.452, is in the acceptance region, we accept the null hypothesis that the population mean is 24,000.

nsX

t

14

15000,4

000,24500,22

500,22X

-1.761 0 t14

.05

crit. reg. Acceptance region

Page 62: Intermediate Statistical Analysis Professor K. Leppel

Hypothesis testing on the population proportion

If X and n-X are each at least five, then X/n p is approximately

normally distributed, with mean equal to the population

(1- )proportion and standard deviation equal to

n

p - So is distributed as a standard normal or Z.

(1- )

n

If X is the number of successes on n independent trials,

then X/n p is the sample proportion of successes.

Page 63: Intermediate Statistical Analysis Professor K. Leppel

p - Z .

(1- )

n

So for hypothesis testing on a population proportion, we have the statistic

Page 64: Intermediate Statistical Analysis Professor K. Leppel

Example

0 1

A sample of 100 people in a state shows 33% are Democrats.

Test at the 5% level H : 0.30 versus H : 0.30 .

Notice that our test is right-tailed, so the critical region is as shown below.From the Z table, we know that the cut-off point is 1.645.

p -

(1- )

n

Z

100(.30)(.70)

.30- 0.33

0.6651.645 0 Z

.05acceptance

region

crit. reg..45

Since our Z-statistic is in the acceptance region, we accept H0: = 0.30

Page 65: Intermediate Statistical Analysis Professor K. Leppel

In the section we have just completed, we did 3 different types of hypothesis tests for the case of a single sample.

1. population mean - known population variance 2. population mean - unknown population variance 3. population proportion

In the next section we will look at hypothesis testing when we have more than one sample.