Unpaired T test
Miaoyan Wang
Department of Statistics UW Madison
Copyright By PowCoder代写 加微信 powcoder
Example: Pairie Dogs
Table: Bark distance (m)
urban rural 29 40 10 47 15 38 41 59 18 45 18 52 12 57 45 50 34 50 30 49 22 50 26 43 18
Y1i: Random variable of the ith response in the first sample for i = 1,…,n1.
Y2i: Random variable of the ith response in the second sample for i = 1,…,n2.
μ1 = E (Y1i ): Population mean response of the first group. μ2 = E (Y2i ): Population mean response of the second group. Our goal is to test
H0 :μ1 =μ2 vs. HA :μ1 ̸=μ2.
Assumptions
#1 The first sample Y11, Y12, . . . , Y1n1 is an i.i.d. sample of size n1 from N(μ1, σ12).
#2 The second sample Y21, Y22, . . . , Y2n2 is an i.i.d. sample of size n2 from N(μ2, σ2).
#3 The two samples {Y1i } and {Y2i } are independent.
#4 The (unknown) variances are the same σ12 = σ2 = σ2.
Test Statistic
H0 :μ1 =μ2 vs HA :μ1 ̸=μ2. The main idea is to consider the difference in mean
Y ̄ 1 − Y ̄ 2 and construct a T-type test statistic
(Y ̄1 − Y ̄2) − E0(Y ̄1 − Y ̄2) T = V a r ( Y ̄ 1 − Y ̄ 2 )
Test Statistic
Under the null hypothesis:
What is the distribution of Y ̄1?
̄ σ2 Y1 ∼ N(μ1, n )
What is the distribution of Y ̄2?
̄ σ2 Y2 ∼ N(μ2, n )
What is the expectation of Y ̄1 − Y ̄2?
μY ̄1−Y ̄2 = E(Y ̄1 − Y ̄2) = E(Y ̄1) − E(Y ̄2) = μ1 − μ2
What is the variance of Y ̄1 − Y ̄2?
σ 2 ̄ ̄ = V a r ( Y ̄ 1 ) + V a r ( Y ̄ 2 ) = σ 2 ( 1 + 1 ) Y1−Y2 n1 n2
Estimated Variance of Y ̄1 − Y ̄2
If Sp2 is an estimator of σ2 = Var(Y1) = Var(Y2), then we can
estimate σ2 ̄ ̄ Y1 −Y2
Var(Y1−Y2)=Sp n +n .
Consider a pooled variance estimate of σ2:
(n1 − 1)S12 + (n2 − 1)S2
n1+n2−2 1 n1
(Y1i − Y ̄1)2, n1 −1 i=1
(Y2i − Y ̄2)2
̄ ̄ 211 12
Interpretation of Sp2: A weighted average of the two sample variances, weighted by the d.f.’s.
T Test Statistic Our goal is to test
H0 :μ1 =μ2 vs HA :μ1 ̸=μ2 Under the H0, the test statistic follows t-distribution with
df=n1 + n2 − 2.
Y ̄ 1 − Y ̄ 2 − 0 t =
S2 1 + 1 Pn1 n2
∼ Tn1+n2−2.
A (1 − α) CI for μ1 − μ2 is
Y ̄1 − Y ̄2 ± tn1+n2−2,α/2 ×
where tn1+n2−2,α/2 is the critical value for which P(|Tn1+n2−2| ≥ tn1+n2−2,α/2) = α.
Example: Bark Distance
From the bark distance data, we have y ̄1 = 48.33, s12 = 38.97, n1 = 12 and y ̄2 = 24.46, s2 = 118.77, n2 = 13.
The pooled sample variance is:
sp2 = (12−1)×38.97+(13−1)×118.77 =80.60 12+13−2
The observed test statistic is:
48.33 − 24.46 − 0 t =
80.601 +1 12 13
Thedegreesoffreedomare: df=12+13−2=23.
The p-value is: The p-value is 2 × P(T23 ≥ 6.642), which is less than 0.002.
The conclusion is: Reject H0 at the 5% level. There is very strong evidence that the mean bark distances for rural and urban prairie dogs are different.
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com