Math 3680 Lecture #15 Hypothesis Testing: The t Test.

56
Math 3680 Lecture #15 Hypothesis Testing: The t Test

Transcript of Math 3680 Lecture #15 Hypothesis Testing: The t Test.

Page 1: Math 3680 Lecture #15 Hypothesis Testing: The t Test.

Math 3680

Lecture #15

Hypothesis Testing:The t Test

Page 2: Math 3680 Lecture #15 Hypothesis Testing: The t Test.

• In all of the previous examples, we assumed that we knew the population standard deviation

• In practice, this is an extremely rare situation!

• Instead, the sample standard deviation S is used in lieu of

• This approximation is called the bootstrap estimate.

Page 3: Math 3680 Lecture #15 Hypothesis Testing: The t Test.

Example. The manufacturer of a new fiberglass tire claims that its average life will be at least 40,000 miles. To verify this claim, a sample of 12 tires is tested, and the lifetimes were found to be

36,100 40,200 33,800 38,50042,000 35,800 37,000 41,00036,800 37,200 33,000 36,000

Test the manufacture’s claim using = 0.05.

Page 4: Math 3680 Lecture #15 Hypothesis Testing: The t Test.

36100 Mean 37283.3340200 SD 2731.9133800385004200035800370004100036800372003300036000

Solution.

H0: The average life is at least 40,000 miles.

Ha: The average life is less than 40,000 miles.

We choose = 0.05.

Notice that we have to compute the sample SD this time; it’s not given.

Page 5: Math 3680 Lecture #15 Hypothesis Testing: The t Test.

36100 Mean 37283.3340200 SD 2731.9133800385004200035800370004100036800372003300036000

We now can compute the test statistic

But there’s a catch: since we used S instead of , the test statistic t does NOT follow the normal curve.

.4448.3

12/91.2731

4000033.37283

/

nS

Xt

Page 6: Math 3680 Lecture #15 Hypothesis Testing: The t Test.

Since we used S instead of , the test statistic t does NOT follow the normal curve.

Instead, there’s a theorem which says that the test statistic t follows the Student t distribution with n - 1 degrees of freedom. (There’s a slight catch with this theorem that we’ll discuss later.)

For the current problem, instead of using the normal curve to compute the observed significance level, we will use the Student t distribution with 11 degrees of freedom.

Page 7: Math 3680 Lecture #15 Hypothesis Testing: The t Test.

For the sake of completeness, here’s the pdf of the Student’s t-distribution with r degrees of freedom:

If you find this intimidating, don’t worry: we will never use it.

2

12

1

2

