Unformatted text preview:

Two Sample TestsBios 662Michael G. Hudgens, [email protected]://www.bios.unc.edu/∼mhudgens2008-09-08 13:47BIOS 662 1 Two Sample TestsTwo Sample Test Settings• Single cross-sectional sample, comparing two sub-samples• Compare samples from two different populations (2 cross-sectional samples, case control study)• Single sample; s ubjects randomly allocated to differentinterventions (experiment, clinical trials)BIOS 662 2 Two Sample TestsFundamentals• Def 5.2 Two rvs Y1and Y2are independent if for all y1and y2Pr[Y1≤ y1, Y2≤ y2] = Pr[Y1≤ y1] Pr[Y2≤ y2]• Result 5.1 If Y1and Y2are independent rvs, then forany two constants a1and a2the rv W = a1Y1+ a2Y2has mean and varianceE(W ) = a1E(Y1) + a2E(Y2)V (W ) = a21V (Y1) + a22V (Y2)BIOS 662 3 Two Sample TestsFundamentals• Result 5.2 If Y1and Y2are independent rvs that arenormally distributed, then W = a1Y1+ a2Y2is nor-mally distributed with mean and var given by Result5.1• Corrollary: If¯Y1and¯Y2are based on two independentrandom samples of size n1and n2from two normal dis-tributions with means µ1and µ2and variances σ21andσ22, then¯Y1−¯Y2∼ N µ1− µ2,σ21n1+σ22n2!BIOS 662 4 Two Sample TestsFundamentals• Result 5.3 If¯Y1and¯Y2are based on two independentrandom samples of size n1and n2from two normal dis-tributions with means µ1and µ2and the same variancesσ21= σ22= σ2, then(¯Y1−¯Y2) − (µ1− µ2)spp1/n1+ 1/n2∼ tn1+n2−2wheres2p=(n1− 1)s21+ (n2− 1)s22n1+ n2− 2• Note n1= n2impliess2p=12(s21+ s22)BIOS 662 5 Two Sample TestsTwo Sample t-test Example• An experiment was conducted to see if a drug couldprevent prem ature birth• 30 women at risk of premature birth were randomlyassigned to take drug or placebo (15 in each group)• Endpoint: birthweightBIOS 662 6 Two Sample TestsTwo Sample t-test Example• Let 1=drug, 2=placebo• H0: µ1= µ2vs HA: µ1> µ2• Cα= {t : t > t1−α;28}• C.05= {t : t > 1.7}BIOS 662 7 Two Sample TestsTwo Sample t-test ExampleDrug Placebo6.9 6.47.6 6.77.3 5.47.6 8.26.8 5.37.2 6.68.0 5.85.5 5.75.8 6.27.3 7.18.2 7.06.9 6.96.8 5.65.7 4.28.6 6.8BIOS 662 8 Two Sample TestsTwo Sample t-test ExampleHistogram of drugdrugDensity4 5 6 7 8 90.0 0.1 0.2 0.3 0.4 0.5Histogram of placeboplaceboDensity4 5 6 7 8 90.0 0.1 0.2 0.3 0.4 0.5 0.6●drug placebo5 6 7 8BIOS 662 9 Two Sample TestsTwo Sample t-test Example•¯y1= 7.08 s1= 0.899•¯y2= 6.26 s2= 0.961• Thuss2p=14(.899)2+ 14(.961)228= 0.8695t =7.08 − 6.26.931p2/15= 2.41• Since t ∈ C.05, reject H0p = 1 − Ft28(2.41) = .011BIOS 662 10 Two Sample TestsTwo Sample t-test: BW example• R> t.test(bw$drug,bw$placebo,var.equal=TRUE,alternative="greater")Two Sample t-testdata: bw$drug and bw$placebot = 2.4136, df = 28, p-value = 0.01129alternative hypothesis: true difference in means is greater than 0BIOS 662 11 Two Sample TestsTwo Sample t-test: BW example• SASproc ttest; class trt; var bw;The TTEST ProcedureT-TestsVariable Method Variances DF t Value Pr > |t|bw Pooled Equal 28 2.41 0.0226bw Satterthwaite Unequal 27.9 2.41 0.0226BIOS 662 12 Two Sample TestsHomogeneity of Variance• Want to testH0: σ21= σ22versus HA: σ216= σ22• We know that (assuming normality)(nk− 1)s2kσ2k∼ χ2nk−1for k = 1, 2• If X1and X2are independe nt rvs with X1∼ χ2v1andX2∼ χ2v2, thenX1/v1X2/v2∼ Fv1,v2BIOS 662 13 Two Sample TestsF Distribution0 1 2 3 4 5 60.0 0.2 0.4 0.6 0.8fdensity1,1 df4,4 df4,25 dfBIOS 662 14 Two Sample TestsHomogeneity of Variance• LetXk=(nk− 1)s2kσ2kfor k = 1, 2• It follows thatY =X1/(n1− 1)X2/(n2− 1)∼ Fn1−1,n2−1• ThusY =s21/σ21s22/σ22∼ Fn1−1,n2−1BIOS 662 15 Two Sample TestsHomogeneity of Variance• Under H0: σ21= σ22, such thats21s22∼ Fn1−1,n2−1• For HA: σ216= σ22, reject null if s21/s22is v large or vsmall (i.e., near ze ro)• Formally,Cα= {f : f < Fn1−1,n2−1,α/2or f > Fn1−1,n2−1,1−α/2}where f = s21/s22BIOS 662 16 Two Sample TestsHomogeneity of Variance• Note: Fv1,v2,α= 1/Fv2,v1,1−α• Table A.5 and A .6 of text for two-sided α = .10 andα = .02; see errata• R> qf(.975,14,14)[1] 2.978588• SASdata; y = finv(.975,14,14);BIOS 662 17 Two Sample TestsHomogeneity of Variance: BW example• H0: σ21= σ22; HA: σ216= σ22• For α = .05,C.05= {f : f < F14,14,.025or f > F14,14,.975}= {f : f < 0.34 or f > 2.98}• Observed test statisticf =.89942.96052= 0.8768• Therefore, do not reject H0p = 2 ∗ F14,14(.8768) = 0.809BIOS 662 18 Two Sample TestsHomogeneity of Variance: BW example• SASproc ttest; class trt; var bw;The TTEST ProcedureT-TestsVariable Method Variances DF t Value Pr > |t|bw Pooled Equal 28 2.41 0.0226bw Satterthwaite Unequal 27.9 2.41 0.0226Equality of VariancesVariable Method Num DF Den DF F Value Pr > Fbw Folded F 14 14 1.14 0.8090BIOS 662 19 Two Sample TestsHomogeneity of Variance: BW example• R> var.test(bw$drug,bw$placebo)F test to compare two variancesdata: bw$drug and bw$placeboF = 0.8767, num df = 14, denom df = 14, p-value = 0.809alternative hypothesis: true ratio of variances is not equal to 1BIOS 662 20 Two Sample TestsHomogeneity of Variance• Cf page 133 of text• Genuine interes t in whether vars equal• WRT testing H0: µ1= µ2– For small samples, potential for type II error– For large samples, CLT/Slutsky– Adjustment for sequential testing• For additional reading, see Moser and Stevens (TAS1992)BIOS 662 21 Two Sample TestsTesting µ1= µ2• What if σ216= σ22and unknown?• Solutions1. Large sample approximation2. Normality: Welch-Satterthwaite approximation(Behrens-Fisher problem)3. Transformation4. Nonparametric methods: Wilcoxon RanksumBIOS 662 22 Two Sample TestsLarge Sample Approximation• If n1and n2are large, homoegeneity of variance as-sumption is not important• Recall CLT plus Slutsky implies¯Y ∼ N(µ,s2n)• Thus¯Y1−¯Y2∼ N(µ1− µ2,s21n1+s22n2)BIOS 662 23 Two Sample TestsLarge Sample Approximation• Therefore, to test H0: µ1− µ2= δ, we can useZ =(¯Y1−¯Y2) − δrs21n1+s22n2• Under H0, Z ∼ N(0, 1)• Approximation gets better as n1, n2→ ∞• Generally, require nj≥ 25 for j = 1, 2• Note assumption that Y ’s normally distributed no longerneeded either (CLT)BIOS 662 24 Two Sample TestsLarge Sample Approximation: Example• A st udy was done to compare the percent body fat of 3rdgraders at schools on 2 Native American reservations:Tohona and Apache• H0: µT= µAvs HA: µT6= µA• nT= 63, nA= 35• C.05= {z : |z| >


View Full Document

UNC-Chapel Hill BIOS 662 - Two Sample Tests

Download Two Sample Tests
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Two Sample Tests and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Two Sample Tests 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?