R/EOI.R

Defines functions EOI

Documented in EOI

#' This function calculates engineering optimal information (EOI ) function as introduced in Kingsbury & Wise (2020)
#'
#' @param theta a numeric vector containing the true ability level of students
#' @param t.hat a numeric vector containing the estimated ability level of students
#' @param items.administered A data matrix that has the set of item items administered to individuals. This input assumes that every row in the data frame corresponds to the set of item names administered to an individual.
#' @param bank A data matrix that have item parameters in the following order: discrimination, difficulty, guessing and slipping.
#'
#' @importFrom catR Ii
#' @return Returns a single numeric value for EOI
#' @export
#' @references
#' Kingsbury, G. G., & Wise, S. L. (2020). Three Measures of Test Adaptation Based on Optimal Test Information. Journal of Computerized Adaptive Testing, 8(1), 1-19.

#' @examples
#' library(catR)
#' N=1000 #number of students
#' bank=250 #number of items
#' items=45
#' theta=rnorm(N,0,1) #level of trait
#' model="2PL" #IRT model to use
#' start <- list(theta = -1:1, randomesque = 1)
#' stop <- list(rule = c( "length"), thr = items)
#' final <- list(method = "ML")
#'
#' test=list(method = "ML", itemSelect = "MFI")
#' bank=genDichoMatrix(items =bank, cbControl = NULL,
#'                     model = model)
#'
#' res <- simulateRespondents(thetas = theta, bank,
#'                            start = start, test = test, stop = stop,
#'                            final = final, model = NULL)
#' t.hat=res$final.values.df$estimated.theta
#'
#' items.administered=res$responses.df[,grepl("items.administrated",
#'                                            names( res$responses.df ) ) ]
#' colnames(items.administered)=NULL
#' diff=matrix(ncol = ncol(items.administered),nrow = nrow(items.administered))
#' for (k in 1:nrow(items.administered)) {
#'   xx= as.numeric(items.administered[k,])
#'   diff[k,]=bank[xx,2]
#' }
#' EOI(theta, t.hat, items.administered, bank)

EOI <- function(theta,t.hat, items.administered, bank) {
  require(catR)
  res=matrix(ncol = 1,nrow = length(theta))
  for (i in 1:length(theta)) {

  items.administered.individual=as.numeric(items.administered[i,])
  IAj=sum(Ii(t.hat[i],bank[items.administered.individual,],)$Ii)
  inf.items=bank[items.administered.individual,]
  inf.items[,2]=t.hat[i]
  res[i,1] =IAj/sum(Ii(t.hat[i],inf.items)$Ii)
  }
  EOI=mean(res)
  return(noquote(paste("EOI=",round(EOI,digits = 2))))}
mustfa5/test.adaptation documentation built on Dec. 21, 2021, 11:03 p.m.