# Meta-analysis of RR and OR calculated from 2x2 tables in R using metafor

## Background

My question concerns the calculation of risk ratios and odds ratios for meta-analysis using the metafor package. I know it looks long, but please bear with me, as it is a simple question. I've simply provided a lot of background information. First, copy/paste the below to make my example data.

# Load package
library(metafor)

# Create example_data
example_data <-
data.frame(
trial = c(1, 2, 3, 4, 5, 6),
author = c("Abers", "Baker", "Cook", "Dodds", "Eggers", "Fritz"),
year = c(2000, 2001, 2002, 2003, 2004, 2005),
tpos = c(437, NA, 51, 26, 468, 10),
tneg = c(49, NA, 1, 8, 83, 1),
cpos = c(50, 7, 6, 0, 36, 0),
cneg = c(33, 8, 0, 0, 19, 0)
)

# Show example_data
example_data
trial author year tpos tneg cpos cneg
1     1  Abers 2000  437   49   50   33
2     2  Baker 2001   NA   NA    7    8
3     3   Cook 2002   51    1    6    0
4     4  Dodds 2003   26    8    0    0
5     5 Eggers 2004  468   83   36   19
6     6  Fritz 2005   10    1    0    0


## More background

If I were to make a two-by-two table by hand for the first study, Abers, it would look as follows:

      pos  neg
pos  437   49
neg  50    33


The relative risk would be calculated by hand as follows:

RR = (437/(437 + 49)) / (50/(50 + 33)) = 1.49
log(RR) = 0.40


The odds ratio would be calculated by hand as follows:

OR = (437 * 33) / (50 * 49) = 5.89
log(OR) = 1.77


Here are the forest plots for log(RR) and log(OR). If you look at the first line in each plot, you can see that metafor produces the same values as I did by hand for the Abers study.  ## My question

Take a look at the line for Dodds on the plots. Where are these values for log(RR) and log(OR) coming from? As I see it, if I were to make a two-by-two table for the Dodds, it would look as follows:

      pos  neg
pos   26    8
neg    0    0


The relative risk would be calculated by hand as follows:

RR = (26/(26 + 8)) / (0/(0 + 0)) = Undefined! As you cannot divide by zero.
log(RR) = ?


The odds ratio would be calculated by hand as follows:

OR = (26 * 0) / (0 * 8) = Again, undefined!
log(OR) = ?


So how did the metafor package calculate a log(RR) of 0.41 and a log(OR) of 1.14 for the Dodds study? And more generally, for all of my studies with zero values (e.g., Cook, Dodds, and Fritz), can I even include any of them in my meta-analysis?

Quoting from the documentation (help(escalc)):
Cell entries with a zero count can be problematic, especially for the relative risk and the odds ratio. Adding a small constant to the cells of the 2x2 tables is a common solution to this problem. When to="only0" (the default), the value of add (the default is 1/2) is added to each cell of those 2x2 tables with at least one cell equal to 0. When to="all", the value of add is added to each cell of all 2x2 tables. When to="if0all", the value of add is added to each cell of all 2x2 tables, but only when there is at least one 2x2 table with a zero cell. Setting to="none" or add=0 has the same effect: No adjustment to the observed table frequencies is made. Depending on the outcome measure and the data, this may lead to division by zero inside of the function (when this occurs, the resulting value is recoded to NA). Also, studies where ai=ci=0 or bi=di=0 may be considered to be uninformative about the size of the effect and dropping such studies has sometimes been recommended (Higgins & Green, 2008). This can be done by setting drop00=TRUE. The counts for such studies will then be set to NA.
So, to make a long story short, escalc() added 1/2 to the cell counts before computing the log(RR) or the log(OR).
• If you only want the visual reminder, you could also set to="none", but then use options(na.action="na.pass") before creating the forest plot. See here for further details. Apr 13, 2014 at 13:18