#' probgenerator
#'
#' Generate probability of rating each category given difficulty and ability
#'
#' @param item difficulty of an item
#' @param person ability of a subject
#' @param obj An RSM object or PCM object
probgenerator = function(item, person, obj){
if(class(obj) == "BPCM"){
eta.length = length(item) + 1
}
else{
thresh = andrich.threshold(obj)
eta.length = length(thresh) + 1
}
prob = rep(NA, eta.length)
eta = rep(NA, eta.length)
psum = rep(NA, eta.length)
exp.psum = rep(NA, eta.length)
eta[1] = 0
for(i in 2:eta.length) {
if(class(obj) == "BPCM"){eta[i] = person - item[i - 1]}
else{eta[i] = person - (item + thresh[i - 1])}
}
for(i in 1:eta.length){
psum[i] = sum(eta[1:i])
exp.psum[i] = exp(psum[i])
}
for(i in 1:eta.length){
prob[i] = exp.psum[i] / sum(exp.psum)
}
prob
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.