R/ES.R

Defines functions ES

Documented in ES

#' ES
#'
#' Compute the effect size from an BRPM object
#' Note: This computation of ES does not rely on normality assumption.
#' It outputs the probability that person from experimental group
#' will be higher than person from control, if both chosen at random
#'
#' Reference
#' Coe, R. (2002). It's the effect size, stupid: What effect size is and why it is important.
#'
#' @param obj an BRPM object
#' @export ES
ES = function(obj){
  DIF = obj$DIF
  prob = c()
  mcmc = obj$mcmc
  N = obj$N
  if(DIF == TRUE){
    for(i in 1:1000){
      larger = 0
      theta.group.1 = mcmc[i, paste0("theta[",1 ,",",1:N[1],"]")]
      theta.group.2 = mcmc[i, paste0("theta[",2 ,",",1:N[2],"]")]
      for(i in 1:1000){
        theta.1 = sample(theta.group.1, 1, replace = TRUE)
        theta.2 = sample(theta.group.2, 1, replace = TRUE)
        if(theta.2 > theta.1){larger = larger + 1}
      }
      prob = c(prob, larger / 1000)
    }
    HDInterval::hdi(prob)
  }else{
    show("There is no multiple group for analysis")
  }
}
changxiulee/BayesianRasch documentation built on Nov. 18, 2019, 6:54 a.m.