Docsity

Stat 312: Lecture 18 - Paired Samples and Z-Test for Two Proportions, Exams of Mathematical Statistics

Toggle sidebar
bg1
Stat 312: Lecture 18
Other two sample tests
Moo K. Chung
November 11, 2004
Concepts
1. Paired data. For a given paired sample
(X1, Y1),··· ,(Xn, Yn)with EXi=µXand
EYi=µY, a test statistic for testing H0:µX=µYcan
be based on one sample test.
2. Let Xi∼Bernoulli(p1)and Yj∼Bernoulli(p2). Let
ˆp1=Pn
i=1 Xi/n and ˆp2=Pm
j=1 Yj/m.
Var(ˆp1−ˆp2) = p1(1 −p1)
n+p2(1 −p2)
m.
3. Suppose p1and p2denote the proportion of individuals
in population 1 and 2 respectively. For sufficiently large
nand m, we use a Z-statistic for testing
H0:p1=p2vs. H1:p16=p2:
Z=ˆp1−ˆp2−E(ˆp1−ˆp2)
pVar(ˆp1−ˆp2).
Examples
Example 1. 10 students took two midterm exams.
Student k01 02 03 04 05 06 07 08 09 10
Midterm 1k80 75 60 90 99 60 55 85 65 70
Midterm 2k70 60 70 72 95 66 60 80 70 60
Is the first exam easier than the second exam? Test it at level
0.05.
Solution. Let Xiand Yibe the first and the second midterm
scores for the i-th student. Perform the t-test on H0:µY−
µX= 0 based on observations Yi−Xi.
> x<-c(80, 75, 60, 90, 99, 60, 55,
85, 65, 70)
> y<-c(70, 60, 70, 72, 95, 66, 60,
80, 70, 60)
> t.test(y-x, conf.level=0.95)
One Sample t-test
data: y - x t = -1.1739, df = 9,
p-value = 0.2706 alternative
hypothesis: true mean is not equal
to 0 95 percent confidence
interval:
-10.537282 3.337282
Example 2. Is it harmful to use Marijuana when mothers are
pregnant?
User Nonuser
Sample size 1246 11,178
Birth defects 42 294
Solution. Let p1and p2be the birth defect proportions
among Marijuana users and non users. The hypothesis we are
testing is
H0:p1=p2vs. H0:p1> p2.
From data ˆp1= 42/1246 = 0.034,ˆp2= 294/11178 =
0.026. Under H0:p1=p2=p,ˆp= (42 + 294)/(1246 +
11,178) = 0.027. Then the estimate for the variance in Con-
cept 2 under H0would be ˆp(1 −ˆp)(1/n + 1/m) = 0.00482.
Then z= 1.53. We reject H0if zis larger so the P-value is
P(Z > 1.53) = 1 −P(Z < 1.53) = 1 −pnorm(1.53) =
0.06.So we do not reject H0at 0.05 level but we reject H0at
0.1 level.
Example 3. There are two coins. You toss the first coin 100
times and observed 40 heads. When you threw the second
coin 110 times, you observed 50 heads. Test if the two coins
give the same number of heads.
Solution. Let p1and p2be the probabilities of getting heads
for the first and the second coins respectively.
H0:P1=p2vs. H1:p16=p2.
Let Xbe the number of heads when you threw the first coin
n= 100 times and Ybe the number of heads when you threw
the second coin m= 110 times. ˆp1−ˆp2=X/n −Y /m.
Then the test statistic is Z=X/n−Y/m
√p(1−p)(1/n+1/m)∼N(0,1),
where p=p1=p2. Since pis unknown, you estimate it
by pooling the samples: ˆp= (x+y)/(m+n).ˆp= (40 +
50)/(100 +110) = 0.43 and z=−0.60. Since we reject H0
if |z|is large, the P-value would be P(|Z|>0.6) = 2P(Z >
0.6) = 2(1 −P(Z≤0.6)) = 2(1 −0.73) = 0.54. So we do
not reject H0at any level smaller than 0.5.
Review problems
Example 9.9, 9.11.
Note: Starting lecture 19, we will jump to Chapter 12 and
study linear regressions.

Partial preview of the text

Download Stat 312: Lecture 18 - Paired Samples and Z-Test for Two Proportions and more Exams Mathematical Statistics in PDF only on Docsity!

