Cotets 3.5.3 Two Saple t Tests................................... 3.5.3 Two Saple t Tests Setup: Two Saples We ow focus o a sceario where we have two idepedet saples fro possibly differet populatios. Our iterest focuses o the differece i populatio eas µ µ y. We assue both saples coe fro oral saplig distributios that ay or ay ot differ i their ea ad variace paraeters. or equivaletly X,..., X Y,..., Y N ( µ, ) N ( µ y, y ) X i = µ + ɛ i, i =,..., ɛ i N ( 0, ) Y j = µ y + δ j, j =,..., δ j N ( 0, y ) I both cases, our theoretical owledge tells us the followig facts: X N ( µ, / ) Ȳ N ( µ y, y/ ), ad () X Ȳ N ( µ µ y, / + y/ ). There are four scearios to hadle, as suarized i the followig table. We will address each sceario i tur, presetig soe theores to justify the proposed tests. We will also eplore the iplicatios i quic eaples. Variace Assuptios Test Distributio Coo variace Variace ow Z test N(0, ) = y = Variace uow t test t + Differet variaces Variaces ow Z test N(0, ) y Variaces uow t test t df. Coo variace, = y =. (a) Variace ow. Coo Variace, Variace Kow Usig the distributio i Eq. () for X Ȳ ad applyig equivalece of variaces, we have statistic Z = ( X Ȳ ) (µ µ y ) N(0, ) + with CI for µ µ y give by Z ± φ + +, rejectio (tail) regio for H 0 : µ µ y = A cosistig of Z with Z > φ +, ad p-value P (Z > z ) for observed value of the test statistic z, coputed i R as (b) Variace uow. R> *por(-abs(z)). ()
Coo Variace, Variace Uow If the variace is uow, we eed to obtai a estiate of. There are actually two estiates available, S ad S y, but uder the assuptio of coo variaces, they both estiate the sae quatity. It would be best if we could cobie these estiates ito a sigle estiator. The pooled variace is such a estiator: S p = ( )S + ( )S y + This estiator weights the estiates obtaied fro each saple by its saple size, which sees logical. There is a theore that gives us a statistic ad saplig distributio for this sceario. Theore 0. Give two saples as i Eq., the statistic T = ( X Ȳ ) (µ µ y ) S p + has a t distributio with + degrees of freedo. t + Proof. We ow, fro Th??, that ( )S χ ad ( )S y χ have chi-squared distributios. I additio, these quatitites are idepedet because the saples are idepedet. Therefore, ( )S + ( )Sy = ( + )S p χ + by the reproductive property of chi-square rado variables. Cosider ad U = X Ȳ (µ µ y ) N(0, ) V = The, Th.?? yields T = U/V t +. + S p = S p. The above-defied t statistic allows us to costruct CI for µ µ y of ( ) + α T ± t + S p + ( where t +α ) ( + is the +α ) th quatile of the t+ distributio coputed as R> qt((+alpha)/, df=+-). The rejectio regios (tails) for H 0 : µ µ y = A iclude values of T where ( ) + α T > t + ad the p-value for reject H 0 : µ = µ y is P (T > t ) for T t + ad the observe statistic t, coputed as R> *pt(-abs(t)). Eaple: Suppose two ethods, A ad B, easure the latet heat of fusio of ice, the chage i heat, easured i calories/gra, whe ice oves fro 0.7 o C to water at 0 o C. Fid the CI for µ A µ B ad test H 0 : µ a = µ B whe X A = 80.0, X B = 79.98, S A = 0.04, S B = 0.03, = 3, ad = 8, assuig the variaces are equal.
The pooled variace is S p = 0.04 + 7 0.03 = 0.000778 The estiated populatio ea differece is X A X B = 0.04 with correspodig saple variace S XA X B = S p 3 + 8 = 0.0. The critical value t 9(0.975) is coputed as R> qt(0.975, df=9) ad is.093. Therefore, the CI are The hypothesis test uses statistic 0.04 ±.093 0.0 = (0.05, 0.065) t = X A X B S XA X B = 0.04 0.0 = 0 3, with p-value give by R> *pt(-0/3, df=9), which is 0.00349. We coclude that at least oe of the two easureet ethods is a biased estiator of the heat of fusio.. Differece variaces, y. (a) Variace ow. Differet Variaces, Variaces Kow Whe variace is ow, we use the ow distributio (Eq. ) of X Ȳ to for statistic with CI for µ µ y give by Z = X Ȳ (µ µ y ) N(0, ) + y X Ȳ ± φ +α + y. Rejectio regios ad p-value are coputed as for the case with coo, ow variace. (b) Variace uow. Differet Variaces, Variaces Uow Whe variace is uow, it is atural to estiate Var( X Ȳ ) =S + S y There is a theore that justifies this choice that we will state without proof. Theore. Give the two-saple setup of Eq., the statistic X Ȳ (µ µ y ) t df S + S y has a t-distributio with degrees of freedo give by df = [( S (S /) ) + ( S y )] + (S y /) 3
Eaple: Returig to the heat of fusio eaple, repeat the aalysis without assuig equal variaces. First, we ust copute df as df = [ ] 0.04 3 + 0.03 8 0.04 0.03 3 8 3 + 8 =.83 We ca roud this to, although R will hadle o-iteger degrees of freedo. The CI becoe ( ) X A X + α 0.04 B ± t.83 + 0.03 = (0.0, 0.068) 3 8 The hypothesis test uses statistic X A X B 0.08 = 3.5 which geerates p-value 0.00895 via R> *pt(-3.5, df=.83). Noral Probability Plot The precedig results deped o startig with two saples of orally distributed rado variables. For o-oral saplig distributios, the CLT gives us the result asyptotically, although saple size ust be large to be sure. Thus, ay data aalysis should start with a eaiatio of the data to assess whether the data are approiately oral. We ow derive oe of the ost coo graphical techiques for assessig orality, the oral probability plot. We etioed it briefly whe coverig graphical suaries of data. Theore. Suppose rado variable X F () has strictly icreasig cdf ad let Z = F (X), the Z Uif(0, ) Proof. P (Z z) = P [F (X) z[ = P [ X F (z) ] = F [ F (z) ] = z The cdf of the stadard oral r.v. is F (z) = z, thus Z Uif(0,). Suppose X F () is the hypothesized cdf (i our case, soe id of oral). Give X,..., X F (), the ordered values, fro sallest to largest, are writte as X (),..., X () where X () is the th sallest value. We clai X () estiates the saple quatile is the first observed value X such that But, ideed, X () does satisfy while X ( ) does ot, so it is the first. #{X i X } #{X i X () } + + + quatile. To verify, reeber the Now F (X i ) are uiforly distributed if ad oly if F () is the true cdf of the X i. I particular, the quatiles X () should ap, via F (X () ), to the quatiles of a Uif(0, ) distributio, aely. Thus, if we plot 4 +
( poits F (X () ), ) +, they should fall alog the lie y = if F () is the saplig distributio of X i. ( )) Equivaletly, we could plot poits (X (), F +, which has the advatage of plottig the data o its origial, presuably iterpretable, scale. Stadardizatio. If we stadardize the data Xi µ first, the F () becoes the stadard oral cdf Φ(). If we do ot use the stadard oral cdf, the we also eed µ ad to copute the cdf F (). I either case, µ ad are( uow, )) but we ca replace the with their saple estiators. Still, we ay prefer to plot (X (), Φ, which requires o owledge of µ or. It agai has the advatage that the -ais is + o the origial data scale. While the data should still for a lie, it is ot the y = idetity lie. There are ay variats of the oral probability plot, but the idea is the sae: Curvature i the poits suggests o-oral data. Eaple: Of Mice ad Iro We ow deostrate how to perfor a two-saple aalysis of data where orality assuptios ay be uder doubt. Suppose ice are give either radioactive F e + or radioactive F e 3+. The, a few days later, their radioactivity is easured i order to deterie which iro suppleet is better retaied by the body. The data is available as Fe.Rtt. Our first cocer is to chec that the data are oral, sice all two-sapled results have assued oral saplig distributios. We ca plot histogras ad see that the data see to be sewed right ad trucated o the left, sice egative radioacitivities are ot possible (Fig. 4). We ca see the oral probability plots (Fig. 4) show soe curvature, so we are cocered about possible o-orality. We ow of oe foral test for distributioal assuptios: the goodess-of-fit. We will bi the data ito the quartiles of a oral distributio. Which oral distributio? We ust estiate its two paraeters with the saple ea ad saple variace. For the F e + data, X = 9.63 ad stadard deviatio S = 6.695. Each paraeter we estiate taes away oe degree of freedo. The quartiles of N(9.6, 6.69 ) are 5.09, 9.6, 4.. We cout the uber of observatios i each iterval. X i < 5.09 5.09 X i < 9.6 9.6 X i < 4. 4. X i Epected Observed 4 9 3 Epected couts are a little low, but we ll proceed with the chi-squared goodess-of-fit test ayway. The statistic is X ( 4 0.5) ( 9 0.5) ( 0.5) ( 3 0.5) = + + + + = 4.7 where we have applied the Yate s cotiuity correctio to each ter. The correctio is ost iportat for low cout data, ad it corrects for the fact that epectatios are cotiuous, but observed data are always discrete. The degrees of freedo are df = 4 =, so the p-value for rejectig the ull hypothesis of orally distributed data is 0.097754. At a traditioal α-level of 0.05, we reject the ull hypothesis, ad develop further worries about usig the t-test. We proceed with the t-test,but do so with great cocer. The saple size = = 8 does ot eceed the rule-of-thub 30 that we lie for trustig CLT asyptotics. The saple stadard deviatios are S = 6.69 ad S 3 = 5.45. We hesitate to assue coo variace, so copute df = 3.79. The t statistic coes to 0.70 ad the p-value is 0.49. Trasforatio. Oe solutio for the o-orality is to trasfor the observed data such that they becoe ore oral-lie. A coo proble is right sew, especially for data that is costraied to live i the positive half of the real lie. To correct right sew, oe ay use the log() or trasforatios, sice both ted to shri large values ad epad sall values. 5
Desity 0.00 0.0 0.04 0.06 0.08 0.0 Desity 0.00 0.0 0.04 0.06 0.08 0.0 0. 0.4 0 5 0 5 0 5 30 Fe (a) F e + 5 0 5 0 Fe3 (b) F e 3+ Stadard Noral Quatiles 0 Stadard Noral Quatiles 0 0 5 0 5 0 5 Fe Estiated Quatiles (c) F e + = o, F e 3+ =.0.5.0.5 3.0 log(fe) Estiated Quatiles (d) log(f e + ) = o, log(f e 3+ ) = Desity 0.0 0. 0.4 0.6 0.8 Desity 0.0 0. 0. 0.3 0.4 0.5 0.6.0.5.0.5 3.0 3.5 log(fe) (e) log(f e + ) 0.5.0.5.0.5 3.0 log(fe3) (f) log(f e 3+ ) Figure 4: Histogras ad Noral Probabililty Plots of Iro Data 6
The result of loggig the iro data is also show i Fig. 4. Much of the o-orality disappears, but soe curvature reais i the oral probability plots. It is liely that further goodess-of-fit tests will ot be sigificat. 7