calculateEffectSizes: Calculate effect sizes

View source: R/calculateEffectSizes.R

calculateEffectSizesR Documentation

Calculate effect sizes

Description

This is a function to calculate effect sizes of meta-analysis data created by expandMultiarmTrials.

Usage

calculateEffectSizes(data,
       comp.id.indicator = "id",
       trt.indicator = "trt",
       funcs = list(meanSD = meanSD,
                    binaryES = binaryES,
                    changeES = changeES),
       include.switched.arms = FALSE,
       change.sign = NULL,
       data.format = NULL)

Arguments

data

Meta-analysis data set of class expandMultiarmTrials, created using expandMultiarmTrials.

comp.id.indicator

character, column name of the variable storing the comparison ID; typically created by expandMultiarmTrials.

trt.indicator

character, column name of the variable storing the treatment indicator (treatment 1 or 2); typically created by expandMultiarmTrials.

funcs

list of functions. These functions will be used to calculate the effect sizes (Hedges' g) based on the raw data (see Details).

include.switched.arms

logical. Should all unique arm comparisons (in lieu of unique arm combinations) be calculated? Default is FALSE. Can only be set to TRUE when trt.indicator is set to "trt".

change.sign

character. Name of a logical column in data, encoding if the sign of a calculated effect size should be reversed (TRUE) or not (FALSE). Set to NULL (default) if no changes should be made.

data.format

character. Either "long" or "wide", depending on the format of the dataset in data. NULL by default, which lets the user define the format after the function has been called.

Details

By default, the small-sample bias corrected standardized mean difference (Hedges' g) is calculated from:

  • the mean, SD and N

  • binary outcome data (i.e. response counts) and

  • change scores

Other functions can be added to the list provided to funcs. However, results of the function must result in a data.frame with the same number of rows as in data, and two columns: one for the calculated g value (named es) and its standard error (named se). In rows for which no fitting raw data was supplied, the resulting data.frame should contain NA.

For more details see the help vignette: vignette("metapsyTools")

Value

calculateEffectSizes returns the meta-analysis data set as class data.frame in wide format (if results are saved to a variable). It also generates the following columns, wich are added to the data:

  • es calculated effect sizes for each comparison.

  • se calculated standard error of the effect size.

  • study.id a study-specific ID variable.

  • study a study-specific variable containing its name. For multiarm studies, this variable specifies the active treatment arm used to calculate the effect.

Author(s)

Mathias Harrer mathias.h.harrer@gmail.com, Paula Kuper paula.r.kuper@gmail.com, Pim Cuijpers p.cuijpers@vu.nl

See Also

expandMultiarmTrials

Examples

## Not run: 
#Example 1: use function in default mode; requires data created by expandMultiarmTrials
data("inpatients")
inpatients %>%
    expandMultiarmTrials() %>%
    calculateEffectSizes()

#Example 2: further use to pool effect sizes
library(meta)
inpatients %>%
  checkDataFormat() %>%
  expandMultiarmTrials() %>%
  calculateEffectSizes() %>%
  filterPoolingData(primary==1) %>%
  metagen(es, se, studlab=study, fixed=FALSE, data=.)


# Example 3: use for 3-level model
library(metafor)
library(dplyr)
inpatients %>%
  checkDataFormat ()%>%
  expandMultiarmTrials() %>%
  calculateEffectSizes() %>%
  dplyr::mutate(es.id = 1:nrow(.)) %>%
  metafor::rma.mv(es, se^2, data = ., slab = study.id,
                  random = ~ 1 | study.id/es.id, test = "t")

## End(Not run)



MathiasHarrer/metapsyTools documentation built on May 1, 2022, 5:14 p.m.