鄭任鈞
1
• Comparing Two Variances via an F test
• Comparing Two Means for Unpaired Samples
• Unpaired t Tests with Pooled Variances
• Welch's Approximate t Tests When Variances Differ
• Confidence Intervals for Differences in Means
• Paired t Tests
• The Wilcoxon Rank-Sum Test for Differences in
Medians
• The Sign Test for Paired Data
• The Wilcoxon Signed-Rank Test for Paired Data
2
3
4
5
FORMULA 7.5
• The test statistic for the paired sample t test is
X d d
t sd
nd
with v = n − 1,where n is the number of pairs of
data points.
6
7
8
9
• Hypotheses about two samples with paired data take
the following forms:
0 d c E (t ) 0
a) H:
a d c E (t ) 0
H:
0 d c E (t ) 0
b) H:
a d c E (t ) 0
H:
0 d c E (t ) 0
c) H:
a d c E (t ) 0
H:
where c is a real number chosen before the data are
gathered; c is often 0 under the assumption of no
change.
10
• The appropriate H0 above is tested using a t test of
the following form:
X d d
t sd
nd
with nd − 1 degrees of freedom.
• The decision about H0 is based on how far this
statistic deviates from expectation under a true H0. If
the t statistic exceeds the critical value(s), H0 is
rejected. Alternatively, if the P value for the t statistic
is smaller than the predetermined alpha level, H0 is
rejected
11
• An F-test is any statistical test in which the test
statistic has an F-distribution under the null
hypothesis
• It is most often used when comparing statistical
models that have been fitted to a data set, in order to
identify the model that best fits the population from
which the data were sampled
12
• Common examples of the use of F-tests include
the study of the following cases:
• The hypothesis that the means of a given set of
normally distributed populations, all having the same
standard deviation, are equal. This is perhaps the
best-known F-test, and plays an important role in the
analysis of variance (ANOVA).
• The hypothesis that a proposed regression model fits
the data well. See Lack-of-fit sum of squares.
• The hypothesis that a data set in a regression analysis
follows the simpler of two proposed linear models
that are nested within each other.
13
Population 1
N(μ1, σ12) Y1, Y2, ........YN1
s12 s12
s12
s12 s12 s12
Population 2
N(μ2, σ22) Y1, Y2, ........YN2
s22 s22
s2 2
s22 s2 2 s22 14
If σ12 = σ22
F = , F = , F = , F = , F = , ........
ν1 = n1 -1, ν2 = n2 -1
Density
F value
15
16
• X ~ F(ν1, ν2)
•0≤F≤∞
• There are two degree of freedom
• Since E(s12) = σ12 and E(s22) = σ22 , the
mean or expected value of the F
distribution is 1
• Because the shape and expected value of
the F distribution are known, the F ratio
is an appropriate test statistic for a null
hypothesis of σ12 = σ22
17
• Fα(ν1, ν2) =
F1−α(ν2, ν1)
• F0.975(12, 6); F0.025(12, 6) = = = 0.27
F0.975(6, 12) .
18
H 0 :σ σ
2
A
2
B
H a :σ σ
2
A
2
B
19
• For Example 7.1 the degrees of
freedom would be vA = nA − 1 = 13 − 1
= 12 and vB = nB − 1 = 7 − 1 = 6. If we
use the variance for location A as the
numerator and the variance for
location B as the denominator in the F
statistic, v1 = 12 and v2 = 6.
Under H: 0 σ A σ B , we expect the F
2 2
value to be close to 1 and when it is
extremely large or extremely small we
will reject H0 in favor of the
alternative hypothesis σ A σ B .
2 2
20
• Using α = 0.05 and v1 = 12 and v2 = 6, we
find the critical values for this F statistic to
be:
• Right tail from Table C.7, F0.975(12,6) = 5.37.
• Left tail for an F with v1 and v2 degrees of
freedom is the reciprocal of the
corresponding right-tail critical value with
the degrees of freedom reversed.
1 1
F0.025(12, 6) 0.27
F0.975(6, 12) 3.73
21
• So if the variance of Location A is less than 0.27
times the variance of Location B or if the
variance of Location A is more that 5.37 times
the variance of Location B, we will assume that
H0 is false because the F value is so far from the
expected value of 1. Rejecting H0 with these
critical values will lead to a Type I error 5% of
the time.
22
• We can now finish the analysis. s A2 37,853.17
and sB 15,037.00 ,
2
2
s 37,853.17
F A
2
2.52
s 15,037.00
B
• The variance of Location A is 2.52 times
the variance of Location B, but because
of the small sample sizes here we cannot
say that this statistic (2.52) is
significantly different from expectation
under H0 [E(F) = 1]. Because 0.27 < 2.52
< 5.37 we accept H0. 23
24
F0.95(49, 49)
25
26
• Hypotheses about two population variances can
take one of three forms:
a) H 0 :σ12 σ 22 b) H 0 :σ12 σ 22 c) H 0 :σ12 σ 22
H a :σ σ
2
1
2
2 H a :σ σ
2
1
2
2 H a :σ σ
2
1
2
2
• Each H0 above is tested with an F statistic and
the decision about H0 is based on how far this
statistic deviates from expectation under a true
H0. If the F statistic exceeds the critical value(s),
H0 is rejected. Alternatively, if the P value for the
F statistic is smaller than the predetermined
alpha level, H0 is rejected.
27
• Equal Population Variances
• We first consider two independent random samples
of size n1 and n2 from two normally distributed
populations, with equal population variances assumed.
28
29
30
31
FORMULA 7.1
• Under H0, (μ1 − μ2) = 0, making the test
statistic for the difference in means of
independent samples with equal variances
( X 1 X 2 ) ( 1 2 )
t
s 2
p 1
n1 n12
with v = n1 + n2 − 2 degrees of freedom.
32
33
34
35
F0.975(24, 35)
F0.025(35, 24)
=F
0.975(35, 24)
36
37
38
• Hypotheses about two means from independent
samples of normal populations with equal
variances can take the following forms:
0 1 2
a) H: E (t ) 0
a 1 2
H: E (t ) 0
0 1 2
b) H: E (t ) 0
a 1 2
H: E (t ) 0
0 1 2
c) H: E (t ) 0
a 1 2
H: E (t ) 0
39
• If a preliminary F test of H:0 σ σ is accepted,
2
1
2
2
then the appropriate H0 above is tested using
a t test of the following form:
( X 1 X 2 ) ( 1 2 )
t , with ν n1 n2 2
s 2p 1
n1 n12
• The decision about H0 is based on how far this
statistic deviates from expectation under a
true H0. If the t statistic exceeds the critical
value(s), H0 is rejected. Alternatively, if the P
value for the t statistic is smaller than the
predetermined alpha level, H0 is rejected.
40
FORMULA 7.2
• The t test for H0 : μ1 = μ2 when the population
variances differ is
( X 1 X 2 ) ( 1 2 )
t
s12 s22
n1 n2
with s12 s22
2
n1 n2
22 2 2
s1 s2
n1 n2
n1 1
n2 1
This calculation of the degrees of freedom should be
rounded down to the nearest integer and will be
somewhat less than n1 + n2 − 2 in most cases.
41
42
43
F0.975(14, 9)
44
45
46
• Hypotheses about two means from independent
samples without the assumption of equal
variances can take the following forms:
0 1 2
a) H: E (t ) 0
a 1 2
H: E (t ) 0
0 1 2
b) H: E (t ) 0
a 1 2
H: E (t ) 0
0 1 2
c) H: E (t ) 0
a 1 2
H: E (t ) 0
47
• If a preliminary F test of the 0 1
H: σ 2
σ 2
2 is
rejected, then the appropriate H0 above is
tested using a t test of the following form:
2
s12 s22
( X 1 X 2 ) ( 1 2 ) n1 n2
t with
2 2
s12 s22 s12 s22
n2 n1 n2
n1
n1 1
n2 1
48
μ1 − μ2
• We have a point estimate X 1 X 2 for the
difference of the means, its sampling distribution
is the t distribution, and an estimate of its
standard error based on whether the population
variances are equal or not. Using (4.3) we can
determine a confidence interval for the
difference in the population means 母體平均值
之差異值的可信賴區間.
49
FORMULA 7.3
• Assuming equal variance, the confidence
interval for μ1 − μ2 at the (1 − α)100% level
of confidence is given by
C[( X 1 X 2 ) t0 s X1 X 2 1 2 ( X 1 X 2 ) t0 s X1 X 2 ] 1
where 1 1
s X1 X 2 s
2
p
n1 n2
and t0 t1 2 , with degrees of freedom v = n1
+ n2 − 2.
50
51
FORMULA 7.4
• When equal variances cannot be assumed, the
confidence interval for μ1 − μ2 at the (1 −
α)100% level of confidence is given by
s12 s22 s12 s22
C ( X 1 X 2 ) t0 1 2 ( X 1 X 2 ) t0 1
n1 n2 n1 n2
wheret0 t1 , with degrees of freedom
2
2
s12 s22
n1 n2
2 2
s12 s22
n1 n2
n1 1
n2 1
52
53
54
• If there are reasons to believe that the
distributions involved are normal, then tests on
the differences in the means of the two
populations are carried out by using one form or
another of the t test, depending on whether
variances are equal or not. But often we don't
know anything about the populations or
perhaps we know that the distributions are not
normal. In this case, the most common
distribution-free hypothesis test used is the
Wilcoxon rank-sum test, also known as the
Mann-Whitney U test.
55
• The assumptions for the Wilcoxon rank-sum test
are the following:
1. X and Y are continuous random variables.
2. The data consist of two independent, random
samples. X1, …, Xm denotes a random sample of size
m from the distribution of X, and Y1, …, Yn denotes a
random sample of size n from the distribution of Y .
Note that m and n are often, but not always,
different.
3. The null hypothesis is that the X and Y populations
are identical.
56 © Waveland Press;滄海圖
書
• Let MX and MY denote the medians of X and Y ,
respectively. The hypothesis test can take one of
three forms:
• Two-tailed. H0: MX = MY versus Ha: MX ≠ MY . This
tests whether the X′s tend to be different from
the Y′s.
• Left-tailed. H0: MX ≥ MY versus Ha: MX < MY. This
tests whether the X's tend to be smaller than
the Y′s.
• Right-tailed. H0: MX ≤ MY versus Ha: MX > MY.
This tests whether the X′s tend to be larger than
the Y′s.
57 © Waveland Press;滄海圖
書
• Q1:(課本第19題!) 如果一個生物學家在兩個
不同地點採了蜈蚣。第一個地點,有多樣化的環
境,第二個地點,環境單一。他認為在多樣化的
環境當中,動物體長變化性比較高,他收集的資
料是支持此觀點?
58
Q2:在多樣化環境中的動物,體長是否較長?
(3.6)2 = 12.96, (3.6)2 /25 = 0.5184, ((3.6)2 /25)2 /24 = 0.0111
(2.5)2 = 6.25, (2.5)2 / 30 = 0.2083, ((2.5)2 /30)2 /29 = 0.0015
(0.7267)0.5 = 0.8525
(0.7267)2 = 0.5281
0.5280/0.0126 = 41.91
-2.4/0.8525 = -2.815
59