conv.delta.Rd
Function to transform observed effect sizes or outcomes and their sampling variances using the delta method.
conv.delta(yi, vi, ni, data, include, transf, var.names, append=TRUE, replace="ifna", ...)
vector with the observed effect sizes or outcomes.
vector with the corresponding sampling variances.
vector with the total sample sizes of the studies.
optional data frame containing the variables given to the arguments above.
optional (logical or numeric) vector to specify the subset of studies for which the transformation should be carried out.
a function which should be used for the transformation.
character vector with two elements to specify the name of the variable for the transformed effect sizes or outcomes and the name of the variable for the corresponding sampling variances (if data
is an object of class "escalc"
, the var.names
are taken from the object; otherwise the defaults are "yi"
and "vi"
).
logical to specify whether the data frame provided via the data
argument should be returned together with the estimated values (the default is TRUE
).
character string or logical to specify how values in var.names
should be replaced (only relevant when using the data
argument and if variables in var.names
already exist in the data frame). See the ‘Value’ section for more details.
other arguments for the transformation function.
The escalc
function can be used to compute a wide variety of effect sizes or ‘outcome measures’. In some cases, it may be necessary to transform one type of measure to another. The present function provides a general method for doing so via the delta method (e.g., van der Vaart, 1998), which briefly works as follows.
Let \(y_i\) denote the observed effect size or outcome for a particular study and \(v_i\) the corresponding sampling variance. Then \(f(y_i)\) will be the transformed effect size or outcome, where \(f(\cdot)\) is the function specified via the transf
argument. The sampling variance of the transformed effect size or outcome is then computed with \(v_i \times f'(y_i)^2\), where \(f'(y_i)\) denotes the derivative of \(f(\cdot)\) evaluated at \(y_i\). The present function computes the derivative numerically using the grad
function from the numDeriv
package.
The value of the observed effect size or outcome should be the first argument of the function specified via transf
. The function can have additional arguments, which can be specified via the ... argument. However, due to the manner in which these additional arguments are evaluated, they cannot have names that match one of the arguments of the grad
function (an error will be issued if such a naming clash is detected).
Optionally, one can use the ni
argument to supply the total sample sizes of the studies. This has no relevance for the calculations done by the present function, but some other functions may use this information (e.g., when drawing a funnel plot with the funnel
function and one adjusts the yaxis
argument to one of the options that puts the sample sizes or some transformation thereof on the y-axis).
If the data
argument was not specified or append=FALSE
, a data frame of class c("escalc","data.frame")
with two variables called var.names[1]
(by default "yi"
) and var.names[2]
(by default "vi"
) with the transformed observed effect sizes or outcomes and the corresponding sampling variances (computed as described above).
If data
was specified and append=TRUE
, then the original data frame is returned. If var.names[1]
is a variable in data
and replace="ifna"
(or replace=FALSE
), then only missing values in this variable are replaced with the transformed observed effect sizes or outcomes (where possible) and otherwise a new variable called var.names[1]
is added to the data frame. Similarly, if var.names[2]
is a variable in data
and replace="ifna"
(or replace=FALSE
), then only missing values in this variable are replaced with the sampling variances calculated as described above (where possible) and otherwise a new variable called var.names[2]
is added to the data frame.
If replace="all"
(or replace=TRUE
), then all values in var.names[1]
and var.names[2]
are replaced, even for cases where the value in var.names[1]
and var.names[2]
is not missing.
van der Vaart, A. W. (1998). Asymptotic statistics. Cambridge, UK: Cambridge University Press.
Viechtbauer, W. (2010). Conducting meta-analyses in R with the metafor package. Journal of Statistical Software, 36(3), 1–48. https://doi.org/10.18637/jss.v036.i03
escalc
for a function to compute various effect size measures and deltamethod
for a function to apply the multivariate delta method to a set of estimates.
############################################################################
### the following examples illustrate that the use of the delta method (with numeric derivatives)
### yields essentially identical results as the analytic calculations that are done by escalc()
### compute logit transformed proportions and corresponding sampling variances for two studies
escalc(measure="PLO", xi=c(5,12), ni=c(40,80))
#>
#> yi vi
#> 1 -1.9459 0.2286
#> 2 -1.7346 0.0980
#>
### compute raw proportions and corresponding sampling variances for the two studies
dat <- escalc(measure="PR", xi=c(5,12), ni=c(40,80))
dat
#>
#> yi vi
#> 1 0.1250 0.0027
#> 2 0.1500 0.0016
#>
### apply the logit transformation (note: this yields the same values as above with measure="PLO")
conv.delta(dat$yi, dat$vi, transf=transf.logit)
#>
#> yi vi
#> 1 -1.9459 0.2286
#> 2 -1.7346 0.0980
#>
### using the 'data' argument
conv.delta(yi, vi, data=dat, transf=transf.logit, var.names=c("yi.t","vi.t"))
#>
#> yi vi yi.t vi.t
#> 1 0.1250 0.0027 -1.9459 0.2286
#> 2 0.1500 0.0016 -1.7346 0.0980
#>
### or replace the existing 'yi' and 'vi' values
conv.delta(yi, vi, data=dat, transf=transf.logit, replace="all")
#>
#> yi vi
#> 1 -1.9459 0.2286
#> 2 -1.7346 0.0980
#>
######################################
### use escalc() with measure D2ORN which transforms standardized mean differences (computed
### from means and standard deviations) into the corresponding log odds ratios
escalc(measure="D2ORN", m1i=m1i, sd1i=sd1i, n1i=n1i,
m2i=m2i, sd2i=sd2i, n2i=n2i, data=dat.normand1999)
#>
#> study source n1i m1i sd1i n2i m2i sd2i yi vi
#> 1 1 Edinburgh 155 55 47 156 75 64 -0.5875 0.0356
#> 2 2 Orpington-Mild 31 27 7 32 29 4 -0.5813 0.1756
#> 3 3 Orpington-Moderate 75 64 17 71 119 29 -3.8441 0.1253
#> 4 4 Orpington-Severe 18 66 20 18 137 48 -3.1861 0.4435
#> 5 5 Montreal-Home 8 14 8 13 18 11 -0.6600 0.5601
#> 6 6 Montreal-Transfer 57 19 7 52 18 4 0.2861 0.1005
#> 7 7 Newcastle 34 52 45 33 41 34 0.4541 0.1641
#> 8 8 Umea 110 21 16 183 31 27 -0.7024 0.0405
#> 9 9 Uppsala 60 30 27 52 23 20 0.4811 0.0988
#>
### use escalc() to compute standardized mean differences (without the usual bias correction) and
### then apply the same transformation to the standardized mean differences
dat <- escalc(measure="SMD", m1i=m1i, sd1i=sd1i, n1i=n1i,
m2i=m2i, sd2i=sd2i, n2i=n2i, data=dat.normand1999, correct=FALSE)
conv.delta(yi, vi, data=dat, transf=transf.dtolnor.norm, replace="all")
#>
#> study source n1i m1i sd1i n2i m2i sd2i yi vi
#> 1 1 Edinburgh 155 55 47 156 75 64 -0.5875 0.0356
#> 2 2 Orpington-Mild 31 27 7 32 29 4 -0.5813 0.1756
#> 3 3 Orpington-Moderate 75 64 17 71 119 29 -3.8441 0.1253
#> 4 4 Orpington-Severe 18 66 20 18 137 48 -3.1861 0.4435
#> 5 5 Montreal-Home 8 14 8 13 18 11 -0.6600 0.5601
#> 6 6 Montreal-Transfer 57 19 7 52 18 4 0.2861 0.1005
#> 7 7 Newcastle 34 52 45 33 41 34 0.4541 0.1641
#> 8 8 Umea 110 21 16 183 31 27 -0.7024 0.0405
#> 9 9 Uppsala 60 30 27 52 23 20 0.4811 0.0988
#>
######################################
### an example where the transformation function takes additional arguments
### use escalc() with measure RPB which transforms standardized mean differences (computed
### from means and standard deviations) into the corresponding point-biserial correlations
escalc(measure="RPB", m1i=m1i, sd1i=sd1i, n1i=n1i,
m2i=m2i, sd2i=sd2i, n2i=n2i, data=dat.normand1999)
#>
#> study source n1i m1i sd1i n2i m2i sd2i yi vi
#> 1 1 Edinburgh 155 55 47 156 75 64 -0.1758 0.0030
#> 2 2 Orpington-Mild 31 27 7 32 29 4 -0.1762 0.0151
#> 3 3 Orpington-Moderate 75 64 17 71 119 29 -0.7609 0.0009
#> 4 4 Orpington-Severe 18 66 20 18 137 48 -0.7048 0.0055
#> 5 5 Montreal-Home 8 14 8 13 18 11 -0.2001 0.0474
#> 6 6 Montreal-Transfer 57 19 7 52 18 4 0.0871 0.0092
#> 7 7 Newcastle 34 52 45 33 41 34 0.1384 0.0147
#> 8 8 Umea 110 21 16 183 31 27 -0.2026 0.0031
#> 9 9 Uppsala 60 30 27 52 23 20 0.1452 0.0086
#>
### use escalc() to compute standardized mean differences (without the usual bias correction) and
### then apply the same transformation to the standardized mean differences
dat <- escalc(measure="SMD", m1i=m1i, sd1i=sd1i, n1i=n1i,
m2i=m2i, sd2i=sd2i, n2i=n2i, data=dat.normand1999, correct=FALSE)
conv.delta(yi, vi, data=dat, transf=transf.dtorpb, n1i=n1i, n2i=n2i, replace="all")
#>
#> study source n1i m1i sd1i n2i m2i sd2i yi vi
#> 1 1 Edinburgh 155 55 47 156 75 64 -0.1758 0.0030
#> 2 2 Orpington-Mild 31 27 7 32 29 4 -0.1762 0.0151
#> 3 3 Orpington-Moderate 75 64 17 71 119 29 -0.7609 0.0009
#> 4 4 Orpington-Severe 18 66 20 18 137 48 -0.7048 0.0055
#> 5 5 Montreal-Home 8 14 8 13 18 11 -0.2001 0.0474
#> 6 6 Montreal-Transfer 57 19 7 52 18 4 0.0871 0.0092
#> 7 7 Newcastle 34 52 45 33 41 34 0.1384 0.0147
#> 8 8 Umea 110 21 16 183 31 27 -0.2026 0.0031
#> 9 9 Uppsala 60 30 27 52 23 20 0.1452 0.0086
#>
############################################################################
### a more elaborate example showing how this function could be used in the data
### preparation steps for a meta-analysis of standardized mean differences (SMDs)
dat <- data.frame(study=1:6,
m1i=c(2.03,NA,NA,NA,NA,NA), sd1i=c(0.95,NA,NA,NA,NA,NA), n1i=c(32,95,145,NA,NA,NA),
m2i=c(1.25,NA,NA,NA,NA,NA), sd2i=c(1.04,NA,NA,NA,NA,NA), n2i=c(30,99,155,NA,NA,NA),
tval=c(NA,2.12,NA,NA,NA,NA), dval=c(NA,NA,0.37,NA,NA,NA),
ai=c(NA,NA,NA,26,NA,NA), bi=c(NA,NA,NA,58,NA,NA),
ci=c(NA,NA,NA,11,NA,NA), di=c(NA,NA,NA,74,NA,NA),
or=c(NA,NA,NA,NA,2.56,NA), lower=c(NA,NA,NA,NA,1.23,NA), upper=c(NA,NA,NA,NA,5.30,NA),
corr=c(NA,NA,NA,NA,NA,.32), ntot=c(NA,NA,NA,NA,NA,86))
dat
#> study m1i sd1i n1i m2i sd2i n2i tval dval ai bi ci di or lower upper corr ntot
#> 1 1 2.03 0.95 32 1.25 1.04 30 NA NA NA NA NA NA NA NA NA NA NA
#> 2 2 NA NA 95 NA NA 99 2.12 NA NA NA NA NA NA NA NA NA NA
#> 3 3 NA NA 145 NA NA 155 NA 0.37 NA NA NA NA NA NA NA NA NA
#> 4 4 NA NA NA NA NA NA NA NA 26 58 11 74 NA NA NA NA NA
#> 5 5 NA NA NA NA NA NA NA NA NA NA NA NA 2.56 1.23 5.3 NA NA
#> 6 6 NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA 0.32 86
### study types:
### 1) reports means and SDs so that the SMD can be directly calculated
### 2) reports the t-statistic from an independent samples t-test (and group sizes)
### 3) reports the standardized mean difference directly (and group sizes)
### 4) dichotomized the continuous dependent variable and reports the resulting 2x2 table
### 5) dichotomized the continuous dependent variable and reports an odds ratio with 95% CI
### 6) treated the group variable continuously and reports a Pearson product-moment correlation
### use escalc() to directly compute the SMD and its variance for studies 1, 2, and 3
dat <- escalc(measure="SMD", m1i=m1i, sd1i=sd1i, n1i=n1i,
m2i=m2i, sd2i=sd2i, n2i=n2i, ti=tval, di=dval, data=dat)
dat
#>
#> study m1i sd1i n1i m2i sd2i n2i tval dval ai bi ci di or lower upper corr ntot yi vi
#> 1 1 2.03 0.95 32 1.25 1.04 30 NA NA NA NA NA NA NA NA NA NA NA 0.7744 0.0694
#> 2 2 NA NA 95 NA NA 99 2.12 NA NA NA NA NA NA NA NA NA NA 0.3033 0.0209
#> 3 3 NA NA 145 NA NA 155 NA 0.37 NA NA NA NA NA NA NA NA NA 0.3691 0.0136
#> 4 4 NA NA NA NA NA NA NA NA 26 58 11 74 NA NA NA NA NA NA NA
#> 5 5 NA NA NA NA NA NA NA NA NA NA NA NA 2.56 1.23 5.3 NA NA NA NA
#> 6 6 NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA 0.32 86 NA NA
#>
### use escalc() with measure OR2DN to compute the SMD value for study 4
dat <- escalc(measure="OR2DN", ai=ai, bi=bi, ci=ci, di=di, data=dat, replace=FALSE)
dat
#>
#> study m1i sd1i n1i m2i sd2i n2i tval dval ai bi ci di or lower upper corr ntot yi vi
#> 1 1 2.03 0.95 32 1.25 1.04 30 NA NA NA NA NA NA NA NA NA NA NA 0.7744 0.0694
#> 2 2 NA NA 95 NA NA 99 2.12 NA NA NA NA NA NA NA NA NA NA 0.3033 0.0209
#> 3 3 NA NA 145 NA NA 155 NA 0.37 NA NA NA NA NA NA NA NA NA 0.3691 0.0136
#> 4 4 NA NA NA NA NA NA NA NA 26 58 11 74 NA NA NA NA NA 0.6690 0.0588
#> 5 5 NA NA NA NA NA NA NA NA NA NA NA NA 2.56 1.23 5.3 NA NA NA NA
#> 6 6 NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA 0.32 86 NA NA
#>
### use conv.wald() to convert the OR and CI into the log odds ratio and its variance for study 5
dat <- conv.wald(out=or, ci.lb=lower, ci.ub=upper, data=dat,
transf=log, var.names=c("lnor","vlnor"))
dat
#>
#> study m1i sd1i n1i m2i sd2i n2i tval dval ai bi ci di or lower upper corr ntot yi vi
#> 1 1 2.03 0.95 32 1.25 1.04 30 NA NA NA NA NA NA NA NA NA NA NA 0.7744 0.0694
#> 2 2 NA NA 95 NA NA 99 2.12 NA NA NA NA NA NA NA NA NA NA 0.3033 0.0209
#> 3 3 NA NA 145 NA NA 155 NA 0.37 NA NA NA NA NA NA NA NA NA 0.3691 0.0136
#> 4 4 NA NA NA NA NA NA NA NA 26 58 11 74 NA NA NA NA NA 0.6690 0.0588
#> 5 5 NA NA NA NA NA NA NA NA NA NA NA NA 2.56 1.23 5.3 NA NA NA NA
#> 6 6 NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA 0.32 86 NA NA
#> lnor vlnor
#> 1 NA NA
#> 2 NA NA
#> 3 NA NA
#> 4 NA NA
#> 5 0.9400 0.1389
#> 6 NA NA
#>
### use conv.delta() to transform the log odds ratio into the SMD value for study 5
dat <- conv.delta(lnor, vlnor, data=dat,
transf=transf.lnortod.norm, var.names=c("yi","vi"))
dat
#>
#> study m1i sd1i n1i m2i sd2i n2i tval dval ai bi ci di or lower upper corr ntot yi vi
#> 1 1 2.03 0.95 32 1.25 1.04 30 NA NA NA NA NA NA NA NA NA NA NA 0.7744 0.0694
#> 2 2 NA NA 95 NA NA 99 2.12 NA NA NA NA NA NA NA NA NA NA 0.3033 0.0209
#> 3 3 NA NA 145 NA NA 155 NA 0.37 NA NA NA NA NA NA NA NA NA 0.3691 0.0136
#> 4 4 NA NA NA NA NA NA NA NA 26 58 11 74 NA NA NA NA NA 0.6690 0.0588
#> 5 5 NA NA NA NA NA NA NA NA NA NA NA NA 2.56 1.23 5.3 NA NA 0.5697 0.0510
#> 6 6 NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA 0.32 86 NA NA
#> lnor vlnor
#> 1 NA NA
#> 2 NA NA
#> 3 NA NA
#> 4 NA NA
#> 5 0.9400 0.1389
#> 6 NA NA
#>
### remove the lnor and vlnor variables (no longer needed)
dat$lnor <- NULL
dat$vlnor <- NULL
### use escalc() with measure COR to compute the sampling variance of ri for study 6
dat <- escalc(measure="COR", ri=corr, ni=ntot, data=dat, var.names=c("ri","vri"))
dat
#>
#> study m1i sd1i n1i m2i sd2i n2i tval dval ai bi ci di or lower upper corr ntot yi vi
#> 1 1 2.03 0.95 32 1.25 1.04 30 NA NA NA NA NA NA NA NA NA NA NA 0.7744 0.0694
#> 2 2 NA NA 95 NA NA 99 2.12 NA NA NA NA NA NA NA NA NA NA 0.3033 0.0209
#> 3 3 NA NA 145 NA NA 155 NA 0.37 NA NA NA NA NA NA NA NA NA 0.3691 0.0136
#> 4 4 NA NA NA NA NA NA NA NA 26 58 11 74 NA NA NA NA NA 0.6690 0.0588
#> 5 5 NA NA NA NA NA NA NA NA NA NA NA NA 2.56 1.23 5.3 NA NA 0.5697 0.0510
#> 6 6 NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA 0.32 86 NA NA
#> ri vri
#> 1 NA NA
#> 2 NA NA
#> 3 NA NA
#> 4 NA NA
#> 5 NA NA
#> 6 0.3200 0.0095
#>
### use conv.delta() to transform the correlation into the SMD value for study 6
dat <- conv.delta(ri, vri, data=dat, transf=transf.rtod, var.names=c("yi","vi"))
dat
#>
#> study m1i sd1i n1i m2i sd2i n2i tval dval ai bi ci di or lower upper corr ntot yi vi
#> 1 1 2.03 0.95 32 1.25 1.04 30 NA NA NA NA NA NA NA NA NA NA NA 0.7744 0.0694
#> 2 2 NA NA 95 NA NA 99 2.12 NA NA NA NA NA NA NA NA NA NA 0.3033 0.0209
#> 3 3 NA NA 145 NA NA 155 NA 0.37 NA NA NA NA NA NA NA NA NA 0.3691 0.0136
#> 4 4 NA NA NA NA NA NA NA NA 26 58 11 74 NA NA NA NA NA 0.6690 0.0588
#> 5 5 NA NA NA NA NA NA NA NA NA NA NA NA 2.56 1.23 5.3 NA NA 0.5697 0.0510
#> 6 6 NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA 0.32 86 0.5282 0.0295
#> ri vri
#> 1 NA NA
#> 2 NA NA
#> 3 NA NA
#> 4 NA NA
#> 5 NA NA
#> 6 0.3200 0.0095
#>
### remove the ri and vri variables (no longer needed)
dat$ri <- NULL
dat$vri <- NULL
### now variable 'yi' is complete with the SMD values for all studies
dat
#>
#> study m1i sd1i n1i m2i sd2i n2i tval dval ai bi ci di or lower upper corr ntot yi vi
#> 1 1 2.03 0.95 32 1.25 1.04 30 NA NA NA NA NA NA NA NA NA NA NA 0.7744 0.0694
#> 2 2 NA NA 95 NA NA 99 2.12 NA NA NA NA NA NA NA NA NA NA 0.3033 0.0209
#> 3 3 NA NA 145 NA NA 155 NA 0.37 NA NA NA NA NA NA NA NA NA 0.3691 0.0136
#> 4 4 NA NA NA NA NA NA NA NA 26 58 11 74 NA NA NA NA NA 0.6690 0.0588
#> 5 5 NA NA NA NA NA NA NA NA NA NA NA NA 2.56 1.23 5.3 NA NA 0.5697 0.0510
#> 6 6 NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA 0.32 86 0.5282 0.0295
#>
### fit an equal-effects model to the SMD values
rma(yi, vi, data=dat, method="EE")
#>
#> Equal-Effects Model (k = 6)
#>
#> I^2 (total heterogeneity / total variability): 0.00%
#> H^2 (total variability / sampling variability): 0.87
#>
#> Test for Heterogeneity:
#> Q(df = 5) = 4.3327, p-val = 0.5026
#>
#> Model Results:
#>
#> estimate se zval pval ci.lb ci.ub
#> 0.4519 0.0696 6.4933 <.0001 0.3155 0.5883 ***
#>
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
############################################################################
### a more elaborate example showing how this function could be used in the data
### preparation steps for a meta-analysis of correlation coefficients
dat <- data.frame(study=1:6,
ri=c(.42,NA,NA,NA,NA,NA),
tval=c(NA,2.85,NA,NA,NA,NA),
phi=c(NA,NA,NA,0.27,NA,NA),
ni=c(93,182,NA,112,NA,NA),
ai=c(NA,NA,NA,NA,61,NA), bi=c(NA,NA,NA,NA,36,NA),
ci=c(NA,NA,NA,NA,39,NA), di=c(NA,NA,NA,NA,57,NA),
or=c(NA,NA,NA,NA,NA,1.86), lower=c(NA,NA,NA,NA,NA,1.12), upper=c(NA,NA,NA,NA,NA,3.10),
m1i=c(NA,NA,54.1,NA,NA,NA), sd1i=c(NA,NA,5.79,NA,NA,NA), n1i=c(NA,NA,66,75,NA,NA),
m2i=c(NA,NA,51.7,NA,NA,NA), sd2i=c(NA,NA,6.23,NA,NA,NA), n2i=c(NA,NA,65,88,NA,NA))
dat
#> study ri tval phi ni ai bi ci di or lower upper m1i sd1i n1i m2i sd2i n2i
#> 1 1 0.42 NA NA 93 NA NA NA NA NA NA NA NA NA NA NA NA NA
#> 2 2 NA 2.85 NA 182 NA NA NA NA NA NA NA NA NA NA NA NA NA
#> 3 3 NA NA NA NA NA NA NA NA NA NA NA 54.1 5.79 66 51.7 6.23 65
#> 4 4 NA NA 0.27 112 NA NA NA NA NA NA NA NA NA 75 NA NA 88
#> 5 5 NA NA NA NA 61 36 39 57 NA NA NA NA NA NA NA NA NA
#> 6 6 NA NA NA NA NA NA NA NA 1.86 1.12 3.1 NA NA NA NA NA NA
### study types:
### 1) reports the correlation coefficient directly
### 2) reports the t-statistic from a t-test of H0: rho = 0
### 3) dichotomized one variable and reports means and SDs for the two corresponding groups
### 4) reports the phi coefficient, marginal counts, and total sample size
### 5) dichotomized both variables and reports the resulting 2x2 table
### 6) dichotomized both variables and reports an odds ratio with 95% CI
### use escalc() to directly compute the correlation and its variance for studies 1 and 2
dat <- escalc(measure="COR", ri=ri, ni=ni, ti=tval, data=dat)
dat
#>
#> study ri tval phi ni ai bi ci di or lower upper m1i sd1i n1i m2i sd2i n2i yi vi
#> 1 1 0.42 NA NA 93 NA NA NA NA NA NA NA NA NA NA NA NA NA 0.4200 0.0074
#> 2 2 NA 2.85 NA 182 NA NA NA NA NA NA NA NA NA NA NA NA NA 0.2078 0.0051
#> 3 3 NA NA NA NA NA NA NA NA NA NA NA 54.1 5.79 66 51.7 6.23 65 NA NA
#> 4 4 NA NA 0.27 112 NA NA NA NA NA NA NA NA NA 75 NA NA 88 NA NA
#> 5 5 NA NA NA NA 61 36 39 57 NA NA NA NA NA NA NA NA NA NA NA
#> 6 6 NA NA NA NA NA NA NA NA 1.86 1.12 3.1 NA NA NA NA NA NA NA NA
#>
### use escalc() with measure RBIS to compute the biserial correlation for study 3
dat <- escalc(measure="RBIS", m1i=m1i, sd1i=sd1i, n1i=n1i,
m2i=m2i, sd2i=sd2i, n2i=n2i, data=dat, replace=FALSE)
dat
#>
#> study ri tval phi ni ai bi ci di or lower upper m1i sd1i n1i m2i sd2i n2i yi vi
#> 1 1 0.42 NA NA 93 NA NA NA NA NA NA NA NA NA NA NA NA NA 0.4200 0.0074
#> 2 2 NA 2.85 NA 182 NA NA NA NA NA NA NA NA NA NA NA NA NA 0.2078 0.0051
#> 3 3 NA NA NA NA NA NA NA NA NA NA NA 54.1 5.79 66 51.7 6.23 65 0.2471 0.0109
#> 4 4 NA NA 0.27 112 NA NA NA NA NA NA NA NA NA 75 NA NA 88 NA NA
#> 5 5 NA NA NA NA 61 36 39 57 NA NA NA NA NA NA NA NA NA NA NA
#> 6 6 NA NA NA NA NA NA NA NA 1.86 1.12 3.1 NA NA NA NA NA NA NA NA
#>
### use conv.2x2() to reconstruct the 2x2 table for study 4
dat <- conv.2x2(ri=phi, ni=ni, n1i=n1i, n2i=n2i, data=dat)
dat
#>
#> study ri tval phi ni ai bi ci di or lower upper m1i sd1i n1i m2i sd2i n2i yi vi
#> 1 1 0.42 NA NA 93 NA NA NA NA NA NA NA NA NA NA NA NA NA 0.4200 0.0074
#> 2 2 NA 2.85 NA 182 NA NA NA NA NA NA NA NA NA NA NA NA NA 0.2078 0.0051
#> 3 3 NA NA NA NA NA NA NA NA NA NA NA 54.1 5.79 66 51.7 6.23 65 0.2471 0.0109
#> 4 4 NA NA 0.27 112 65 10 23 14 NA NA NA NA NA 75 NA NA 88 NA NA
#> 5 5 NA NA NA NA 61 36 39 57 NA NA NA NA NA NA NA NA NA NA NA
#> 6 6 NA NA NA NA NA NA NA NA 1.86 1.12 3.1 NA NA NA NA NA NA NA NA
#>
### use escalc() with measure RTET to compute the tetrachoric correlation for studies 4 and 5
dat <- escalc(measure="RTET", ai=ai, bi=bi, ci=ci, di=di, data=dat, replace=FALSE)
dat
#>
#> study ri tval phi ni ai bi ci di or lower upper m1i sd1i n1i m2i sd2i n2i yi vi
#> 1 1 0.42 NA NA 93 NA NA NA NA NA NA NA NA NA NA NA NA NA 0.4200 0.0074
#> 2 2 NA 2.85 NA 182 NA NA NA NA NA NA NA NA NA NA NA NA NA 0.2078 0.0051
#> 3 3 NA NA NA NA NA NA NA NA NA NA NA 54.1 5.79 66 51.7 6.23 65 0.2471 0.0109
#> 4 4 NA NA 0.27 112 65 10 23 14 NA NA NA NA NA 75 NA NA 88 0.4654 0.0203
#> 5 5 NA NA NA NA 61 36 39 57 NA NA NA NA NA NA NA NA NA 0.3429 0.0107
#> 6 6 NA NA NA NA NA NA NA NA 1.86 1.12 3.1 NA NA NA NA NA NA NA NA
#>
### use conv.wald() to convert the OR and CI into the log odds ratio and its variance for study 6
dat <- conv.wald(out=or, ci.lb=lower, ci.ub=upper, data=dat,
transf=log, var.names=c("lnor","vlnor"))
dat
#>
#> study ri tval phi ni ai bi ci di or lower upper m1i sd1i n1i m2i sd2i n2i yi vi
#> 1 1 0.42 NA NA 93 NA NA NA NA NA NA NA NA NA NA NA NA NA 0.4200 0.0074
#> 2 2 NA 2.85 NA 182 NA NA NA NA NA NA NA NA NA NA NA NA NA 0.2078 0.0051
#> 3 3 NA NA NA NA NA NA NA NA NA NA NA 54.1 5.79 66 51.7 6.23 65 0.2471 0.0109
#> 4 4 NA NA 0.27 112 65 10 23 14 NA NA NA NA NA 75 NA NA 88 0.4654 0.0203
#> 5 5 NA NA NA NA 61 36 39 57 NA NA NA NA NA NA NA NA NA 0.3429 0.0107
#> 6 6 NA NA NA NA NA NA NA NA 1.86 1.12 3.1 NA NA NA NA NA NA NA NA
#> lnor vlnor
#> 1 NA NA
#> 2 NA NA
#> 3 NA NA
#> 4 NA NA
#> 5 NA NA
#> 6 0.6206 0.0675
#>
### use conv.delta() to estimate the tetrachoric correlation from the log odds ratio for study 6
dat <- conv.delta(lnor, vlnor, data=dat,
transf=transf.lnortortet.pearson, var.names=c("yi","vi"))
dat
#>
#> study ri tval phi ni ai bi ci di or lower upper m1i sd1i n1i m2i sd2i n2i yi vi
#> 1 1 0.42 NA NA 93 NA NA NA NA NA NA NA NA NA NA NA NA NA 0.4200 0.0074
#> 2 2 NA 2.85 NA 182 NA NA NA NA NA NA NA NA NA NA NA NA NA 0.2078 0.0051
#> 3 3 NA NA NA NA NA NA NA NA NA NA NA 54.1 5.79 66 51.7 6.23 65 0.2471 0.0109
#> 4 4 NA NA 0.27 112 65 10 23 14 NA NA NA NA NA 75 NA NA 88 0.4654 0.0203
#> 5 5 NA NA NA NA 61 36 39 57 NA NA NA NA NA NA NA NA NA 0.3429 0.0107
#> 6 6 NA NA NA NA NA NA NA NA 1.86 1.12 3.1 NA NA NA NA NA NA 0.2394 0.0093
#> lnor vlnor
#> 1 NA NA
#> 2 NA NA
#> 3 NA NA
#> 4 NA NA
#> 5 NA NA
#> 6 0.6206 0.0675
#>
### remove the lnor and vlnor variables (no longer needed)
dat$lnor <- NULL
dat$vlnor <- NULL
### now variable 'yi' is complete with the correlations for all studies
dat
#>
#> study ri tval phi ni ai bi ci di or lower upper m1i sd1i n1i m2i sd2i n2i yi vi
#> 1 1 0.42 NA NA 93 NA NA NA NA NA NA NA NA NA NA NA NA NA 0.4200 0.0074
#> 2 2 NA 2.85 NA 182 NA NA NA NA NA NA NA NA NA NA NA NA NA 0.2078 0.0051
#> 3 3 NA NA NA NA NA NA NA NA NA NA NA 54.1 5.79 66 51.7 6.23 65 0.2471 0.0109
#> 4 4 NA NA 0.27 112 65 10 23 14 NA NA NA NA NA 75 NA NA 88 0.4654 0.0203
#> 5 5 NA NA NA NA 61 36 39 57 NA NA NA NA NA NA NA NA NA 0.3429 0.0107
#> 6 6 NA NA NA NA NA NA NA NA 1.86 1.12 3.1 NA NA NA NA NA NA 0.2394 0.0093
#>
### fit an equal-effects model to the correlations
rma(yi, vi, data=dat, method="EE")
#>
#> Equal-Effects Model (k = 6)
#>
#> I^2 (total heterogeneity / total variability): 13.82%
#> H^2 (total variability / sampling variability): 1.16
#>
#> Test for Heterogeneity:
#> Q(df = 5) = 5.8020, p-val = 0.3260
#>
#> Model Results:
#>
#> estimate se zval pval ci.lb ci.ub
#> 0.2984 0.0385 7.7476 <.0001 0.2229 0.3738 ***
#>
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
############################################################################