effect_sizes: Generate effect size data frame from other data

Description Usage Arguments Details Value Examples

View source: R/esc.R

Description

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).

Usage

1
2
3
4
5
6
effect_sizes(
  data,
  ...,
  fun,
  es.type = c("d", "g", "or", "logit", "r", "f", "eta", "cox.or", "cox.log")
)

Arguments

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 data that holds the data values. See 'Examples'.

fun

Name of one of the esc-functions, as string, where arguments in ... are passed to. May either be the full function name (like "esc_t" or "esc_2x2") or the funcion name without the suffix "esc_" (like "t" or "2x2").

es.type

Type of effect size that should be returned.

"d"

returns standardized mean difference effect size d

"f"

returns effect size Cohen's f

"g"

returns adjusted standardized mean difference effect size Hedges' g

"or"

returns effect size as odds ratio

"cox.or"

returns effect size as Cox-odds ratio (see convert_d2or for details)

"logit"

returns effect size as log odds

"cox.log"

returns effect size as Cox-log odds (see convert_d2logit for details)

"r"

returns correlation effect size r

"eta"

returns effect size eta squared

Details

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').

Value

A data frame with the effect sizes computed for all data from data.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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")

# 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")


tmp <- 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")

# 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")

# 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")

esc documentation built on Dec. 4, 2019, 5:07 p.m.