Page 73 - Applied Statistics with R
P. 73

5.2. HYPOTHESIS TESTS IN R                                         73


                      c(mean(capt_crisp$weight) - qt(0.975, df = 8) * sd(capt_crisp$weight) / sqrt(9),
                        mean(capt_crisp$weight) + qt(0.975, df = 8) * sd(capt_crisp$weight) / sqrt(9))


                      ## [1] 15.70783 16.09217


                      5.2.3   Two Sample t-Test: Review

                                                          2
                                         2
                      Suppose    ∼ N(   ,    ) and    ∼ N(   ,    ).
                                                         
                                        
                                                  
                                 
                      Want to test    ∶    −    =    versus    ∶    −    ≠    .
                                         
                                    0
                                                 0
                                                                     
                                              
                                                                       0
                                                                
                                                          1
                      Assuming    is unknown, use the two-sample Student’s    test statistic:
                                                       
                                                   
                                                ( ̄ − ̄) −    0
                                                =           ∼      +  −2 ,
                                                         1
                                                     1
                                                    √ +    
                                                    
                                                       
                                                                    2
                                ∑           ∑                (   − 1)   + (   − 1)   2
                                                         2
                      where ̄ =     =1      , ̄ =    =1      , and    =            .
                              
                                          
                                                                     +    − 2
                      A 100(1 −   )% CI for    −    is given by
                                                  
                                             
                                                                  1
                                                                      1
                                        ( ̄ − ̄) ±      +  −2 (  /2) (   √ +     ) ,
                                               
                                           
                                                                
                                                                    
                      where      +  −2 (  /2) is the critical value such that    (   >      +  −2 (  /2)) =   /2.
                      5.2.4   Two Sample t-Test: Example
                                                                      2
                                                                                  2
                      Assume that the distributions of    and    are N(   ,    ) and N(   ,    ), respec-
                                                                               2
                                                                   1
                      tively. Given the    = 6 observations of   ,
                      x = c(70, 82, 78, 74, 94, 82)
                      n = length(x)
                      and the    = 8 observations of    ,
                      y = c(64, 72, 60, 76, 72, 80, 84, 68)
                      m = length(y)
                      we will test    ∶    =    versus    ∶    >    .
                                   0
                                      1
                                                    1
                                                        1
                                                             2
                                           2
                      First, note that we can calculate the sample means and standard deviations.
   68   69   70   71   72   73   74   75   76   77   78