testing means, part iii the two-sample t-test
DESCRIPTION
Testing means, part III The two-sample t-test. One-sample t-test. Null hypothesis The population mean is equal to o. Sample. Null distribution t with n-1 df. Test statistic. compare. How unusual is this test statistic?. P > 0.05. P < 0.05. Reject H o. Fail to reject H o. - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Testing means, part III The two-sample t-test](https://reader036.vdocuments.mx/reader036/viewer/2022062501/56815ff8550346895dcef87f/html5/thumbnails/1.jpg)
Testing means, part III
The two-sample t-test
![Page 2: Testing means, part III The two-sample t-test](https://reader036.vdocuments.mx/reader036/viewer/2022062501/56815ff8550346895dcef87f/html5/thumbnails/2.jpg)
Sample Null hypothesisThe population mean
is equal to o
One-sample t-test
Test statistic Null distributiont with n-1 dfcompare
How unusual is this test statistic?
P < 0.05 P > 0.05
Reject Ho Fail to reject Ho
€
t = Y − μo
s / n
![Page 3: Testing means, part III The two-sample t-test](https://reader036.vdocuments.mx/reader036/viewer/2022062501/56815ff8550346895dcef87f/html5/thumbnails/3.jpg)
Sample Null hypothesisThe mean difference
is equal to o
Paired t-test
Test statistic Null distributiont with n-1 df
*n is the number of pairscompare
How unusual is this test statistic?
P < 0.05 P > 0.05
Reject Ho Fail to reject Ho
€
t = d − μdo
SEd
![Page 4: Testing means, part III The two-sample t-test](https://reader036.vdocuments.mx/reader036/viewer/2022062501/56815ff8550346895dcef87f/html5/thumbnails/4.jpg)
4
Comparing means
• Tests with one categorical and one numerical variable
• Goal: to compare the mean of a numerical variable for different groups.
![Page 5: Testing means, part III The two-sample t-test](https://reader036.vdocuments.mx/reader036/viewer/2022062501/56815ff8550346895dcef87f/html5/thumbnails/5.jpg)
5
Paired vs. 2 sample comparisons
![Page 6: Testing means, part III The two-sample t-test](https://reader036.vdocuments.mx/reader036/viewer/2022062501/56815ff8550346895dcef87f/html5/thumbnails/6.jpg)
6
2 Sample Design
• Each of the two samples is a random sample from its population
![Page 7: Testing means, part III The two-sample t-test](https://reader036.vdocuments.mx/reader036/viewer/2022062501/56815ff8550346895dcef87f/html5/thumbnails/7.jpg)
7
2 Sample Design
• Each of the two samples is a random sample from its population
• The data cannot be paired
![Page 8: Testing means, part III The two-sample t-test](https://reader036.vdocuments.mx/reader036/viewer/2022062501/56815ff8550346895dcef87f/html5/thumbnails/8.jpg)
8
2 Sample Design - assumptions
• Each of the two samples is a random sample
• In each population, the numerical variable being studied is normally distributed
• The standard deviation of the numerical variable in the first population is equal to the standard deviation in the second population
![Page 9: Testing means, part III The two-sample t-test](https://reader036.vdocuments.mx/reader036/viewer/2022062501/56815ff8550346895dcef87f/html5/thumbnails/9.jpg)
9
Estimation: Difference between two
means
€
Y 1 −Y 2
Normal distributionStandard deviation s1=s2=s
Since both Y1 and Y2 are normally distributed, their difference will also follow a normal distribution
![Page 10: Testing means, part III The two-sample t-test](https://reader036.vdocuments.mx/reader036/viewer/2022062501/56815ff8550346895dcef87f/html5/thumbnails/10.jpg)
10
Estimation: Difference between two
means
€
Y 1 −Y 2
Confidence interval:
€
Y 1 −Y 2( ) ± SEY 1 −Y 2tα 2( ),df
![Page 11: Testing means, part III The two-sample t-test](https://reader036.vdocuments.mx/reader036/viewer/2022062501/56815ff8550346895dcef87f/html5/thumbnails/11.jpg)
11
Standard error of difference in means
€
SEY 1 −Y 2= sp
2 1n1
+ 1n2
⎛ ⎝ ⎜
⎞ ⎠ ⎟
= pooled sample variance= size of sample 1= size of sample 2
€
sp2
n1
n2
![Page 12: Testing means, part III The two-sample t-test](https://reader036.vdocuments.mx/reader036/viewer/2022062501/56815ff8550346895dcef87f/html5/thumbnails/12.jpg)
12
Standard error of difference in means
€
SEY 1 −Y 2= sp
2 1n1
+ 1n2
⎛ ⎝ ⎜
⎞ ⎠ ⎟
€
sp2 =
df1s12 + df2s2
2
df1 + df2
Pooled variance:
![Page 13: Testing means, part III The two-sample t-test](https://reader036.vdocuments.mx/reader036/viewer/2022062501/56815ff8550346895dcef87f/html5/thumbnails/13.jpg)
13
Standard error of difference in means
€
sp2 =
df1s12 + df2s2
2
df1 + df2
df1 = degrees of freedom for sample 1 = n1 -1df2 = degrees of freedom for sample 2 = n2-1s1
2 = sample variance of sample 1s2
2 = sample variance of sample 2
Pooled variance:
![Page 14: Testing means, part III The two-sample t-test](https://reader036.vdocuments.mx/reader036/viewer/2022062501/56815ff8550346895dcef87f/html5/thumbnails/14.jpg)
14
Estimation: Difference between two
means
€
Y 1 −Y 2
Confidence interval:
€
Y 1 −Y 2( ) ± SEY 1 −Y 2tα 2( ),df
![Page 15: Testing means, part III The two-sample t-test](https://reader036.vdocuments.mx/reader036/viewer/2022062501/56815ff8550346895dcef87f/html5/thumbnails/15.jpg)
15
Estimation: Difference between two
means
€
Y 1 −Y 2
Confidence interval:
€
Y 1 −Y 2( ) ± SEY 1 −Y 2tα 2( ),df
df = df1 + df2 = n1+n2-2
![Page 16: Testing means, part III The two-sample t-test](https://reader036.vdocuments.mx/reader036/viewer/2022062501/56815ff8550346895dcef87f/html5/thumbnails/16.jpg)
16
Costs of resistance to disease
2 genotypes of lettuce: Susceptible and Resistant
Do these differ in fitness in the absence of disease?
QuickTime™ and aTIFF (Uncompressed) decompressor
are needed to see this picture.QuickTime™ and a
TIFF (Uncompressed) decompressorare needed to see this picture.
![Page 17: Testing means, part III The two-sample t-test](https://reader036.vdocuments.mx/reader036/viewer/2022062501/56815ff8550346895dcef87f/html5/thumbnails/17.jpg)
17
Data, summarizedSusceptible Resistant
Mean numberof buds 720 582
SD of numberof buds 223.6 277.3
Sample size 15 16
Both distributions are approximately normal.
![Page 18: Testing means, part III The two-sample t-test](https://reader036.vdocuments.mx/reader036/viewer/2022062501/56815ff8550346895dcef87f/html5/thumbnails/18.jpg)
18
Calculating the standard errordf1 =15 -1=14; df2 = 16-1=15
![Page 19: Testing means, part III The two-sample t-test](https://reader036.vdocuments.mx/reader036/viewer/2022062501/56815ff8550346895dcef87f/html5/thumbnails/19.jpg)
19
Calculating the standard errordf1 =15 -1=14; df2 = 16-1=15
€
sp2 = df1s1
2 + df2s22
df1 + df2
=14 223.6( )
2 +15 277.3( )2
14 +15= 63909.9
![Page 20: Testing means, part III The two-sample t-test](https://reader036.vdocuments.mx/reader036/viewer/2022062501/56815ff8550346895dcef87f/html5/thumbnails/20.jpg)
20
Calculating the standard errordf1 =15 -1=14; df2 = 16-1=15
€
sp2 = df1s1
2 + df2s22
df1 + df2
=14 223.6( )
2 +15 277.3( )2
14 +15= 63909.9
€
SEx 1 −x 2= sp
2 1n1
+ 1n2
⎛ ⎝ ⎜
⎞ ⎠ ⎟= 63909.9 1
15+ 1
16 ⎛ ⎝ ⎜
⎞ ⎠ ⎟= 90.86
![Page 21: Testing means, part III The two-sample t-test](https://reader036.vdocuments.mx/reader036/viewer/2022062501/56815ff8550346895dcef87f/html5/thumbnails/21.jpg)
21
Finding t
df = df1 + df2= n1+n2-2
= 15+16-2=29
![Page 22: Testing means, part III The two-sample t-test](https://reader036.vdocuments.mx/reader036/viewer/2022062501/56815ff8550346895dcef87f/html5/thumbnails/22.jpg)
22
Finding t
df = df1 + df2= n1+n2-2
= 15+16-2=29
€
t0.05 2( ),29 = 2.05
![Page 23: Testing means, part III The two-sample t-test](https://reader036.vdocuments.mx/reader036/viewer/2022062501/56815ff8550346895dcef87f/html5/thumbnails/23.jpg)
23
The 95% confidence interval of the
difference in the means
€
Y 1 −Y 2( ) ± sY 1 −Y 2tα 2( ),df = 720 − 582( ) ± 90.86 2.05( )
=138 ±186
![Page 24: Testing means, part III The two-sample t-test](https://reader036.vdocuments.mx/reader036/viewer/2022062501/56815ff8550346895dcef87f/html5/thumbnails/24.jpg)
24
Testing hypotheses about the difference
in two means2-sample t-test
The two sample t-test compares the means of a numerical
variable between two populations.
![Page 25: Testing means, part III The two-sample t-test](https://reader036.vdocuments.mx/reader036/viewer/2022062501/56815ff8550346895dcef87f/html5/thumbnails/25.jpg)
25
2-sample t-test
€
t = Y 1 −Y 2SE
Y 1−Y 2
Test statistic:
€
SEY 1 −Y 2= sp
2 1n1
+ 1n2
⎛ ⎝ ⎜
⎞ ⎠ ⎟
€
sp2 =
df1s12 + df2s2
2
df1 + df2
![Page 26: Testing means, part III The two-sample t-test](https://reader036.vdocuments.mx/reader036/viewer/2022062501/56815ff8550346895dcef87f/html5/thumbnails/26.jpg)
26
Hypotheses
H0: There is no difference between the number ofbuds in the susceptible and resistant plants.
(1 = 2)
HA: The resistant and the susceptible plants differ intheir ean nu ber of buds. (1 ≠ 2)
![Page 27: Testing means, part III The two-sample t-test](https://reader036.vdocuments.mx/reader036/viewer/2022062501/56815ff8550346895dcef87f/html5/thumbnails/27.jpg)
27
Null distribution
€
tα 2( ),df
df = df1 + df2 = n1+n2-2
![Page 28: Testing means, part III The two-sample t-test](https://reader036.vdocuments.mx/reader036/viewer/2022062501/56815ff8550346895dcef87f/html5/thumbnails/28.jpg)
28
Calculating t
€
t =x 1 − x 2( )SEx 1 −x 2
=720 − 582( )
90.86=1.52
![Page 29: Testing means, part III The two-sample t-test](https://reader036.vdocuments.mx/reader036/viewer/2022062501/56815ff8550346895dcef87f/html5/thumbnails/29.jpg)
29
Drawing conclusions...
t0.05(2),29=2.05
t <2.05, so we cannot reject the null hypothesis.
These data are not sufficient to say that there is a cost of resistance.
Critical value:
![Page 30: Testing means, part III The two-sample t-test](https://reader036.vdocuments.mx/reader036/viewer/2022062501/56815ff8550346895dcef87f/html5/thumbnails/30.jpg)
30
Assumptions of two-sample t -tests
• Both samples are random samples.
• Both populations have normal distributions
• The variance of both populations is equal.
![Page 31: Testing means, part III The two-sample t-test](https://reader036.vdocuments.mx/reader036/viewer/2022062501/56815ff8550346895dcef87f/html5/thumbnails/31.jpg)
SampleNull hypothesis
The two populations have the same mean
1=2
Two-sample t-test
Test statistic Null distributiont with n1+n2-2 dfcompare
How unusual is this test statistic?
P < 0.05 P > 0.05
Reject Ho Fail to reject Ho
€
t = Y 1 −Y 2SE
Y 1−Y 2
![Page 32: Testing means, part III The two-sample t-test](https://reader036.vdocuments.mx/reader036/viewer/2022062501/56815ff8550346895dcef87f/html5/thumbnails/32.jpg)
Quick reference summary:
Two-sample t-test• What is it for? Tests whether two groups have the same mean
• What does it assume? Both samples are random samples. The numerical variable is normally distributed within both populations. The variance of the distribution is the same in the two populations
• Test statistic: t• Distribution under Ho: t-distribution with n1+n2-2 degrees of freedom.
• Formulae:
€
t = Y 1 −Y 2SE
Y 1−Y 2€
SEY 1 −Y 2= sp
2 1n1
+ 1n2
⎛ ⎝ ⎜
⎞ ⎠ ⎟
€
sp2 =
df1s12 + df2s2
2
df1 + df2
![Page 33: Testing means, part III The two-sample t-test](https://reader036.vdocuments.mx/reader036/viewer/2022062501/56815ff8550346895dcef87f/html5/thumbnails/33.jpg)
33
Comparing means when variances are not
equalWelch’s t test
Welch's approximate t-test compares the means of two
normally distributed populations that have unequal
variances.
![Page 34: Testing means, part III The two-sample t-test](https://reader036.vdocuments.mx/reader036/viewer/2022062501/56815ff8550346895dcef87f/html5/thumbnails/34.jpg)
34
Burrowing owls and dung traps
QuickTime™ and aTIFF (LZW) decompressor
are needed to see this picture.
![Page 35: Testing means, part III The two-sample t-test](https://reader036.vdocuments.mx/reader036/viewer/2022062501/56815ff8550346895dcef87f/html5/thumbnails/35.jpg)
35
Dung beetles
![Page 36: Testing means, part III The two-sample t-test](https://reader036.vdocuments.mx/reader036/viewer/2022062501/56815ff8550346895dcef87f/html5/thumbnails/36.jpg)
36
Experimental design
• 20 randomly chosen burrowing owl nests
• Randomly divided into two groups of 10 nests
• One group was given extra dung; the other not
• Measured the number of dung beetles on the owls’ diets
![Page 37: Testing means, part III The two-sample t-test](https://reader036.vdocuments.mx/reader036/viewer/2022062501/56815ff8550346895dcef87f/html5/thumbnails/37.jpg)
37
Number of beetles caught
• Dung added:
• No dung added:
€
Y = 4.8s = 3.26
€
Y = 0.51s = 0.89
![Page 38: Testing means, part III The two-sample t-test](https://reader036.vdocuments.mx/reader036/viewer/2022062501/56815ff8550346895dcef87f/html5/thumbnails/38.jpg)
38
Hypotheses
H0: Owls catch the same number of dung beetles with or without extra dung (1 = 2)
HA: Owls do not catch the same number of dung beetles with or without extra dung (1 2)
![Page 39: Testing means, part III The two-sample t-test](https://reader036.vdocuments.mx/reader036/viewer/2022062501/56815ff8550346895dcef87f/html5/thumbnails/39.jpg)
39
Welch’s t
€
t =Y 1 − Y 2s1
2
n1
+ s22
n2
€
df =
s12
n1
+s2
2
n2
⎛ ⎝ ⎜
⎞ ⎠ ⎟2
s12 n1( )
2
n1 −1+
s22 n2( )
2
n2 −1
⎛
⎝ ⎜ ⎜
⎞
⎠ ⎟ ⎟
Round down df to nearest integer
![Page 40: Testing means, part III The two-sample t-test](https://reader036.vdocuments.mx/reader036/viewer/2022062501/56815ff8550346895dcef87f/html5/thumbnails/40.jpg)
40
Owls and dung beetles
€
t = Y 1 −Y 2s1
2
n1
+ s22
n2
= 4.8 − 0.513.262
10+ 0.892
10
= 4.01
![Page 41: Testing means, part III The two-sample t-test](https://reader036.vdocuments.mx/reader036/viewer/2022062501/56815ff8550346895dcef87f/html5/thumbnails/41.jpg)
41
Degrees of freedom
€
df =
s12
n1
+ s22
n2
⎛ ⎝ ⎜
⎞ ⎠ ⎟2
s12 n1( )
2
n1 −1+
s22 n2( )
2
n2 −1
⎛
⎝ ⎜ ⎜
⎞
⎠ ⎟ ⎟
=
3.262
10+ 0.892
10
⎛ ⎝ ⎜
⎞ ⎠ ⎟2
3.262 10( )2
10 −1+
0.892 10( )2
10 −1
⎛
⎝ ⎜ ⎜
⎞
⎠ ⎟ ⎟
=10.33
Which we round down to df= 10
![Page 42: Testing means, part III The two-sample t-test](https://reader036.vdocuments.mx/reader036/viewer/2022062501/56815ff8550346895dcef87f/html5/thumbnails/42.jpg)
42
Reaching a conclusion
t0.05(2), 10= 2.23
t=4.01 > 2.23
So we can reject the null hypothesis with P<0.05.
Extra dung near burrowing owl nests increases the number of dung beetles eaten.
![Page 43: Testing means, part III The two-sample t-test](https://reader036.vdocuments.mx/reader036/viewer/2022062501/56815ff8550346895dcef87f/html5/thumbnails/43.jpg)
Quick reference summary:
Welch’s approximate t-test• What is it for? Testing the difference
between means of two groups when the standard deviations are unequal
• What does it assume? Both samples are random samples. The numerical variable is normally distributed within both populations
• Test statistic: t• Distribution under Ho: t-distribution with adjusted degrees of freedom
• Formulae:
€
t =Y 1 − Y 2s1
2
n1
+ s22
n2
€
df =
s12
n1
+ s22
n2
⎛ ⎝ ⎜
⎞ ⎠ ⎟2
s12 n1( )
2
n1 −1+
s22 n2( )
2
n2 −1
⎛
⎝ ⎜ ⎜
⎞
⎠ ⎟ ⎟
![Page 44: Testing means, part III The two-sample t-test](https://reader036.vdocuments.mx/reader036/viewer/2022062501/56815ff8550346895dcef87f/html5/thumbnails/44.jpg)
44
The wrong way to make a comparison of two
groups“Group 1 is significantly different from a constant, but Group 2 is not. Therefore Group 1 and Group 2 are different from each other.”
![Page 45: Testing means, part III The two-sample t-test](https://reader036.vdocuments.mx/reader036/viewer/2022062501/56815ff8550346895dcef87f/html5/thumbnails/45.jpg)
45
A more extreme case...