R/andrich.threshold.R

Defines functions andrich.threshold

Documented in andrich.threshold

#' Andrich Threshold
#'
#' Extract the Andrich threshold (intercept between ICC curve) in a RSM model
#'
#' @param obj A RSM model from BRPM or BRPM.DIF model
#' @export andrich.threshold

andrich.threshold = function(obj) {
  if(class(obj) == "BRSM"){
    #Initialization
    data = obj$data
    data = data[, obj$item]
    if(min(apply(data, 2, min,na.rm = TRUE)) == 0){data = data + 1}
    if(obj$DIF == TRUE){
      mcmc = obj$mcmc[[1]]
    }else{
      mcmc = obj$mcmc
    }
    K = apply(data, 2, max,na.rm = TRUE)

    #Extract from MCMC
    if(max(K) <= 2){
      v = 0
    }else{
      v = c()
      for(j in 2:(max(K))){
        v = c(v, mean(mcmc[, paste0("thres[",j,"]")]))
      }
    }
    v
  }
  else{
    show("This is not available for BPCM")
  }
}
changxiulee/BayesianRasch documentation built on Nov. 18, 2019, 6:54 a.m.