#' BRSM.transform
#'
#' Transform BRSM parameter to make andrich threshold follow the sum-to-zero constraint
#'
#' @param mcmc MCMC sample from RSM model
#' @param item item involved in RSM model
#' @param K number of category
BRSM.transform = function(mcmc, item, K) {
for(i in 1:nrow(mcmc)){
ata = matrix(NA, length(item), K)
for(j in 1:length(item)){
for(k in 2:K){
ata[j,k] = mcmc[i, paste0("beta[",j,"]")] + mcmc[i,paste0("thres[",k,"]")]
}
}
#transform beta
for(j in 1:length(item)){
mcmc[i,paste0("beta[",j,"]")] = mean(ata[j,], na.rm = TRUE)
}
#transform thres
for(k in 2:K){
mcmc[i,paste0("thres[",k,"]")] = ata[1, k] - mcmc[i,paste0("beta[",1,"]")]
}
}
mcmc
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.