#' beta.specific
#'
#' This extract the difficulty of each category in a Partial Credit model
#'
#'
#'@param codaSamples MCMC sample from a Partial Credit model
#'@param data A data frame to know the number of item and category
#'@param item Item included in Partial Credit model
beta.specific = function(codaSamples, data, item) {
codaSamples.matrix = as.matrix(codaSamples)
item.variable = data[, item]
if(min(apply(item.variable, 2, min,na.rm = TRUE)) == 0){item.variable = item.variable + 1}
K = apply(item.variable, 2, max,na.rm = TRUE)
p = ncol(item.variable)
beta.matrix = matrix(NA, p, max(K))
for(i in 1:p){
for(j in 2:K[i]){
beta.matrix[i,j] = mean(codaSamples.matrix[,paste0("beta[", i,",", j,"]")])
}
}
rownames(beta.matrix) = item
beta.matrix[,-1]
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.