21

)(

r

r

t

rr

r

tf

Page 8: Math 3680 Lecture #15 Hypothesis Testing: The t Test.

-4 -2 2 4

0.05

0.1

0.15

0.2

0.25

0.3

0.35

Student T Distribution with 1 degrees of freedom

Red: t distribution Blue: standard normal curve

Page 9: Math 3680 Lecture #15 Hypothesis Testing: The t Test.

-4 -2 2 4

0.05

0.1

0.15

0.2

0.25

0.3

0.35

Student T Distribution with 2 degrees of freedom

Red: t distribution Blue: standard normal curve

Page 10: Math 3680 Lecture #15 Hypothesis Testing: The t Test.

-4 -2 2 4

0.05

0.1

0.15

0.2

0.25

0.3

0.35

Student T Distribution with 3 degrees of freedom

Red: t distribution Blue: standard normal curve

Page 11: Math 3680 Lecture #15 Hypothesis Testing: The t Test.

-4 -2 2 4

0.05

0.1

0.15

0.2

0.25

0.3

0.35

Student T Distribution with 4 degrees of freedom

Red: t distribution Blue: standard normal curve

Page 12: Math 3680 Lecture #15 Hypothesis Testing: The t Test.

-4 -2 2 4

0.05

0.1

0.15

0.2

0.25

0.3

0.35

Student T Distribution with 5 degrees of freedom

Red: t distribution Blue: standard normal curve

Page 13: Math 3680 Lecture #15 Hypothesis Testing: The t Test.

-4 -2 2 4

0.05

0.1

0.15

0.2

0.25

0.3

0.35

Student T Distribution with 10 degrees of freedom

Red: t distribution Blue: standard normal curve

Page 14: Math 3680 Lecture #15 Hypothesis Testing: The t Test.

-4 -2 2 4

0.05

0.1

0.15

0.2

0.25

0.3

0.35

Student T Distribution with 20 degrees of freedom

Red: t distribution Blue: standard normal curve

Page 15: Math 3680 Lecture #15 Hypothesis Testing: The t Test.

-4 -2 2 4

0.05

0.1

0.15

0.2

0.25

0.3

0.35

Student T Distribution with 30 degrees of freedom

Red: t distribution Blue: standard normal curve

Page 16: Math 3680 Lecture #15 Hypothesis Testing: The t Test.

-4 -2 2 4

0.05

0.1

0.15

0.2

0.25

0.3

0.35

Student T Distribution with 40 degrees of freedom

Red: t distribution Blue: standard normal curve

Page 17: Math 3680 Lecture #15 Hypothesis Testing: The t Test.

-4 -2 2 4

0.05

0.1

0.15

0.2

0.25

0.3

0.35

Student T Distribution with 50 degrees of freedom

Red: t distribution Blue: standard normal curve

Page 18: Math 3680 Lecture #15 Hypothesis Testing: The t Test.

-4 -2 2 4

0.05

0.1

0.15

0.2

0.25

0.3

0.35

Student T Distribution with 100 degrees of freedom

Red: t distribution Blue: standard normal curve

Page 19: Math 3680 Lecture #15 Hypothesis Testing: The t Test.

For the t distribution with 11 df, we can compute the critical value for = 0.05 using Table 4 (p. 510).

In Excel, be careful: the command is TINV(0.1,11).(The default is for two tails, not one tail.)

-3.4448 -1.79588

0.1

0.2

0.3

-3.4448 -1.79588

0.1

0.2

0.35%

Page 20: Math 3680 Lecture #15 Hypothesis Testing: The t Test.

-3.4448 -1.79588

0.1

0.2

0.3

-3.4448 -1.79588

0.1

0.2

0.3

In Excel, the command is TDIST(3.448,11,1).(The third entry specifies the number of tails.)

0.002724

Observed Significance Level

Page 21: Math 3680 Lecture #15 Hypothesis Testing: The t Test.

Conclusion: We reject the null hypothesis. There is good reason to believe that the average lifespan of thetires is less than 40,000 miles.

Note: It is possible to compute power with theStudent’s t-distribution, but the computations aremuch, much more complicated than the normal case(Larsen & Marx, 3rd ed., p. 447). Many statistical software packages are able to compute power for the t-test automatically.

Page 22: Math 3680 Lecture #15 Hypothesis Testing: The t Test.

36100 4000040200 4000033800 4000038500 4000042000 4000035800 4000037000 4000041000 4000036800 4000037200 4000033000 4000036000 40000

0.00273917

Excel: Use the command

=TTEST(A1:A12, B1:B12,1, 1)

• This is silly, I know, but you have to list the claimed average once for each entry in the list.

• The blue 1 stands for a one-tailed test; the second 1 is required.

Page 23: Math 3680 Lecture #15 Hypothesis Testing: The t Test.

Remember: If the sample is small (n < 30) and thepopulation variance is unknown, then we use thet-test and not the z-test.

On the other hand, if either is known or the sampleis sufficiently large (n > 30), then we may safely usethe z-test instead.

Also, we must be careful about stating the null and alternative hypotheses so that we correctly choose whether to use a left-tail, a right-tail, or both tails.

Page 24: Math 3680 Lecture #15 Hypothesis Testing: The t Test.

Example. Before a substance can be deemed safe for landfilling, its chemical properties must be assessed.In a sample of six replicates of sludge from a NewHampshire wastewater treatment plant, the mean pHwas 6.68 with a standard deviation of 0.20. Can weconclude than the mean pH is less than 7.0?

J. Benoit, T. Eighmy and B. Crannell, Journal of Geotechnical andGeoenvironmental Engineering 1999, pp. 877--888.

Page 25: Math 3680 Lecture #15 Hypothesis Testing: The t Test.
Page 26: Math 3680 Lecture #15 Hypothesis Testing: The t Test.

Example. Certain rectangles appear more pleasing to the eye than others. The ancient Greeks called a rectangle with

the golden rectangle, and this ratio was called the golden ratio. The golden ratio has been claimed to be a deliberate design of various artand architecture.

)(2

15lengthwidth

Page 27: Math 3680 Lecture #15 Hypothesis Testing: The t Test.

The data below shows the width-to-length ratios of beaded rectangles used by the Shoshone Native Americans to decorate their leather goods. Does it appear that the golden rectangle is also an aesthetic standard for the Shoshones?

0.693 0.662 0.690 0.606 0.5700.749 0.672 0.628 0.609 0.8440.654 0.615 0.668 0.601 0.5760.670 0.606 0.611 0.553 0.933

C. Dubois, ed., Lowie’s Selected Papers in Anthropology(UC Press, Berkeley, 1960), pp. 137--142

Page 28: Math 3680 Lecture #15 Hypothesis Testing: The t Test.
Page 29: Math 3680 Lecture #15 Hypothesis Testing: The t Test.

Robustness of the t Test

Page 30: Math 3680 Lecture #15 Hypothesis Testing: The t Test.

The t statistic is defined by

If X1, X2, …, Xn follow a normal distribution, then there’s a theorem that says that this t statistic

follows the Student t-distribution with n - 1 degrees of freedom.

But, in real life, this assumption is almost certainly not true. Models are idealized; real data are, well, real. Now what?

(FYI: The exact answer is 0.00330.)

nS

Xt

/

Page 31: Math 3680 Lecture #15 Hypothesis Testing: The t Test.

The good news is that the underlying pdf doesn’t have to be very close to normal in order for the test statistic to be close to the Student t-distribution.

The following graphs are empirical histograms of the t statistic computed from 10,000 data sets drawn from a “triangular” distribution with pdf

which is not too far off from bell shaped. Even for very small samples, the t distribution is accurate.

0.5 1 1.5 2

0.1

0.2

0.3

0.4

0.5

,21,2/)2(

,10,2/)(

xx

xxxf

Page 32: Math 3680 Lecture #15 Hypothesis Testing: The t Test.

-5 -4 -3 -2 -1 0 1 2 3 4 5

0.1

0.2

0.3

0.4

t Statistic from a Triangular distributionwith a sample of size 2

Page 33: Math 3680 Lecture #15 Hypothesis Testing: The t Test.

-5 -4 -3 -2 -1 0 1 2 3 4 5

0.1

0.2

0.3

0.4

t Statistic from a Triangular distributionwith a sample of size 3

Page 34: Math 3680 Lecture #15 Hypothesis Testing: The t Test.

-5 -4 -3 -2 -1 0 1 2 3 4 5

0.1

0.2

0.3

0.4

t Statistic from a Triangular distributionwith a sample of size 4

Page 35: Math 3680 Lecture #15 Hypothesis Testing: The t Test.

The following graphs are empirical histograms of the t statistic computed from 10,000 data sets drawn from a Uniform(0,1) distribution, which is symmetric but decisively not bell-shaped. Notice that convergence does not occur as quickly.

0.2 0.4 0.6 0.8 1

0.2

0.4

0.6

0.8

1

Page 36: Math 3680 Lecture #15 Hypothesis Testing: The t Test.

-5 -4 -3 -2 -1 0 1 2 3 4 5

0.1

0.2

0.3

0.4

t Statistic from a Uniform0,1with a sample of size 2

Page 37: Math 3680 Lecture #15 Hypothesis Testing: The t Test.

-5 -4 -3 -2 -1 0 1 2 3 4 5

0.1

0.2

0.3

0.4

t Statistic from a Uniform0,1with a sample of size 3

Page 38: Math 3680 Lecture #15 Hypothesis Testing: The t Test.

-5 -4 -3 -2 -1 0 1 2 3 4 5

0.1

0.2

0.3

0.4

t Statistic from a Uniform0,1with a sample of size 4

Page 39: Math 3680 Lecture #15 Hypothesis Testing: The t Test.

-5 -4 -3 -2 -1 0 1 2 3 4 5

0.1

0.2

0.3

0.4

t Statistic from a Uniform0,1with a sample of size 5

Page 40: Math 3680 Lecture #15 Hypothesis Testing: The t Test.

-5 -4 -3 -2 -1 0 1 2 3 4 5

0.1

0.2

0.3

0.4

t Statistic from a Uniform0,1with a sample of size 6

Page 41: Math 3680 Lecture #15 Hypothesis Testing: The t Test.

-5 -4 -3 -2 -1 0 1 2 3 4 5

0.1

0.2

0.3

0.4

t Statistic from a Uniform0,1with a sample of size 7

Page 42: Math 3680 Lecture #15 Hypothesis Testing: The t Test.

-5 -4 -3 -2 -1 0 1 2 3 4 5

0.1

0.2

0.3

0.4

t Statistic from a Uniform0,1with a sample of size 8

Page 43: Math 3680 Lecture #15 Hypothesis Testing: The t Test.

-5 -4 -3 -2 -1 0 1 2 3 4 5

0.1

0.2

0.3

0.4

t Statistic from a Uniform0,1with a sample of size 9

Page 44: Math 3680 Lecture #15 Hypothesis Testing: The t Test.

-5 -4 -3 -2 -1 0 1 2 3 4 5

0.1

0.2

0.3

0.4

t Statistic from a Uniform0,1with a sample of size 10

Page 45: Math 3680 Lecture #15 Hypothesis Testing: The t Test.

The following graphs are empirical histograms of the t statistic computed from 10,000 data sets drawn from an Exponential(1) distribution, which is neither symmetric nor bell-shaped.

This time, the sample has to be of size 40 or so for the t distribution to be accurate… that’s mostly due to the Central Limit Theorem.

(FYI: The exact answer is 0.00330.)1 2 3 4

0.2

0.4

0.6

0.8

1

Page 46: Math 3680 Lecture #15 Hypothesis Testing: The t Test.

-10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5

0.1

0.2

0.3

0.4

t Statistic from an Exponential1with a sample of size 5

Page 47: Math 3680 Lecture #15 Hypothesis Testing: The t Test.

-10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5

0.1

0.2

0.3

0.4

t Statistic from an Exponential1with a sample of size 10

Page 48: Math 3680 Lecture #15 Hypothesis Testing: The t Test.

-10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5

0.1

0.2

0.3

0.4

t Statistic from an Exponential1with a sample of size 15

Page 49: Math 3680 Lecture #15 Hypothesis Testing: The t Test.

-10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5

0.1

0.2

0.3

0.4

t Statistic from an Exponential1with a sample of size 20

Page 50: Math 3680 Lecture #15 Hypothesis Testing: The t Test.

-10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5

0.1

0.2

0.3

0.4

t Statistic from an Exponential 1with a sample of size 30

Page 51: Math 3680 Lecture #15 Hypothesis Testing: The t Test.

-10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5

0.1

0.2

0.3

0.4

t Statistic from an Exponential 1with a sample of size 40

Page 52: Math 3680 Lecture #15 Hypothesis Testing: The t Test.

-10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5

0.1

0.2

0.3

0.4

t Statistic from an Exponential 1with a sample of size 50

Page 53: Math 3680 Lecture #15 Hypothesis Testing: The t Test.

-10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5

0.1

0.2

0.3

0.4

t Statistic from an Exponential 1with a sample of size 100

Page 54: Math 3680 Lecture #15 Hypothesis Testing: The t Test.

Observations

• The distribution of the t statistic is relatively unaffected by the pdf of the Xi, as long as

– The pdf is not too skewed, and

– The sample size is not too small.

• As the sample size n increases, the distribution of the t statistic gets closer to the Student t-distribution with n -1 degrees of freedom.

Page 55: Math 3680 Lecture #15 Hypothesis Testing: The t Test.

Observations

We succinctly describe this as saying that the t test is robust, meaning that it is not heavily dependent on the underlying assumption of normality. The practical importance of this robustness is that the t test can be used in real-life situations.

Page 56: Math 3680 Lecture #15 Hypothesis Testing: The t Test.

Practical Implications

• If n < 15, the data should be nearly normal. Make a histogram. If there are outliers or strong skewness, do not use the t-test.

• If 15 n 40, make a histogram to check that the data is unimodal, free of outliers, and reasonably symmetric. Again, make a histogram.

• If n > 40, the t-test is safe even if the data is skewed.