R/theta.R

Defines functions theta

Documented in theta

#' theta
#'
#' Extract ability estimated from model
#'
#' @param obj An BPCM or BRSM obj
#' @param g If it is a DIF object, specify group of interest.
#' @export theta

theta = function(obj, g = 1) {
  if(obj$DIF == TRUE){
    codaSamples = obj$mcmc[[g]]
  }else{
    codaSamples = obj$mcmc
  }

  N = obj$N[g]
  theta = NULL
  thetaMean = c()

  for(i in 1:N){
    theta = rbind(theta, HDInterval::hdi(codaSamples[,paste0("theta[", g,",", i,"]")]))
    thetaMean = c(thetaMean, mean(codaSamples[,paste0("theta[", g,",", i,"]")]))
  }

  round(cbind(theta, thetaMean), 2)
}
changxiulee/BayesianRasch documentation built on Nov. 18, 2019, 6:54 a.m.