#' theta.matching
#'
#' Because ltm only provides theta estimates for each response pattern, not for each person,
#' this function is made to get the theta estimates for each person according to the person's
#' response pattern
#'
#' @param data A data frame containing the fata
#' @param item item included in Rasch Analysis
#' @param theta.pattern theta estimate from ltm's factor scores function
theta.matching = function (data, item, theta.pattern) {
theta = c()
data = data[,item]
for(i in 1:nrow(data)) {
if(is.na(data[i,1])){
theta.pattern.subset = theta.pattern[is.na(theta.pattern[,1]),]
}else{
theta.pattern.subset = theta.pattern[theta.pattern[,1] == data[i, 1],]
}
for(j in 1:nrow(theta.pattern.subset)){
if(toString(data[i, ]) == toString(theta.pattern.subset[j, item])){
theta = c(theta, theta.pattern.subset[j, "z1"])
break
}
}
}
cbind(data, theta)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.