library(tidyverse)
library(mirt)
The data set irt_calibration contains scores for 60 math and 40 reading items. There are 6000 examinees. The data has 105 columns: 4+60+40+1=105
4: ID 0001 to 6000
60: 0/1 responses for a 60-item math test
40: 0/1 responses for a 40-item reading test
1: group ID (1 for examinees 1-3000, 0 for
examinees 3001-6000)Â
Our data is best imported using the read_fwf function in tidyverse’s readr, this will help us handle the first four digit which represent examinee’s ID. For this exercise we will be calibrating responses for the first 2000 examinees in math.
data <- read_fwf("irt_calibration.txt", fwf_widths(c(4,rep(1,60)), col_names =
c("ID",paste0("math",seq(1,60)))))
data <- data[1:2000,2:61]
head(data)
## # A tibble: 6 x 60
## math1 math2 math3 math4 math5 math6 math7 math8 math9 math10 math11 math12
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 1 0 0 0 1 1 1 1 0 1 1 0
## 2 1 1 1 1 1 1 1 1 1 1 0 0
## 3 1 1 1 0 1 0 1 0 1 0 0 0
## 4 1 1 1 1 0 0 1 1 1 0 1 0
## 5 1 1 0 1 1 1 0 1 0 0 1 1
## 6 1 0 1 0 1 0 0 0 1 0 1 0
## # ... with 48 more variables: math13 <dbl>, math14 <dbl>, math15 <dbl>,
## # math16 <dbl>, math17 <dbl>, math18 <dbl>, math19 <dbl>, math20 <dbl>,
## # math21 <dbl>, math22 <dbl>, math23 <dbl>, math24 <dbl>, math25 <dbl>,
## # math26 <dbl>, math27 <dbl>, math28 <dbl>, math29 <dbl>, math30 <dbl>,
## # math31 <dbl>, math32 <dbl>, math33 <dbl>, math34 <dbl>, math35 <dbl>,
## # math36 <dbl>, math37 <dbl>, math38 <dbl>, math39 <dbl>, math40 <dbl>,
## # math41 <dbl>, math42 <dbl>, math43 <dbl>, math44 <dbl>, math45 <dbl>, ...
Using the 3PL model, we will obtain the discrimination, difficulty and guessing parameter estimates for the math items
threepl <- mirt(data, 1, itemtype = '3PL', guess = .2)
coef(threepl, simplify=TRUE)
## $items
## a1 d g u
## math1 1.458 2.614 0.025 1
## math2 1.463 3.048 0.005 1
## math3 1.766 2.001 0.002 1
## math4 1.389 1.428 0.105 1
## math5 2.258 3.166 0.365 1
## math6 2.262 1.555 0.254 1
## math7 1.643 1.454 0.428 1
## math8 1.922 1.512 0.323 1
## math9 1.324 1.446 0.002 1
## math10 1.960 1.170 0.171 1
## math11 2.699 0.610 0.376 1
## math12 2.519 -0.051 0.446 1
## math13 1.121 1.069 0.003 1
## math14 1.899 1.843 0.163 1
## math15 1.891 0.764 0.130 1
## math16 1.665 0.736 0.056 1
## math17 2.080 1.494 0.094 1
## math18 2.716 1.029 0.082 1
## math19 0.837 1.218 0.002 1
## math20 1.957 1.192 0.157 1
## math21 2.258 0.128 0.221 1
## math22 1.156 0.895 0.087 1
## math23 0.787 0.606 0.002 1
## math24 1.266 0.750 0.001 1
## math25 2.041 0.326 0.312 1
## math26 1.752 -0.373 0.330 1
## math27 2.082 -0.085 0.191 1
## math28 1.170 0.858 0.054 1
## math29 1.144 0.936 0.006 1
## math30 2.086 -1.268 0.186 1
## math31 1.663 0.940 0.001 1
## math32 1.448 -0.508 0.147 1
## math33 1.259 1.084 0.097 1
## math34 2.022 0.036 0.065 1
## math35 1.805 -0.667 0.279 1
## math36 2.310 -1.534 0.165 1
## math37 2.567 -1.424 0.157 1
## math38 1.912 0.145 0.049 1
## math39 1.091 0.173 0.002 1
## math40 3.655 -5.913 0.236 1
## math41 2.083 -1.084 0.208 1
## math42 1.398 -1.184 0.184 1
## math43 2.388 -0.661 0.102 1
## math44 2.064 -1.166 0.154 1
## math45 1.232 -1.120 0.133 1
## math46 1.936 -1.574 0.218 1
## math47 1.830 -1.370 0.058 1
## math48 1.083 -1.876 0.187 1
## math49 2.261 -2.070 0.150 1
## math50 1.814 -1.679 0.194 1
## math51 1.881 -1.755 0.054 1
## math52 3.237 -3.194 0.130 1
## math53 3.348 -4.015 0.212 1
## math54 2.745 -2.834 0.162 1
## math55 1.887 -2.258 0.068 1
## math56 2.895 -5.285 0.124 1
## math57 2.731 -5.647 0.123 1
## math58 1.568 -3.245 0.148 1
## math59 1.715 -3.349 0.154 1
## math60 1.303 -2.980 0.104 1
##
## $means
## F1
## 0
##
## $cov
## F1
## F1 1
plot(threepl, type = 'trace')#ICC for all items
plot(threepl, type = 'info') #test information
plot(threepl)