escalc(measure, formula, ...)
## S3 method for class 'default':
escalc(measure, formula, ai, bi, ci, di, n1i, n2i,
m1i, m2i, sd1i, sd2i, xi, mi, ri, ni, data,
add=1/2, to="only0", vtype="LS", append=FALSE, ...)
## S3 method for class 'formula':
escalc(measure, formula, weights, data,
add=1/2, to="only0", vtype="LS", ...)data argument (if one has been specified) should be returned together with the effect sizes and sampling variances (default is FALSE).append=TRUE and a data frame was specified via the data argument, then yi and vi are append to this data frame.escalc function, the default and a formula interface. The two interfaces are described below.
measure is a character string specifying which outcome measure should be calculated (see below for the various options), arguments ai through ni are then used to supply the needed information to calculate the various measures (depending on the outcome measure, different arguments need to be supplied), and data can be used to specify a data frame containing the variables given to the previous arguments. The add and to arguments may be needed when dealing with 2x2 table data that contain cells with zeros. Finally, the vtype argument is used to specify how to calculate the sampling variance estimate (see below).
ai bi n1i
group 2 ci di n2i
} where ai, bi, ci, and di denote the cell frequencies and n1i and n2i the row totals. For example, in a set of randomized clinical trials, group 1 and group 2 may refer to the treatment and placebo/control group, with outcome 1 denoting some event of interest (e.g., remission) and outcome 2 its complement. In a set of case-control studies, group 1 and group 2 may refer to the group of cases and the group of controls, with outcome 1 denoting, for example, exposure to some risk factor and outcome 2 non-exposure. The 2x2 table may also be the result of cross-sectional (i.e., multinomial) sampling, so that none of the table margins (except the total sample size n1i+n2i) are fixed through the study design.
Depending on the type of design (sampling method), a meta-analysis of 2x2 table data can be based on one of several different outcome measures, including the odds ratio, the relative risk (also called risk ratio), the risk difference, and the arcsine transformed risk difference. The phi coefficient, Yule's Q, and Yule's Y are additional measures of association for 2x2 table data (but they may not be the most ideal choices for meta-analyses of such data). For these measures, one needs to supply either ai, bi, ci, and di or alternatively ai, ci, n1i, and n2i. The options for the measure argument are then:
"RR": Thelog relative riskis equal to the log of(ai/n1i)/(ci/n2i)."OR": Thelog odds ratiois equal to the log of(ai*di)/(bi*ci)."RD": Therisk differenceis equal to(ai/n1i)-(ci/n2i)."AS": Thearcsine transformed risk differenceis equal toasin(sqrt(ai/n1i)) -asin(sqrt(ci/n2i)). See Ruecker et al. (2009) for a discussion of this and other outcome measures for 2x2 table data."PETO": Thelog odds ratio estimated with Peto's method(see Yusuf et al., 1985) is equal to(ai-si*n1i/ni)/((si*ti*n1i*n2i)/(ni^2*(ni-1))), wheresi=ai+ci,ti=bi+di, andni=n1i+n2i. Note that this measure technically assumes that the true odds ratio is equal to 1 in all tables."PHI": Thephi coefficientis equal to(ai*di-bi*ci)/sqrt(n1i*n2i*si*ti), wheresi=ai+ciandti=bi+di."YUQ":Yule's Qis equal to(oi-1)/(oi+1), whereoiis the odds ratio."YUY":Yule's Yis equal to(sqrt(oi)-1)/(sqrt(oi)+1), whereoiis the odds ratio.to="all", the value of add is added to each cell of the 2x2 tables in all $k$ tables. When to="only0", the value of add is added to each cell of the 2x2 tables only in those tables with at least one cell equal to 0. When to="if0all", the value of add is added to each cell of the 2x2 tables in all $k$ tables, but only when there is at least one 2x2 table with a zero entry. 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 Inf value is recoded to NA).
}
m1i and m2i specify the means of the two groups, sd1i and sd2i the standard deviations of the scores in the two groups, and n1i and n2i the sample sizes of the two groups.
"MD": Theraw mean differenceis equal tom1i-m2i."SMD": Thestandardized mean differenceis equal to(m1i-m2i)/spi, wherespiis the pooled standard deviation of the two groups (which is calculated inside of the function). The standardized mean difference is automatically corrected for its slight positive bias within the function (see Hedges & Olkin, 1985). Whenvtype="LS", the sampling variances are calculated based on the large sample approximation. Alternatively, the unbiased estimates of the sampling variances can be obtained withvtype="UB".ri, the vector with the raw correlation coefficients, and ni, the corresponding sample sizes.
"COR": Theraw correlation coefficientis simply equal torias supplied to the function. Whenvtype="LS", the sampling variances are calculated based on the large sample approximation. Alternatively, an approximation to the unbiased estimates of the sampling variances can be obtained withvtype="UB"(see Hedges, 1989)."UCOR": Theunbiased estimate of the correlation coefficientis obtained by correcting the raw correlation coefficient for its slight negative bias (based on equation 2.7 in Olkin & Pratt, 1958). Again,vtype="LS"andvtype="UB"can be used to choose between the large sample approximation or approximately unbiased estimates of the sampling variances."ZCOR": Fisher's r-to-z transformation is a variance stabilizing transformation for correlation coefficients with the added benefit of also being a rather effective normalizing transformation (Fisher, 1921). TheFisher's r-to-z transformed correlation coefficientis equal to1/2*log((1+ri)/(1-ri)).xi and ni, denoting the number of individuals experiencing the event of interest and the total number of individuals, respectively. Instead of specifying ni, one can use mi to specify the number of individuals that do not experience the event of interest.
"PR": Theraw proportionis equal toxi/ni."PLN": Thelog transformed proportionis equal to the log ofxi/ni."PLO": Thelogit transformed proportionis equal to the log ofxi/(ni-xi)."PAS": The arcsine transformation is a variance stabilizing transformation for proportions and is equal toasin(sqrt(xi/ni))."PFT": Yet another variance stabilizing transformation for proportions was suggested by Freeman & Tukey (1950). TheFreeman-Tukey double arcsine transformed proportionis equal to1/2*(asin(sqrt(xi/(ni+1))) + asin(sqrt((xi+1)/(ni+1)))).to="all", the value of add is added to xi and mi in all $k$ studies. When to="only0", the value of add is added only for studies where the xi or mi is equal to 0. When to="if0all", the value of add is added in all $k$ studies, but only when there is at least one study with a zero value for xi or mi. Setting to="none" or add=0 again means that no adjustment to the observed values is made.
}
}
measure is a character string specifying which outcome measure should be calculated. The formula argument is then used to specify the data structure as a multipart formula together with the weights argument for the group sizes or cell frequencies. The data argument can be used to specify a data frame containing the variables in the formula and the weights variable. The add, to, and vtype arguments work as described above.
The formula argument takes the form outcome ~ group | study, where group is a factor specifying the group variable and study is a factor specifying the study factor.
group is a two-level factor specifying the rows of the tables and outcome is a two-level factor specifying the columns of the tables (the two possible outcomes). The weights argument is then used to specify the frequencies in the various cells.
}
group is a two-level factor specifying the group factor and the left-hand side of the formula is composed of two parts, with the first variable for the means and the second variable for the standard deviations (i.e., means + sds ~ group | study). The weights argument is then used to specify the sample sizes in the groups.
}
group is a one-level factor and outcome is used to specify the observed correlations. The weights argument is again used to specify the sample sizes.
}
group is a one-level factor and outcome is a two-level factor specifying the columns of the tables (the two possible outcomes). The weights argument is then used to specify the frequencies in the various cells.
}
}rma.uni, rma.mh, rma.peto### load BCG vaccine data
data(dat.bcg)
### calculate log relative risks and corresponding sampling variances
dat <- escalc(measure="RR", ai=tpos, bi=tneg, ci=cpos, di=cneg,
data=dat.bcg, append=TRUE)
dat
### using formula interface (first rearrange data into required format)
k <- length(dat.bcg$trial)
dat.fm <- data.frame(study=factor(rep(1:k, each=4)))
dat.fm$grp <- factor(rep(c("T","T","C","C"), k), levels=c("T", "C"))
dat.fm$out <- factor(rep(c("+","-","+","-"), k), levels=c("+", "-"))
dat.fm$freq <- with(dat.bcg, c(rbind(tpos, tneg, cpos, cneg)))
dat.fm
escalc(out ~ grp | study, weights=freq, data=dat.fm, measure="RR")Run the code above in your browser using DataLab