#' BPCM.DIF.transform
#'
#' Split the MCMC into multiple matrix for each group
#'
#' @param mcmc MCMC sample from a BPCM DIF model
#' @param item item involved in the model
#' @param p number of item
#' @param N number of subject for each group
#' @param K number of category
#' @param G number of group
BPCM.DIF.transform = function(mcmc, item, p, N, K, G) {
mcmc.new = list()
for(i in 1:G){
group = matrix(NA, nrow(mcmc), p * K + N[i])
temp = c()
for(j in 1:p) {
for(k in 1:K){
temp = c(temp, paste0("beta[", j,",", k,"]"))
}
}
colnames(group) = c(temp, paste0("theta[", i,",", 1:N[i], "]"))
for(j in 1:p) {
for(k in 1:K){
group[, paste0("beta[", j,",", k,"]")] = mcmc[, paste0("beta[", j,",", k,"]")] + mcmc[, paste0("d[",i,",", j, ",", k, "]")]
}
}
group[, paste0("theta[", i ,",", 1:N[i], "]")] = mcmc[, paste0("theta[", i ,",", 1:N[i], "]")]
mcmc.new[[i]] = group
}
mcmc.new
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.