Sunday, October 7, 2012

epiR package

Q: I tried doing the examples at the back of the module and am getting the error message below. I installed EpiR so not sure what I'm doing wrong, as I think I'm following the instructions from the module??? Pg 28 and 29 of module 6.

> a <- 621
> b <- 440034
> c <- 117
> d <- 96531
> epi.2by2(a, b, c, d, method="case.control")
Error in c[i] : object of type 'builtin' is not subsettable

A: The issue appearing is that epiR does not accept input in this form, where if we assume a 2 x 2 contingency table with exposed/unexposed as our row and disease/healthy as our column with a and b being row 1, and c and d being row 2 (or a and c being column 1 and b, and d being column 2). Instead, epiR requires that the "data" be in the form of a matrix/table, so what we need to do is:

> a <- 621
> b <- 440034
> c <- 117
> d <- 96531
> data <- matrix(c(a, c, b, d), nrow = 2, ncol = 2)
> epi.2by2(data, method="case.control")

where the matrix looks like so:
          Disease +  Disease - 
Expose +  a          b         
Expose -  c          d
As a confirmation, the OR should be 1.16. Be cautious of how you order the data in the matrix. The current set up applies the data by going down the column, if you want to go by row you need to use the option, "BYROW=T".

No comments:

Post a Comment