Statistics for laboratory scientists II

Solutions for the homework problems for lecture 4

  1. Here is the R code for creating the observed table.

        mydata <- rbind( c(17, 259), c(7, 274), c(10, 264) )
    1. Code for the chi-square test.

          chi <- chisq.test(mydata)
          chi                                           # stat=4.98; P-value = 0.083
    2. For calculating the LRT statistic and corresponding P-value, we can use the expected counts given within the results of chisq.test().

          ex <- chi$expected                            # expected counts
          lrt <- 2 * sum( mydata * log(mydata/ex) )     # value = 4.88
          1 - pchisq(lrt, 2)                            # P-value = 0.087
    3. Perform Fisher's exact test using the built-in function, fisher.test().

          fisher.test(mydata)                           # P-value = 0.084
    4. Since the p-values are ~8%, we would conclude that there is some evidence for a difference in the survival rates for the three treatments, but it is not strong.


[ Main page | 4th term syllabus | R for Windows ]

Last modified: Fri Mar 31 09:24:59 EST 2006