R/ConvertBinaryToEffectSize.R

Defines functions ConvertBinaryToEffectSize

ConvertBinaryToEffectSize <-
function(table, measure="RR"){
  # Converts count data to an effect size (such as log relative risk).  
  #
  # Args:
  #   table: A data set table with binary count data for both the ctrl and expt arms.
  #   measure: which effect size measure to calculate
  #     "RR" = log risk ratio (default)
  #     "OR" = log odds ratio 
  #
  # Returns: Adjusted SMD/Hedges g and its variance under a fixed effects model.
  
  # Dependencies:
  #   Calls: package "metafor" to use function escalc()
  #   Callers: binary.table()

  fixedmodel <- escalc(measure=measure, data=table, 
                  append=TRUE,
                  ai=table$expt.events, n1i=table$expt.n, 
                  ci=table$ctrl.events, n2i=table$ctrl.n)
  return(fixedmodel)
}

Try the SAMURAI package in your browser

Any scripts or data that you put into this service are public.

SAMURAI documentation built on May 1, 2019, 11:31 p.m.