# R code written by Melanie M. Wall - last updated 11/19/2010 # This program calculates a 95% confidence interval for # TIA (Total information area index) for the # 2 parameter logistic IRT model. The TIA is calculated # as the integral of the total test information function across # the entire (-infinity, +infinity) latent trait. # It can equivalently be calculated # as the sum of the p discrimination parameters (where p is the number of items in the set). # The standard error (and confidence interval) for the TIA in this function # is thus obtained based on the # the asymptotic distributions of the sum of discrimination parameters # This program utilizes the 'ltm' latent trait modeling package, so it must first be loaded # onto your system from the CRAN site for the program to work library(ltm) ################Beginning of the function called asym.confint.irt.info ########## asym.confint.irt.info<-function(dataset){ ########################################################################### #### The following uses the ltm function to obtain the ML estimators of the #### discrimination and severity parameters for the observed data ########################################################################### parms.of.observed = ltm(dataset ~ z1,IRT.param=TRUE) coef.observed<-coef(parms.of.observed) numvars<-dim(dataset)[2] ########################################################################## ### The following makes the plot of the total information curves ### The test information curve is the sum of item information curves and ### provides a visual way to examine where the item set, i.e. "test", ### yields the most precise estimate of the underlying trait. ### Often the location of the peak is ### referred to as the place along the trait where the item set is ### "most discriminating", e.g. (Reise and Waller 2002). ### Reise, S. andWaller, N. (2002) Item response theory for dichotomous assessment data. In Drasgow, ### F. and Schmitt, N., editors, Measuring and Analyzing Behavior in Organizations. San Francisco: ### Jossey-Bass. ############################################################################# plotall<-plot(parms.of.observed , type = "IIC", items = 0,xlab = "Latent trait") ############################################################################### ### ### The following calculates the Total Information Area Index ### ### To get the total information across the whole trait, the information function in the ltm package uses the ### integrate() function built into R and integrates from -10 to 10 ### this Total Information Area Index can also be calculated as the sum of the ### discrimination parameters ############################################################################### tia.original<-information(parms.of.observed, range = c(-10,10))$InfoTotal #### Here the asymptotic standard error of the total information is obtained #### using the fact that it is simply the sum of the discrimination #### parameters and so we have a closed form for its variance covdiscrm<-vcov(parms.of.observed)[(numvars+1):(2*numvars),(numvars+1):(2*numvars)] varofsum<-t(c(rep(1,numvars)))%*%covdiscrm%*%c(rep(1,numvars)) #### Here using the asymptotic distribution of the sum of the discrimination estimators #### being normally distributed, we calculate a symmetric 95% confidence interval confint<-c(tia.original-1.96*sqrt(varofsum), tia.original+1.96*sqrt(varofsum)) allout<-list(coef.observed=coef.observed,tia.original=tia.original, confint = confint) return(allout) } ########## End of the Function ############ ################################################ #######Example - simulated data ############################################### set.seed(123499) n<-700 prob<-matrix(rep(0,n*12),ncol = 12) symptoms<-matrix(rep(99,n*12),ncol = 12) f<-rnorm(n,0,1) disc<-c(1,1,1,1,1,1,1,1,1,1,1,1) severity<-c(-1.5,-1.5,-1,-1,0,0,0,0,1,1,1.5,1.5) for (i in c(1:n)){ prob[i,]<- 1/(1+exp(-disc*(f[i]-severity))) symptoms[i,]<-rbinom(12,1,prob[i,]) } #######This is the way to call the function asym.confint.irt.info(symptoms) #Here are the results for the simulated data # TIA = 11.62 95% CI = (10.65,12.76) #$coef.observed # Dffclt Dscrmn #Item 1 -1.55058371 1.2111926 #Item 2 -1.53095794 1.0543602 #Item 3 -1.24211903 0.8660448 #Item 4 -1.27343552 0.7020015 #Item 5 0.05502064 0.9345833 #Item 6 -0.19743686 1.1093184 #Item 7 0.08471676 0.8292031 #Item 8 -0.01683570 1.0667659 #Item 9 1.04264012 0.8543570 #Item 10 0.97723563 0.9642812 #Item 11 1.62733107 0.8793472 #Item 12 1.44888562 1.1536152 # #$tia.original #[1] 11.62063 # #$confint #[1] 10.56235 12.67890