testing means, part ii the paired t-test. outline of lecture options in statistics –sometimes...
TRANSCRIPT
![Page 1: Testing means, part II The paired t-test. Outline of lecture Options in statistics –sometimes there is more than one option One-sample t-test: review](https://reader031.vdocuments.site/reader031/viewer/2022012922/56649eb25503460f94bb98ff/html5/thumbnails/1.jpg)
Testing means, part II
The paired t-test
![Page 2: Testing means, part II The paired t-test. Outline of lecture Options in statistics –sometimes there is more than one option One-sample t-test: review](https://reader031.vdocuments.site/reader031/viewer/2022012922/56649eb25503460f94bb98ff/html5/thumbnails/2.jpg)
Outline of lecture
• Options in statistics– sometimes there is more than one option
• One-sample t-test: review– testing the sample mean
• The paired t-test– testing the mean difference
![Page 3: Testing means, part II The paired t-test. Outline of lecture Options in statistics –sometimes there is more than one option One-sample t-test: review](https://reader031.vdocuments.site/reader031/viewer/2022012922/56649eb25503460f94bb98ff/html5/thumbnails/3.jpg)
A digression:Options in statistics
![Page 4: Testing means, part II The paired t-test. Outline of lecture Options in statistics –sometimes there is more than one option One-sample t-test: review](https://reader031.vdocuments.site/reader031/viewer/2022012922/56649eb25503460f94bb98ff/html5/thumbnails/4.jpg)
Example
• A student wants to check the fairness of the loonie
• She flips the coin 1,000,000 times, and gets heads 501,823 times.
• Is this a fair coin?
![Page 5: Testing means, part II The paired t-test. Outline of lecture Options in statistics –sometimes there is more than one option One-sample t-test: review](https://reader031.vdocuments.site/reader031/viewer/2022012922/56649eb25503460f94bb98ff/html5/thumbnails/5.jpg)
Ho: The coin is fair (p
heads = 0.5).
Ha: The coin is not fair (p
heads ≠ 0.5).
n = 1,000,000 trialsx = 501,823 successes
Under the null hypothesis, the number of successesshould follow a binomial distribution with n=1,000,000and p=0.5
![Page 6: Testing means, part II The paired t-test. Outline of lecture Options in statistics –sometimes there is more than one option One-sample t-test: review](https://reader031.vdocuments.site/reader031/viewer/2022012922/56649eb25503460f94bb98ff/html5/thumbnails/6.jpg)
4 9 8 0 0 0 4 9 9 0 0 0 5 0 0 0 0 0 5 0 1 0 0 0 5 0 2 0 0 0
0
e+
00
2
e-0
44
e
-04
6
e-0
48
e
-04
x
Pro
ba
bili
ty
Test statistic
![Page 7: Testing means, part II The paired t-test. Outline of lecture Options in statistics –sometimes there is more than one option One-sample t-test: review](https://reader031.vdocuments.site/reader031/viewer/2022012922/56649eb25503460f94bb98ff/html5/thumbnails/7.jpg)
Binomial test
• P = 2*Pr[X≥501,823]P = 2*(Pr[X = 501,823] + Pr[X = 501,824] +
Pr[X = 501,825] + Pr[X = 501,826] + ...
+ Pr[X = 999,999] + Pr[X = 1,000,000]
![Page 8: Testing means, part II The paired t-test. Outline of lecture Options in statistics –sometimes there is more than one option One-sample t-test: review](https://reader031.vdocuments.site/reader031/viewer/2022012922/56649eb25503460f94bb98ff/html5/thumbnails/8.jpg)
Central limit theorem
The sum or mean of a large number of measurementsrandomly sampled from any population is approximately normally distributed
![Page 9: Testing means, part II The paired t-test. Outline of lecture Options in statistics –sometimes there is more than one option One-sample t-test: review](https://reader031.vdocuments.site/reader031/viewer/2022012922/56649eb25503460f94bb98ff/html5/thumbnails/9.jpg)
Binomial Distribution
![Page 10: Testing means, part II The paired t-test. Outline of lecture Options in statistics –sometimes there is more than one option One-sample t-test: review](https://reader031.vdocuments.site/reader031/viewer/2022012922/56649eb25503460f94bb98ff/html5/thumbnails/10.jpg)
Normal approximation to the binomial distribution
The binomial distribution, when number of trials n is large
and probability of success p is not close to 0 or 1, is
approximated by a normal distribution having mean np and
standard deviation
np 1 - p( ) .
![Page 11: Testing means, part II The paired t-test. Outline of lecture Options in statistics –sometimes there is more than one option One-sample t-test: review](https://reader031.vdocuments.site/reader031/viewer/2022012922/56649eb25503460f94bb98ff/html5/thumbnails/11.jpg)
Example
• A student wants to check the fairness of the loonie
• She flips the coin 1,000,000 times, and gets heads 501,823 times.
• Is this a fair coin?
![Page 12: Testing means, part II The paired t-test. Outline of lecture Options in statistics –sometimes there is more than one option One-sample t-test: review](https://reader031.vdocuments.site/reader031/viewer/2022012922/56649eb25503460f94bb98ff/html5/thumbnails/12.jpg)
Normal approximation
• Under the null hypothesis, data are approximately normally distributed
• Mean: np = 1,000,000 * 0.5 = 500,000• Standard deviation:
• s = 500s= n p 1− p= 1,000,000∗0.5∗1−0.5
![Page 13: Testing means, part II The paired t-test. Outline of lecture Options in statistics –sometimes there is more than one option One-sample t-test: review](https://reader031.vdocuments.site/reader031/viewer/2022012922/56649eb25503460f94bb98ff/html5/thumbnails/13.jpg)
Normal distributions
• Any normal distribution can be converted to a standard normal distribution, by
Z-score
Z=Y −ms
![Page 14: Testing means, part II The paired t-test. Outline of lecture Options in statistics –sometimes there is more than one option One-sample t-test: review](https://reader031.vdocuments.site/reader031/viewer/2022012922/56649eb25503460f94bb98ff/html5/thumbnails/14.jpg)
Z=501,823−500,000500
=3.646
From standard normal table:P = 0.0001
Z=Y −ms
![Page 15: Testing means, part II The paired t-test. Outline of lecture Options in statistics –sometimes there is more than one option One-sample t-test: review](https://reader031.vdocuments.site/reader031/viewer/2022012922/56649eb25503460f94bb98ff/html5/thumbnails/15.jpg)
Conclusion
• P = 0.0001, so we reject the null hypothesis• This is much easier than the binomial test• Can use as long as p is not close to 0 or 1
and n is large
![Page 16: Testing means, part II The paired t-test. Outline of lecture Options in statistics –sometimes there is more than one option One-sample t-test: review](https://reader031.vdocuments.site/reader031/viewer/2022012922/56649eb25503460f94bb98ff/html5/thumbnails/16.jpg)
Example
• A student wants to check the fairness of the loonie
• She flips the coin 1,000,000 times, and gets heads 500,823 times.
• Is this a fair coin?
![Page 17: Testing means, part II The paired t-test. Outline of lecture Options in statistics –sometimes there is more than one option One-sample t-test: review](https://reader031.vdocuments.site/reader031/viewer/2022012922/56649eb25503460f94bb98ff/html5/thumbnails/17.jpg)
A Third Option!
• Chi-squared goodness of fit test• Null expectation: equal number of successes
and failures• Compare to chi-squared distribution with 1
d.f.
![Page 18: Testing means, part II The paired t-test. Outline of lecture Options in statistics –sometimes there is more than one option One-sample t-test: review](https://reader031.vdocuments.site/reader031/viewer/2022012922/56649eb25503460f94bb98ff/html5/thumbnails/18.jpg)
Result Observed ExpectedHeads 501823 500000Tails 498167 500000
Test statistic: 13.3Critical value: 3.84
![Page 19: Testing means, part II The paired t-test. Outline of lecture Options in statistics –sometimes there is more than one option One-sample t-test: review](https://reader031.vdocuments.site/reader031/viewer/2022012922/56649eb25503460f94bb98ff/html5/thumbnails/19.jpg)
Coin toss example
Binomial test Normal approximation
Chi-squaredgoodness of fit test
Most accurateHard to calculateAssumes:Random sample
ApproximateEasier to calculateAssumes:Random sampleLarge np far from 0, 1
ApproximateEasier to calculateAssumes:Random sampleNo expected <1Not more than 20% less than 5
![Page 20: Testing means, part II The paired t-test. Outline of lecture Options in statistics –sometimes there is more than one option One-sample t-test: review](https://reader031.vdocuments.site/reader031/viewer/2022012922/56649eb25503460f94bb98ff/html5/thumbnails/20.jpg)
Coin toss example
Binomial test Normal approximation
Chi-squaredgoodness of fit test
in this case, n very large (1,000,000)all P < 0.05, reject null hypothesis
![Page 21: Testing means, part II The paired t-test. Outline of lecture Options in statistics –sometimes there is more than one option One-sample t-test: review](https://reader031.vdocuments.site/reader031/viewer/2022012922/56649eb25503460f94bb98ff/html5/thumbnails/21.jpg)
Normal distributions
• Any normal distribution can be converted to a standard normal distribution, by
Z-score
Z=Y −ms
![Page 22: Testing means, part II The paired t-test. Outline of lecture Options in statistics –sometimes there is more than one option One-sample t-test: review](https://reader031.vdocuments.site/reader031/viewer/2022012922/56649eb25503460f94bb98ff/html5/thumbnails/22.jpg)
t distribution
• We carry out a similar transformation on the sample mean
t=Y−ms / n
mean under Ho
estimatedstandard error
![Page 23: Testing means, part II The paired t-test. Outline of lecture Options in statistics –sometimes there is more than one option One-sample t-test: review](https://reader031.vdocuments.site/reader031/viewer/2022012922/56649eb25503460f94bb98ff/html5/thumbnails/23.jpg)
How do we use this?
• t has a Student's t distribution• Find confidence limits for the mean• Carry out one-sample t-test
![Page 24: Testing means, part II The paired t-test. Outline of lecture Options in statistics –sometimes there is more than one option One-sample t-test: review](https://reader031.vdocuments.site/reader031/viewer/2022012922/56649eb25503460f94bb98ff/html5/thumbnails/24.jpg)
t has a Student’s t distribution*
![Page 25: Testing means, part II The paired t-test. Outline of lecture Options in statistics –sometimes there is more than one option One-sample t-test: review](https://reader031.vdocuments.site/reader031/viewer/2022012922/56649eb25503460f94bb98ff/html5/thumbnails/25.jpg)
t has a Student’s t distribution*
* Under the null hypothesis
Uncertaintymakes the nulldistributionFATTER
![Page 26: Testing means, part II The paired t-test. Outline of lecture Options in statistics –sometimes there is more than one option One-sample t-test: review](https://reader031.vdocuments.site/reader031/viewer/2022012922/56649eb25503460f94bb98ff/html5/thumbnails/26.jpg)
Confidence interval for a mean
(2) = 2-tailed significance level
df = degrees of freedom, n-1
SEY = standard error of the mean
Y ±SE Y t2 , df
![Page 27: Testing means, part II The paired t-test. Outline of lecture Options in statistics –sometimes there is more than one option One-sample t-test: review](https://reader031.vdocuments.site/reader031/viewer/2022012922/56649eb25503460f94bb98ff/html5/thumbnails/27.jpg)
Confidence interval for a mean
Y±SE Y t2 ,df
95 % Confidence interval:Use α(2) = 0.05
![Page 28: Testing means, part II The paired t-test. Outline of lecture Options in statistics –sometimes there is more than one option One-sample t-test: review](https://reader031.vdocuments.site/reader031/viewer/2022012922/56649eb25503460f94bb98ff/html5/thumbnails/28.jpg)
Confidence interval for a mean
Y±SE Y t2 ,df
c % Confidence interval:Use α(2) = 1-c/100
![Page 29: Testing means, part II The paired t-test. Outline of lecture Options in statistics –sometimes there is more than one option One-sample t-test: review](https://reader031.vdocuments.site/reader031/viewer/2022012922/56649eb25503460f94bb98ff/html5/thumbnails/29.jpg)
SampleNull hypothesis
The population mean is equal to
o
One-sample t-test
Test statistic
t=Y− o
s / n
Null distributiont with n-1 dfcompare
How unusual is this test statistic?
P < 0.05 P > 0.05
Reject Ho Fail to reject Ho
![Page 30: Testing means, part II The paired t-test. Outline of lecture Options in statistics –sometimes there is more than one option One-sample t-test: review](https://reader031.vdocuments.site/reader031/viewer/2022012922/56649eb25503460f94bb98ff/html5/thumbnails/30.jpg)
The following are equivalent:
• Test statistic > critical value• P < alpha• Reject the null hypothesis• Statistically significant
![Page 31: Testing means, part II The paired t-test. Outline of lecture Options in statistics –sometimes there is more than one option One-sample t-test: review](https://reader031.vdocuments.site/reader031/viewer/2022012922/56649eb25503460f94bb98ff/html5/thumbnails/31.jpg)
Quick reference summary: One-sample t-test
• What is it for? Compares the mean of a numerical variable to a hypothesized value, μ
o
• What does it assume? Individuals are randomly sampled from a population that is normally distributed
• Test statistic: t
• Distribution under Ho: t-distribution with n-1 degrees of
freedom
• Formulae:Y = sample mean, s = sample standard deviation
t=Y− o
s / n
![Page 32: Testing means, part II The paired t-test. Outline of lecture Options in statistics –sometimes there is more than one option One-sample t-test: review](https://reader031.vdocuments.site/reader031/viewer/2022012922/56649eb25503460f94bb98ff/html5/thumbnails/32.jpg)
32
Comparing means
• Goal: to compare the mean of a numerical variable for different groups.
• Tests one categorical vs. one numerical variable
Example:gender (M, F) vs. height
![Page 33: Testing means, part II The paired t-test. Outline of lecture Options in statistics –sometimes there is more than one option One-sample t-test: review](https://reader031.vdocuments.site/reader031/viewer/2022012922/56649eb25503460f94bb98ff/html5/thumbnails/33.jpg)
33
Paired vs. 2 sample comparisons
![Page 34: Testing means, part II The paired t-test. Outline of lecture Options in statistics –sometimes there is more than one option One-sample t-test: review](https://reader031.vdocuments.site/reader031/viewer/2022012922/56649eb25503460f94bb98ff/html5/thumbnails/34.jpg)
34
Paired designs
• Data from the two groups are paired• There is a one-to-one correspondence
between the individuals in the two groups
![Page 35: Testing means, part II The paired t-test. Outline of lecture Options in statistics –sometimes there is more than one option One-sample t-test: review](https://reader031.vdocuments.site/reader031/viewer/2022012922/56649eb25503460f94bb98ff/html5/thumbnails/35.jpg)
35
More on pairs
• Each member of the pair shares much in common with the other, except for the tested categorical variable
• Example: identical twins raised in different environments
• Can use the same individual at different points in time
• Example: before, after medical treatment
![Page 36: Testing means, part II The paired t-test. Outline of lecture Options in statistics –sometimes there is more than one option One-sample t-test: review](https://reader031.vdocuments.site/reader031/viewer/2022012922/56649eb25503460f94bb98ff/html5/thumbnails/36.jpg)
36
Paired design: Examples
• Same river, upstream and downstream of a power plant
• Tattoos on both arms: how to get them off? Compare lasers to dermabrasion
![Page 37: Testing means, part II The paired t-test. Outline of lecture Options in statistics –sometimes there is more than one option One-sample t-test: review](https://reader031.vdocuments.site/reader031/viewer/2022012922/56649eb25503460f94bb98ff/html5/thumbnails/37.jpg)
37
Paired comparisons - setup
• We have many pairs
• In each pair, there is one member that has one treatment and another who has another treatment
• “Treatment” can mean “group”
![Page 38: Testing means, part II The paired t-test. Outline of lecture Options in statistics –sometimes there is more than one option One-sample t-test: review](https://reader031.vdocuments.site/reader031/viewer/2022012922/56649eb25503460f94bb98ff/html5/thumbnails/38.jpg)
38
Paired comparisons
• To compare two groups, we use the mean of the difference between the two members of each pair
![Page 39: Testing means, part II The paired t-test. Outline of lecture Options in statistics –sometimes there is more than one option One-sample t-test: review](https://reader031.vdocuments.site/reader031/viewer/2022012922/56649eb25503460f94bb98ff/html5/thumbnails/39.jpg)
39
Example: National No Smoking Day
• Data compares injuries at work on National No Smoking Day (in Britain) to the same day the week before
• Each data point is a year
![Page 40: Testing means, part II The paired t-test. Outline of lecture Options in statistics –sometimes there is more than one option One-sample t-test: review](https://reader031.vdocuments.site/reader031/viewer/2022012922/56649eb25503460f94bb98ff/html5/thumbnails/40.jpg)
40
data
Year Injur ies before NoSmoking Day
Injur ies on NoSmoking Day
1987 516 540
1988 610 620
1989 581 599
1990 586 639
1991 554 607
1992 632 603
1993 479 519
1994 583 560
1995 445 515
1996 522 556
![Page 41: Testing means, part II The paired t-test. Outline of lecture Options in statistics –sometimes there is more than one option One-sample t-test: review](https://reader031.vdocuments.site/reader031/viewer/2022012922/56649eb25503460f94bb98ff/html5/thumbnails/41.jpg)
41
Calculate differencesInjur ies before No
Smoking DayInjur ies on NoSmoking Day
Differ ence
(d)
516 540 24
610 620 10
581 599 18
586 639 53
554 607 53
632 603 -29
479 519 40
583 560 -23
445 515 70
522 556 34
![Page 42: Testing means, part II The paired t-test. Outline of lecture Options in statistics –sometimes there is more than one option One-sample t-test: review](https://reader031.vdocuments.site/reader031/viewer/2022012922/56649eb25503460f94bb98ff/html5/thumbnails/42.jpg)
42
Paired t test
• Compares the mean of the differences to a value given in the null hypothesis
• For each pair, calculate the difference.
• The paired t-test is a one-sample t-test on the differences.
![Page 43: Testing means, part II The paired t-test. Outline of lecture Options in statistics –sometimes there is more than one option One-sample t-test: review](https://reader031.vdocuments.site/reader031/viewer/2022012922/56649eb25503460f94bb98ff/html5/thumbnails/43.jpg)
43
Hypotheses
Ho: Work related injuries do not change duringNo Smoking Days (μ=0)
Ha: Work related injuries change during No Smoking Days (μ≠0)
![Page 44: Testing means, part II The paired t-test. Outline of lecture Options in statistics –sometimes there is more than one option One-sample t-test: review](https://reader031.vdocuments.site/reader031/viewer/2022012922/56649eb25503460f94bb98ff/html5/thumbnails/44.jpg)
44
Calculate differencesInjur ies before No
Smoking DayInjur ies on NoSmoking Day
Differ ence
(d)
516 540 24
610 620 10
581 599 18
586 639 53
554 607 53
632 603 -29
479 519 40
583 560 -23
445 515 70
522 556 34
![Page 45: Testing means, part II The paired t-test. Outline of lecture Options in statistics –sometimes there is more than one option One-sample t-test: review](https://reader031.vdocuments.site/reader031/viewer/2022012922/56649eb25503460f94bb98ff/html5/thumbnails/45.jpg)
45
Calculate t using d’s
d = 25
sd2 = 1043 .78
n =10
t =25 - 0
1043 .78 /10= 2.45
![Page 46: Testing means, part II The paired t-test. Outline of lecture Options in statistics –sometimes there is more than one option One-sample t-test: review](https://reader031.vdocuments.site/reader031/viewer/2022012922/56649eb25503460f94bb98ff/html5/thumbnails/46.jpg)
46
Caution!
• The number of data points in a paired t test is the number of pairs. -- Not the number of individuals
• Degrees of freedom = Number of pairs - 1
Here, df = 10-1 = 9
![Page 47: Testing means, part II The paired t-test. Outline of lecture Options in statistics –sometimes there is more than one option One-sample t-test: review](https://reader031.vdocuments.site/reader031/viewer/2022012922/56649eb25503460f94bb98ff/html5/thumbnails/47.jpg)
47
Critical value of t
So we can reject the null hypothesis: Stopping smoking increases job-related accidents in the short term.
t 0.05 2 , 9=2.26
Test statistic: t = 2.45
![Page 48: Testing means, part II The paired t-test. Outline of lecture Options in statistics –sometimes there is more than one option One-sample t-test: review](https://reader031.vdocuments.site/reader031/viewer/2022012922/56649eb25503460f94bb98ff/html5/thumbnails/48.jpg)
48
Assumptions of paired t test
• Pairs are chosen at random
• The differences have a normal distribution
It does not assume that the individual values are normally distributed, only the differences.
![Page 49: Testing means, part II The paired t-test. Outline of lecture Options in statistics –sometimes there is more than one option One-sample t-test: review](https://reader031.vdocuments.site/reader031/viewer/2022012922/56649eb25503460f94bb98ff/html5/thumbnails/49.jpg)
Quick reference summary: Paired t-test
• What is it for? To test whether the mean difference in a population equals a null hypothesized value, μ
do
• What does it assume? Pairs are randomly sampled from a population. The differences are normally distributed
• Test statistic: t
• Distribution under Ho: t-distribution with n-1 degrees of
freedom, where n is the number of pairs
• Formula:
t=d− do
SE d