Stat 312: Lecture 18

Other two sample tests

Moo K. Chung

[email protected]

November 11, 2004

Concepts

  1. Paired data. For a given paired sample (X 1 , Y 1 ), · · · , (Xn, Yn) with EXi = μX and EYi = μY , a test statistic for testing H 0 : μX = μY can be based on one sample test.
  2. Let Xi ∼ Bernoulli(p 1 ) and Yj ∼ Bernoulli(p 2 ). Let ˆp 1 =

∑n i=1 Xi/n^ and^ pˆ^2 =^

∑m j=1 Yj^ /m.

Var(ˆp 1 − pˆ 2 ) =

p 1 (1 − p 1 ) n

p 2 (1 − p 2 ) m

  1. Suppose p 1 and p 2 denote the proportion of individuals in population 1 and 2 respectively. For sufficiently large n and m, we use a Z-statistic for testing

H 0 : p 1 = p 2 vs. H 1 : p 1 6 = p 2 :

Z =

pˆ 1 − ˆp 2 − E(ˆp 1 − pˆ 2 ) √ Var(ˆp 1 − pˆ 2 )

Examples

Example 1. 10 students took two midterm exams. Student ‖ 01 02 03 04 05 06 07 08 09 10 Midterm 1‖ 80 75 60 90 99 60 55 85 65 70 Midterm 2‖ 70 60 70 72 95 66 60 80 70 60 Is the first exam easier than the second exam? Test it at level 0.05. Solution. Let Xi and Yi be the first and the second midterm scores for the i-th student. Perform the t-test on H 0 : μY − μX = 0 based on observations Yi − Xi.

x<-c(80, 75, 60, 90, 99, 60, 55, 85, 65, 70) y<-c(70, 60, 70, 72, 95, 66, 60, 80, 70, 60) t.test(y-x, conf.level=0.95) One Sample t-test data: y - x t = -1.1739, df = 9, p-value = 0.2706 alternative hypothesis: true mean is not equal to 0 95 percent confidence interval: -10.537282 3.

Example 2. Is it harmful to use Marijuana when mothers are pregnant?

User Nonuser Sample size 1246 11, Birth defects 42 294 Solution. Let p 1 and p 2 be the birth defect proportions among Marijuana users and non users. The hypothesis we are testing is H 0 : p 1 = p 2 vs. H 0 : p 1 > p 2. From data pˆ 1 = 42/1246 = 0. 034 , pˆ 2 = 294/11178 =

    1. Under H 0 : p 1 = p 2 = p, pˆ = (42 + 294)/(1246 + 11 , 178) = 0. 027. Then the estimate for the variance in Con- cept 2 under H 0 would be pˆ(1 − pˆ)(1/n + 1/m) = 0. 00482. Then z = 1. 53. We reject H 0 if z is larger so the P -value is P (Z > 1 .53) = 1 − P (Z < 1 .53) = 1 − pnorm( 1. 53 ) =
    1. So we do not reject H 0 at 0.05 level but we reject H 0 at 0.1 level. Example 3. There are two coins. You toss the first coin 100 times and observed 40 heads. When you threw the second coin 110 times, you observed 50 heads. Test if the two coins give the same number of heads. Solution. Let p 1 and p 2 be the probabilities of getting heads for the first and the second coins respectively.

H 0 : P 1 = p 2 vs. H 1 : p 1 6 = p 2.

Let X be the number of heads when you threw the first coin n = 100 times and Y be the number of heads when you threw the second coin m = 110 times. pˆ 1 − pˆ 2 = X/n − Y /m. Then the test statistic is Z = √ X/n−Y /m p(1−p)(1/n+1/m)

∼ N (0, 1),

where p = p 1 = p 2. Since p is unknown, you estimate it by pooling the samples: pˆ = (x + y)/(m + n). pˆ = (40 + 50)/(100 + 110) = 0. 43 and z = − 0. 60. Since we reject H 0 if |z| is large, the P -value would be P (|Z| > 0 .6) = 2P (Z > 0 .6) = 2(1 − P (Z ≤ 0 .6)) = 2(1 − 0 .73) = 0. 54. So we do not reject H 0 at any level smaller than 0.5.

Review problems

Example 9.9, 9.11. Note: Starting lecture 19, we will jump to Chapter 12 and study linear regressions.