This method computes any effect size from raw values from a data frame. Convenient method to compute multiple effect sizes at once, when the required information to calculate effects sizes are stored in a table (i.e. data frame).
effect_sizes( data, ..., fun, es.type = c("d", "g", "or", "logit", "r", "f", "eta", "cox.or", "cox.log") )
data | A data frame with columns that contain the values that are passed to one of the esc-functions. |
---|---|
... | Named arguments. The name (left-hand side) is the name of one of
esc functions' argument, the argument (right-hand side) is the
name of the column in |
fun | Name of one of the esc-functions, as string, where arguments
in |
es.type | Type of effect size that should be returned.
|
A data frame with the effect sizes computed for all data from data
.
This function rowwise iterates data
and calls the function named
in fun
for the values taken from each row of data
.
The column names in data
that contain the necessary values to compute
the effect sizes should be passed as unquoted value for the arguments.
The argument names should match those arguments for the esc-function
that should be called from within effect_sizes()
.
Example:
If you want to compute effect sizes from chi-squared values, you
would call esc_chisq()
. This function name is used for the
fun
-argument: fun = "esc_chisq"
. esc_chisq()
requires one of chisq
or p
as arguments, and totaln
.
Now data
must have columns with values for either chisq
or p
, and effect_sizes()
automatically selects the
first non-missing value from data
(see 'Examples').
tmp <- data.frame( tvalue = c(3.3, 2.9, 2.3), n = c(250, 200, 210), studyname = c("Study 1", "Study 2", "Study 3") ) effect_sizes(tmp, t = tvalue, totaln = n, study = studyname, fun = "esc_t")#> study es weight sample.size se var ci.lo #> 1 Study 1 0.4174207 61.16777 250 0.1278612 0.01634848 0.16681735 #> 2 Study 2 0.4101219 48.97040 200 0.1429003 0.02042050 0.13004246 #> 3 Study 3 0.3174302 51.84698 210 0.1388795 0.01928753 0.04523125 #> ci.hi measure #> 1 0.6680239 d #> 2 0.6902014 d #> 3 0.5896291 d# missing effect size results are dropped, # shorter function name, calls "esc_t()" tmp <- data.frame( tvalue = c(3.3, 2.9, NA, 2.3), n = c(250, 200, 210, 210), studyname = c("Study 1", "Study 2", NA, "Study 4") ) effect_sizes(tmp, t = tvalue, totaln = n, study = studyname, fun = "t")#> Warning: Row(s) 3 in `data` had missing values and were removed.#> study es weight sample.size se var ci.lo #> 1 Study 1 0.4174207 61.16777 250 0.1278612 0.01634848 0.16681735 #> 2 Study 2 0.4101219 48.97040 200 0.1429003 0.02042050 0.13004246 #> 3 Study 4 0.3174302 51.84698 210 0.1388795 0.01928753 0.04523125 #> ci.hi measure #> 1 0.6680239 d #> 2 0.6902014 d #> 3 0.5896291 dtmp <- data.frame( coefficient = c(0.4, 0.2, 0.6), se = c(.15, .1, .2), treat = c(50, 60, 50), cntrl = c(45, 70, 40), author = c("Smith 2000", "Smith 2010 2", "Smith 2012") ) effect_sizes(tmp, beta = coefficient, sdy = se, grp1n = treat, grp2n = cntrl, study = author, fun = "esc_beta", es.type = "or")#> study es weight sample.size se var ci.lo #> 1 Smith 2000 4.800087 6.585180 95 0.3896872 0.1518561 2.236386 #> 2 Smith 2010 2 2.089544 9.622967 130 0.3223632 0.1039181 1.110850 #> 3 Smith 2012 14.985175 5.297840 90 0.4344608 0.1887562 6.395111 #> ci.hi measure #> 1 10.302709 or #> 2 3.930499 or #> 3 35.113613 or# the "esc_chisq" function requires *either* the chisq-argument *or* # the pval-argument. If at least one of these values is present, # effect size can be calculated. You can specify both arguments, # and the first non-missing required value from "data" is taken. tmp <- data.frame( chisqquared = c(NA, NA, 3.3, NA, 2.9), pval = c(.003, .05, NA, .12, NA), n = c(250, 200, 210, 150, 180), studyname = c("Study 1", "Study 2", "Study 3", "Study 4", "Study 5") ) effect_sizes(tmp, chisq = chisqquared, p = pval, totaln = n, study = studyname, fun = "esc_chisq")#> study es weight sample.size se var ci.lo #> 1 Study 1 0.3821850 60.29813 250 0.1287799 0.01658426 1.297810e-01 #> 2 Study 2 0.2798817 49.03964 200 0.1427994 0.02039167 5.551115e-17 #> 3 Study 3 0.2527067 51.67500 210 0.1391105 0.01935172 -1.994479e-02 #> 4 Study 4 0.2559643 36.89567 150 0.1646313 0.02710345 -6.670700e-02 #> 5 Study 5 0.2559291 44.27500 180 0.1502868 0.02258611 -3.862751e-02 #> ci.hi measure #> 1 0.6345889 d #> 2 0.5597634 d #> 3 0.5253582 d #> 4 0.5786357 d #> 5 0.5504858 d# if all required information are missing, data will be removed tmp <- data.frame( chisqquared = c(NA, NA, 3.3, NA, NA), pval = c(.003, .05, NA, .12, NA), n = c(250, 200, 210, 150, 180), studyname = c("Study 1", "Study 2", "Study 3", "Study 4", "Study 5") ) effect_sizes(tmp, chisq = chisqquared, p = pval, totaln = n, study = studyname, fun = "chisq")#> Warning: Row(s) 5 in `data` had missing values and were removed.#> study es weight sample.size se var ci.lo #> 1 Study 1 0.3821850 60.29813 250 0.1287799 0.01658426 1.297810e-01 #> 2 Study 2 0.2798817 49.03964 200 0.1427994 0.02039167 5.551115e-17 #> 3 Study 3 0.2527067 51.67500 210 0.1391105 0.01935172 -1.994479e-02 #> 4 Study 4 0.2559643 36.89567 150 0.1646313 0.02710345 -6.670700e-02 #> ci.hi measure #> 1 0.6345889 d #> 2 0.5597634 d #> 3 0.5253582 d #> 4 0.5786357 d