# Load necessary libraries
library(ltm)
## 载入需要的程辑包:MASS
## 载入需要的程辑包:msm
## 载入需要的程辑包:polycor
library(mirt)
## 载入需要的程辑包:stats4
## 载入需要的程辑包:lattice
##
## 载入程辑包:'mirt'
## The following object is masked from 'package:ltm':
##
## Science
# Load the data (assuming the .dat file is tab-separated; modify if needed)
pisa_data <- read.table("C:/Users/徐安迪/Downloads/PISA2009.dat", header=TRUE, sep="\t")
# Select the first column as character data
responses <- as.character(pisa_data[, 1])
# Remove the first 8 characters from each row and retain the remaining part
responses <- substr(responses, 9, nchar(responses))
# Verify that the length of the string is 23 characters
nchar(responses[1]) # The result should be 23 to ensure the data is correct
## [1] 23
# Split each string into 23 items (columns)
item_data <- do.call(rbind, strsplit(responses, ""))
# Confirm that the number of columns after splitting is 23
ncol(item_data)
## [1] 23
# Convert the resulting data into a data frame and ensure column names are unique
item_data <- as.data.frame(item_data)
# Assign unique column names to each column
colnames(item_data) <- paste0("Item_", 1:ncol(item_data))
# Check the first few rows of the data and the column names
head(item_data)
## Item_1 Item_2 Item_3 Item_4 Item_5 Item_6 Item_7 Item_8 Item_9 Item_10
## 1 0 0 0 0 0 0 0 0 0 0
## 2 0 1 0 0 0 0 1 1 0 0
## 3 0 0 0 1 0 0 0 0 1 0
## 4 8 0 0 8 8 8 8 1 1 8
## 5 0 0 0 0 8 0 8 1 0 8
## 6 1 0 0 1 0 0 1 0 1 0
## Item_11 Item_12 Item_13 Item_14 Item_15 Item_16 Item_17 Item_18 Item_19
## 1 1 0 0 0 0 0 0 0 0
## 2 0 1 0 0 0 0 1 1 1
## 3 0 0 0 0 0 1 1 0 1
## 4 0 8 8 1 8 0 1 8 0
## 5 0 8 8 0 8 0 0 8 0
## 6 1 1 0 1 1 1 1 1 1
## Item_20 Item_21 Item_22 Item_23
## 1 1 0 0 0
## 2 0 0 1 0
## 3 0 0 1 0
## 4 1 0 8 8
## 5 1 0 8 8
## 6 1 1 1 0
colnames(item_data)
## [1] "Item_1" "Item_2" "Item_3" "Item_4" "Item_5" "Item_6" "Item_7"
## [8] "Item_8" "Item_9" "Item_10" "Item_11" "Item_12" "Item_13" "Item_14"
## [15] "Item_15" "Item_16" "Item_17" "Item_18" "Item_19" "Item_20" "Item_21"
## [22] "Item_22" "Item_23"
# Convert the split item data to numeric
item_data <- apply(item_data, 2, as.numeric)
# Ensure the data frame is numeric and check data types
item_data <- as.data.frame(item_data)
# Review the structure of the data to confirm all columns are numeric
str(item_data)
## 'data.frame': 2904 obs. of 23 variables:
## $ Item_1 : num 0 0 0 8 0 1 0 0 0 0 ...
## $ Item_2 : num 0 1 0 0 0 0 0 0 0 0 ...
## $ Item_3 : num 0 0 0 0 0 0 0 0 0 0 ...
## $ Item_4 : num 0 0 1 8 0 1 1 0 0 1 ...
## $ Item_5 : num 0 0 0 8 8 0 0 0 0 0 ...
## $ Item_6 : num 0 0 0 8 0 0 0 0 0 0 ...
## $ Item_7 : num 0 1 0 8 8 1 1 0 0 0 ...
## $ Item_8 : num 0 1 0 1 1 0 1 0 1 1 ...
## $ Item_9 : num 0 0 1 1 0 1 0 0 0 0 ...
## $ Item_10: num 0 0 0 8 8 0 1 1 0 1 ...
## $ Item_11: num 1 0 0 0 0 1 0 0 0 0 ...
## $ Item_12: num 0 1 0 8 8 1 1 0 0 1 ...
## $ Item_13: num 0 0 0 8 8 0 0 0 0 0 ...
## $ Item_14: num 0 0 0 1 0 1 1 0 0 1 ...
## $ Item_15: num 0 0 0 8 8 1 0 0 0 1 ...
## $ Item_16: num 0 0 1 0 0 1 1 0 0 1 ...
## $ Item_17: num 0 1 1 1 0 1 1 1 0 1 ...
## $ Item_18: num 0 1 0 8 8 1 1 0 1 0 ...
## $ Item_19: num 0 1 1 0 0 1 1 0 0 1 ...
## $ Item_20: num 1 0 0 1 1 1 0 0 0 1 ...
## $ Item_21: num 0 0 0 0 0 1 1 0 1 1 ...
## $ Item_22: num 0 1 1 8 8 1 1 0 0 1 ...
## $ Item_23: num 0 0 0 8 8 0 0 0 0 0 ...
# Convert any values greater than 1 to 1 for each item
item_data <- apply(item_data, 2, function(x) ifelse(x > 1, 1, x))
# Ensure the data is numeric and convert back to a data frame
item_data <- as.data.frame(item_data)
# Check the first few rows of data to confirm changes
head(item_data)
## Item_1 Item_2 Item_3 Item_4 Item_5 Item_6 Item_7 Item_8 Item_9 Item_10
## 1 0 0 0 0 0 0 0 0 0 0
## 2 0 1 0 0 0 0 1 1 0 0
## 3 0 0 0 1 0 0 0 0 1 0
## 4 1 0 0 1 1 1 1 1 1 1
## 5 0 0 0 0 1 0 1 1 0 1
## 6 1 0 0 1 0 0 1 0 1 0
## Item_11 Item_12 Item_13 Item_14 Item_15 Item_16 Item_17 Item_18 Item_19
## 1 1 0 0 0 0 0 0 0 0
## 2 0 1 0 0 0 0 1 1 1
## 3 0 0 0 0 0 1 1 0 1
## 4 0 1 1 1 1 0 1 1 0
## 5 0 1 1 0 1 0 0 1 0
## 6 1 1 0 1 1 1 1 1 1
## Item_20 Item_21 Item_22 Item_23
## 1 1 0 0 0
## 2 0 0 1 0
## 3 0 0 1 0
## 4 1 0 1 1
## 5 1 0 1 1
## 6 1 1 1 0
# Perform a 3PL analysis on the 23-item data
model_3pl <- mirt(item_data, 1, itemtype = '3PL')
## Iteration: 1, Log-Lik: -37370.625, Max-Change: 8.36211Iteration: 2, Log-Lik: -35132.719, Max-Change: 3.96630Iteration: 3, Log-Lik: -34492.076, Max-Change: 3.54052Iteration: 4, Log-Lik: -34093.726, Max-Change: 1.64753Iteration: 5, Log-Lik: -33945.238, Max-Change: 1.56847Iteration: 6, Log-Lik: -33854.724, Max-Change: 1.27794Iteration: 7, Log-Lik: -33803.122, Max-Change: 0.67287Iteration: 8, Log-Lik: -33778.038, Max-Change: 0.72729Iteration: 9, Log-Lik: -33766.604, Max-Change: 0.78857Iteration: 10, Log-Lik: -33759.181, Max-Change: 0.76641Iteration: 11, Log-Lik: -33754.113, Max-Change: 0.53015Iteration: 12, Log-Lik: -33750.427, Max-Change: 0.66618Iteration: 13, Log-Lik: -33743.585, Max-Change: 0.27706Iteration: 14, Log-Lik: -33740.185, Max-Change: 0.27565Iteration: 15, Log-Lik: -33738.585, Max-Change: 0.26376Iteration: 16, Log-Lik: -33735.224, Max-Change: 0.32328Iteration: 17, Log-Lik: -33733.000, Max-Change: 0.49897Iteration: 18, Log-Lik: -33731.928, Max-Change: 0.75076Iteration: 19, Log-Lik: -33730.172, Max-Change: 0.24293Iteration: 20, Log-Lik: -33729.147, Max-Change: 0.29684Iteration: 21, Log-Lik: -33728.494, Max-Change: 0.91503Iteration: 22, Log-Lik: -33727.513, Max-Change: 0.25384Iteration: 23, Log-Lik: -33727.045, Max-Change: 0.87502Iteration: 24, Log-Lik: -33726.550, Max-Change: 0.62937Iteration: 25, Log-Lik: -33726.167, Max-Change: 0.47747Iteration: 26, Log-Lik: -33725.543, Max-Change: 0.08838Iteration: 27, Log-Lik: -33725.367, Max-Change: 0.98817Iteration: 28, Log-Lik: -33725.013, Max-Change: 0.09265Iteration: 29, Log-Lik: -33724.881, Max-Change: 0.84638Iteration: 30, Log-Lik: -33724.649, Max-Change: 0.38752Iteration: 31, Log-Lik: -33724.522, Max-Change: 0.18245Iteration: 32, Log-Lik: -33724.426, Max-Change: 0.05138Iteration: 33, Log-Lik: -33724.371, Max-Change: 0.01110Iteration: 34, Log-Lik: -33724.359, Max-Change: 0.32082Iteration: 35, Log-Lik: -33724.272, Max-Change: 0.00958Iteration: 36, Log-Lik: -33724.249, Max-Change: 0.00531Iteration: 37, Log-Lik: -33724.237, Max-Change: 0.01526Iteration: 38, Log-Lik: -33724.213, Max-Change: 0.01138Iteration: 39, Log-Lik: -33724.196, Max-Change: 0.00724Iteration: 40, Log-Lik: -33724.187, Max-Change: 0.00985Iteration: 41, Log-Lik: -33724.172, Max-Change: 0.00855Iteration: 42, Log-Lik: -33724.160, Max-Change: 0.00876Iteration: 43, Log-Lik: -33724.142, Max-Change: 0.06530Iteration: 44, Log-Lik: -33724.098, Max-Change: 0.00514Iteration: 45, Log-Lik: -33724.084, Max-Change: 0.00453Iteration: 46, Log-Lik: -33724.079, Max-Change: 0.01025Iteration: 47, Log-Lik: -33724.068, Max-Change: 0.00679Iteration: 48, Log-Lik: -33724.060, Max-Change: 0.00384Iteration: 49, Log-Lik: -33724.056, Max-Change: 0.00536Iteration: 50, Log-Lik: -33724.049, Max-Change: 0.00970Iteration: 51, Log-Lik: -33724.042, Max-Change: 0.00305Iteration: 52, Log-Lik: -33724.039, Max-Change: 0.00469Iteration: 53, Log-Lik: -33724.034, Max-Change: 0.00875Iteration: 54, Log-Lik: -33724.028, Max-Change: 0.00287Iteration: 55, Log-Lik: -33724.025, Max-Change: 0.00443Iteration: 56, Log-Lik: -33724.020, Max-Change: 0.00824Iteration: 57, Log-Lik: -33724.015, Max-Change: 0.00266Iteration: 58, Log-Lik: -33724.013, Max-Change: 0.00412Iteration: 59, Log-Lik: -33724.009, Max-Change: 0.00775Iteration: 60, Log-Lik: -33724.004, Max-Change: 0.00247Iteration: 61, Log-Lik: -33724.002, Max-Change: 0.00384Iteration: 62, Log-Lik: -33723.999, Max-Change: 0.00731Iteration: 63, Log-Lik: -33723.995, Max-Change: 0.00229Iteration: 64, Log-Lik: -33723.993, Max-Change: 0.00645Iteration: 65, Log-Lik: -33723.989, Max-Change: 0.00621Iteration: 66, Log-Lik: -33723.985, Max-Change: 0.00225Iteration: 67, Log-Lik: -33723.983, Max-Change: 0.00591Iteration: 68, Log-Lik: -33723.979, Max-Change: 0.00846Iteration: 69, Log-Lik: -33723.976, Max-Change: 0.00095Iteration: 70, Log-Lik: -33723.975, Max-Change: 0.00097Iteration: 71, Log-Lik: -33723.974, Max-Change: 0.00035Iteration: 72, Log-Lik: -33723.973, Max-Change: 0.00357Iteration: 73, Log-Lik: -33723.970, Max-Change: 0.00678Iteration: 74, Log-Lik: -33723.967, Max-Change: 0.00183Iteration: 75, Log-Lik: -33723.966, Max-Change: 0.00049Iteration: 76, Log-Lik: -33723.965, Max-Change: 0.00035Iteration: 77, Log-Lik: -33723.965, Max-Change: 0.00478Iteration: 78, Log-Lik: -33723.963, Max-Change: 0.00206Iteration: 79, Log-Lik: -33723.962, Max-Change: 0.00054Iteration: 80, Log-Lik: -33723.961, Max-Change: 0.00262Iteration: 81, Log-Lik: -33723.960, Max-Change: 0.00033Iteration: 82, Log-Lik: -33723.960, Max-Change: 0.00033Iteration: 83, Log-Lik: -33723.960, Max-Change: 0.00508Iteration: 84, Log-Lik: -33723.958, Max-Change: 0.00178Iteration: 85, Log-Lik: -33723.957, Max-Change: 0.00053Iteration: 86, Log-Lik: -33723.957, Max-Change: 0.00153Iteration: 87, Log-Lik: -33723.956, Max-Change: 0.00034Iteration: 88, Log-Lik: -33723.956, Max-Change: 0.00168Iteration: 89, Log-Lik: -33723.955, Max-Change: 0.00320Iteration: 90, Log-Lik: -33723.953, Max-Change: 0.00029Iteration: 91, Log-Lik: -33723.953, Max-Change: 0.00029Iteration: 92, Log-Lik: -33723.953, Max-Change: 0.00149Iteration: 93, Log-Lik: -33723.952, Max-Change: 0.00161Iteration: 94, Log-Lik: -33723.952, Max-Change: 0.00060Iteration: 95, Log-Lik: -33723.951, Max-Change: 0.00156Iteration: 96, Log-Lik: -33723.951, Max-Change: 0.00033Iteration: 97, Log-Lik: -33723.951, Max-Change: 0.00032Iteration: 98, Log-Lik: -33723.950, Max-Change: 0.00159Iteration: 99, Log-Lik: -33723.950, Max-Change: 0.00030Iteration: 100, Log-Lik: -33723.950, Max-Change: 0.00151Iteration: 101, Log-Lik: -33723.949, Max-Change: 0.00036Iteration: 102, Log-Lik: -33723.949, Max-Change: 0.00154Iteration: 103, Log-Lik: -33723.948, Max-Change: 0.00035Iteration: 104, Log-Lik: -33723.948, Max-Change: 0.00146Iteration: 105, Log-Lik: -33723.947, Max-Change: 0.00030Iteration: 106, Log-Lik: -33723.947, Max-Change: 0.00030Iteration: 107, Log-Lik: -33723.947, Max-Change: 0.00147Iteration: 108, Log-Lik: -33723.947, Max-Change: 0.00141Iteration: 109, Log-Lik: -33723.946, Max-Change: 0.00050Iteration: 110, Log-Lik: -33723.946, Max-Change: 0.00143Iteration: 111, Log-Lik: -33723.945, Max-Change: 0.00036Iteration: 112, Log-Lik: -33723.945, Max-Change: 0.00030Iteration: 113, Log-Lik: -33723.945, Max-Change: 0.00137Iteration: 114, Log-Lik: -33723.945, Max-Change: 0.00028Iteration: 115, Log-Lik: -33723.944, Max-Change: 0.00138Iteration: 116, Log-Lik: -33723.944, Max-Change: 0.00040Iteration: 117, Log-Lik: -33723.944, Max-Change: 0.00133Iteration: 118, Log-Lik: -33723.943, Max-Change: 0.00045Iteration: 119, Log-Lik: -33723.943, Max-Change: 0.00133Iteration: 120, Log-Lik: -33723.943, Max-Change: 0.00038Iteration: 121, Log-Lik: -33723.943, Max-Change: 0.00031Iteration: 122, Log-Lik: -33723.942, Max-Change: 0.00128Iteration: 123, Log-Lik: -33723.942, Max-Change: 0.00026Iteration: 124, Log-Lik: -33723.942, Max-Change: 0.00129Iteration: 125, Log-Lik: -33723.942, Max-Change: 0.00044Iteration: 126, Log-Lik: -33723.941, Max-Change: 0.00124Iteration: 127, Log-Lik: -33723.941, Max-Change: 0.00050Iteration: 128, Log-Lik: -33723.941, Max-Change: 0.00124Iteration: 129, Log-Lik: -33723.940, Max-Change: 0.00043Iteration: 130, Log-Lik: -33723.940, Max-Change: 0.00035Iteration: 131, Log-Lik: -33723.940, Max-Change: 0.00119Iteration: 132, Log-Lik: -33723.940, Max-Change: 0.00025Iteration: 133, Log-Lik: -33723.940, Max-Change: 0.00024Iteration: 134, Log-Lik: -33723.939, Max-Change: 0.00119Iteration: 135, Log-Lik: -33723.939, Max-Change: 0.00116Iteration: 136, Log-Lik: -33723.939, Max-Change: 0.00041Iteration: 137, Log-Lik: -33723.939, Max-Change: 0.00116Iteration: 138, Log-Lik: -33723.938, Max-Change: 0.00035Iteration: 139, Log-Lik: -33723.938, Max-Change: 0.00029Iteration: 140, Log-Lik: -33723.938, Max-Change: 0.00113Iteration: 141, Log-Lik: -33723.938, Max-Change: 0.00023Iteration: 142, Log-Lik: -33723.938, Max-Change: 0.00113Iteration: 143, Log-Lik: -33723.937, Max-Change: 0.00040Iteration: 144, Log-Lik: -33723.937, Max-Change: 0.00109Iteration: 145, Log-Lik: -33723.937, Max-Change: 0.00048Iteration: 146, Log-Lik: -33723.937, Max-Change: 0.00109Iteration: 147, Log-Lik: -33723.936, Max-Change: 0.00041Iteration: 148, Log-Lik: -33723.936, Max-Change: 0.00033Iteration: 149, Log-Lik: -33723.936, Max-Change: 0.00105Iteration: 150, Log-Lik: -33723.936, Max-Change: 0.00024Iteration: 151, Log-Lik: -33723.936, Max-Change: 0.00021Iteration: 152, Log-Lik: -33723.936, Max-Change: 0.00105Iteration: 153, Log-Lik: -33723.935, Max-Change: 0.00102Iteration: 154, Log-Lik: -33723.935, Max-Change: 0.00039Iteration: 155, Log-Lik: -33723.935, Max-Change: 0.00103Iteration: 156, Log-Lik: -33723.935, Max-Change: 0.00033Iteration: 157, Log-Lik: -33723.934, Max-Change: 0.00027Iteration: 158, Log-Lik: -33723.934, Max-Change: 0.00100Iteration: 159, Log-Lik: -33723.934, Max-Change: 0.00020Iteration: 160, Log-Lik: -33723.934, Max-Change: 0.00100Iteration: 161, Log-Lik: -33723.934, Max-Change: 0.00038Iteration: 162, Log-Lik: -33723.934, Max-Change: 0.00097Iteration: 163, Log-Lik: -33723.933, Max-Change: 0.00046Iteration: 164, Log-Lik: -33723.933, Max-Change: 0.00097Iteration: 165, Log-Lik: -33723.933, Max-Change: 0.00038Iteration: 166, Log-Lik: -33723.933, Max-Change: 0.00031Iteration: 167, Log-Lik: -33723.933, Max-Change: 0.00094Iteration: 168, Log-Lik: -33723.932, Max-Change: 0.00023Iteration: 169, Log-Lik: -33723.932, Max-Change: 0.00019Iteration: 170, Log-Lik: -33723.932, Max-Change: 0.00093Iteration: 171, Log-Lik: -33723.932, Max-Change: 0.00091Iteration: 172, Log-Lik: -33723.932, Max-Change: 0.00036Iteration: 173, Log-Lik: -33723.932, Max-Change: 0.00091Iteration: 174, Log-Lik: -33723.931, Max-Change: 0.00031Iteration: 175, Log-Lik: -33723.931, Max-Change: 0.00025Iteration: 176, Log-Lik: -33723.931, Max-Change: 0.00089Iteration: 177, Log-Lik: -33723.931, Max-Change: 0.00018Iteration: 178, Log-Lik: -33723.931, Max-Change: 0.00089Iteration: 179, Log-Lik: -33723.931, Max-Change: 0.00035Iteration: 180, Log-Lik: -33723.931, Max-Change: 0.00087Iteration: 181, Log-Lik: -33723.931, Max-Change: 0.00043Iteration: 182, Log-Lik: -33723.930, Max-Change: 0.00086Iteration: 183, Log-Lik: -33723.930, Max-Change: 0.00036Iteration: 184, Log-Lik: -33723.930, Max-Change: 0.00029Iteration: 185, Log-Lik: -33723.930, Max-Change: 0.00084Iteration: 186, Log-Lik: -33723.930, Max-Change: 0.00022Iteration: 187, Log-Lik: -33723.930, Max-Change: 0.00018Iteration: 188, Log-Lik: -33723.930, Max-Change: 0.00084Iteration: 189, Log-Lik: -33723.929, Max-Change: 0.00082Iteration: 190, Log-Lik: -33723.929, Max-Change: 0.00034Iteration: 191, Log-Lik: -33723.929, Max-Change: 0.00082Iteration: 192, Log-Lik: -33723.929, Max-Change: 0.00029Iteration: 193, Log-Lik: -33723.929, Max-Change: 0.00024Iteration: 194, Log-Lik: -33723.929, Max-Change: 0.00080Iteration: 195, Log-Lik: -33723.928, Max-Change: 0.00017Iteration: 196, Log-Lik: -33723.928, Max-Change: 0.00080Iteration: 197, Log-Lik: -33723.928, Max-Change: 0.00033Iteration: 198, Log-Lik: -33723.928, Max-Change: 0.00078Iteration: 199, Log-Lik: -33723.928, Max-Change: 0.00041Iteration: 200, Log-Lik: -33723.928, Max-Change: 0.00078Iteration: 201, Log-Lik: -33723.928, Max-Change: 0.00034Iteration: 202, Log-Lik: -33723.927, Max-Change: 0.00027Iteration: 203, Log-Lik: -33723.927, Max-Change: 0.00076Iteration: 204, Log-Lik: -33723.927, Max-Change: 0.00020Iteration: 205, Log-Lik: -33723.927, Max-Change: 0.00017Iteration: 206, Log-Lik: -33723.927, Max-Change: 0.00075Iteration: 207, Log-Lik: -33723.927, Max-Change: 0.00074Iteration: 208, Log-Lik: -33723.927, Max-Change: 0.00032Iteration: 209, Log-Lik: -33723.927, Max-Change: 0.00074Iteration: 210, Log-Lik: -33723.926, Max-Change: 0.00027Iteration: 211, Log-Lik: -33723.926, Max-Change: 0.00022Iteration: 212, Log-Lik: -33723.926, Max-Change: 0.00072Iteration: 213, Log-Lik: -33723.926, Max-Change: 0.00016Iteration: 214, Log-Lik: -33723.926, Max-Change: 0.00072Iteration: 215, Log-Lik: -33723.926, Max-Change: 0.00031Iteration: 216, Log-Lik: -33723.926, Max-Change: 0.00071Iteration: 217, Log-Lik: -33723.926, Max-Change: 0.00038Iteration: 218, Log-Lik: -33723.925, Max-Change: 0.00071Iteration: 219, Log-Lik: -33723.925, Max-Change: 0.00032Iteration: 220, Log-Lik: -33723.925, Max-Change: 0.00026Iteration: 221, Log-Lik: -33723.925, Max-Change: 0.00069Iteration: 222, Log-Lik: -33723.925, Max-Change: 0.00019Iteration: 223, Log-Lik: -33723.925, Max-Change: 0.00016Iteration: 224, Log-Lik: -33723.925, Max-Change: 0.00069Iteration: 225, Log-Lik: -33723.925, Max-Change: 0.00068Iteration: 226, Log-Lik: -33723.925, Max-Change: 0.00031Iteration: 227, Log-Lik: -33723.924, Max-Change: 0.00068Iteration: 228, Log-Lik: -33723.924, Max-Change: 0.00026Iteration: 229, Log-Lik: -33723.924, Max-Change: 0.00021Iteration: 230, Log-Lik: -33723.924, Max-Change: 0.00066Iteration: 231, Log-Lik: -33723.924, Max-Change: 0.00016Iteration: 232, Log-Lik: -33723.924, Max-Change: 0.00066Iteration: 233, Log-Lik: -33723.924, Max-Change: 0.00030Iteration: 234, Log-Lik: -33723.924, Max-Change: 0.00065Iteration: 235, Log-Lik: -33723.924, Max-Change: 0.00037Iteration: 236, Log-Lik: -33723.923, Max-Change: 0.00065Iteration: 237, Log-Lik: -33723.923, Max-Change: 0.00030Iteration: 238, Log-Lik: -33723.923, Max-Change: 0.00025Iteration: 239, Log-Lik: -33723.923, Max-Change: 0.00063Iteration: 240, Log-Lik: -33723.923, Max-Change: 0.00019Iteration: 241, Log-Lik: -33723.923, Max-Change: 0.00076Iteration: 242, Log-Lik: -33723.923, Max-Change: 0.00035Iteration: 243, Log-Lik: -33723.923, Max-Change: 0.00065Iteration: 244, Log-Lik: -33723.923, Max-Change: 0.00045Iteration: 245, Log-Lik: -33723.922, Max-Change: 0.00016Iteration: 246, Log-Lik: -33723.922, Max-Change: 0.00062Iteration: 247, Log-Lik: -33723.922, Max-Change: 0.00020Iteration: 248, Log-Lik: -33723.922, Max-Change: 0.00060Iteration: 249, Log-Lik: -33723.922, Max-Change: 0.00074Iteration: 250, Log-Lik: -33723.922, Max-Change: 0.00032Iteration: 251, Log-Lik: -33723.922, Max-Change: 0.00060Iteration: 252, Log-Lik: -33723.921, Max-Change: 0.00025Iteration: 253, Log-Lik: -33723.921, Max-Change: 0.00020Iteration: 254, Log-Lik: -33723.921, Max-Change: 0.00059Iteration: 255, Log-Lik: -33723.921, Max-Change: 0.00017Iteration: 256, Log-Lik: -33723.921, Max-Change: 0.00069Iteration: 257, Log-Lik: -33723.921, Max-Change: 0.00029Iteration: 258, Log-Lik: -33723.921, Max-Change: 0.00058Iteration: 259, Log-Lik: -33723.921, Max-Change: 0.00038Iteration: 260, Log-Lik: -33723.921, Max-Change: 0.00071Iteration: 261, Log-Lik: -33723.921, Max-Change: 0.00030Iteration: 262, Log-Lik: -33723.921, Max-Change: 0.00024Iteration: 263, Log-Lik: -33723.920, Max-Change: 0.00057Iteration: 264, Log-Lik: -33723.920, Max-Change: 0.00020Iteration: 265, Log-Lik: -33723.920, Max-Change: 0.00016Iteration: 266, Log-Lik: -33723.920, Max-Change: 0.00056Iteration: 267, Log-Lik: -33723.920, Max-Change: 0.00061Iteration: 268, Log-Lik: -33723.920, Max-Change: 0.00030Iteration: 269, Log-Lik: -33723.920, Max-Change: 0.00056Iteration: 270, Log-Lik: -33723.920, Max-Change: 0.00023Iteration: 271, Log-Lik: -33723.920, Max-Change: 0.00019Iteration: 272, Log-Lik: -33723.920, Max-Change: 0.00055Iteration: 273, Log-Lik: -33723.919, Max-Change: 0.00078Iteration: 274, Log-Lik: -33723.919, Max-Change: 0.00030Iteration: 275, Log-Lik: -33723.919, Max-Change: 0.00054Iteration: 276, Log-Lik: -33723.919, Max-Change: 0.00025Iteration: 277, Log-Lik: -33723.919, Max-Change: 0.00020Iteration: 278, Log-Lik: -33723.919, Max-Change: 0.00055Iteration: 279, Log-Lik: -33723.919, Max-Change: 0.00015Iteration: 280, Log-Lik: -33723.919, Max-Change: 0.00063Iteration: 281, Log-Lik: -33723.919, Max-Change: 0.00028Iteration: 282, Log-Lik: -33723.919, Max-Change: 0.00055Iteration: 283, Log-Lik: -33723.919, Max-Change: 0.00036Iteration: 284, Log-Lik: -33723.918, Max-Change: 0.00065Iteration: 285, Log-Lik: -33723.918, Max-Change: 0.00029Iteration: 286, Log-Lik: -33723.918, Max-Change: 0.00024Iteration: 287, Log-Lik: -33723.918, Max-Change: 0.00054Iteration: 288, Log-Lik: -33723.918, Max-Change: 0.00018Iteration: 289, Log-Lik: -33723.918, Max-Change: 0.00015Iteration: 290, Log-Lik: -33723.918, Max-Change: 0.00054Iteration: 291, Log-Lik: -33723.918, Max-Change: 0.00062Iteration: 292, Log-Lik: -33723.918, Max-Change: 0.00028Iteration: 293, Log-Lik: -33723.918, Max-Change: 0.00054Iteration: 294, Log-Lik: -33723.917, Max-Change: 0.00023Iteration: 295, Log-Lik: -33723.917, Max-Change: 0.00019Iteration: 296, Log-Lik: -33723.917, Max-Change: 0.00054Iteration: 297, Log-Lik: -33723.917, Max-Change: 0.00071Iteration: 298, Log-Lik: -33723.917, Max-Change: 0.00030Iteration: 299, Log-Lik: -33723.917, Max-Change: 0.00055Iteration: 300, Log-Lik: -33723.917, Max-Change: 0.00023Iteration: 301, Log-Lik: -33723.917, Max-Change: 0.00019Iteration: 302, Log-Lik: -33723.917, Max-Change: 0.00054Iteration: 303, Log-Lik: -33723.917, Max-Change: 0.00015Iteration: 304, Log-Lik: -33723.917, Max-Change: 0.00063Iteration: 305, Log-Lik: -33723.917, Max-Change: 0.00027Iteration: 306, Log-Lik: -33723.916, Max-Change: 0.00054Iteration: 307, Log-Lik: -33723.916, Max-Change: 0.00035Iteration: 308, Log-Lik: -33723.916, Max-Change: 0.00065Iteration: 309, Log-Lik: -33723.916, Max-Change: 0.00027Iteration: 310, Log-Lik: -33723.916, Max-Change: 0.00022Iteration: 311, Log-Lik: -33723.916, Max-Change: 0.00054Iteration: 312, Log-Lik: -33723.916, Max-Change: 0.00018Iteration: 313, Log-Lik: -33723.916, Max-Change: 0.00015Iteration: 314, Log-Lik: -33723.916, Max-Change: 0.00054Iteration: 315, Log-Lik: -33723.916, Max-Change: 0.00057Iteration: 316, Log-Lik: -33723.916, Max-Change: 0.00028Iteration: 317, Log-Lik: -33723.915, Max-Change: 0.00054Iteration: 318, Log-Lik: -33723.915, Max-Change: 0.00021Iteration: 319, Log-Lik: -33723.915, Max-Change: 0.00017Iteration: 320, Log-Lik: -33723.915, Max-Change: 0.00053Iteration: 321, Log-Lik: -33723.915, Max-Change: 0.00071Iteration: 322, Log-Lik: -33723.915, Max-Change: 0.00028Iteration: 323, Log-Lik: -33723.915, Max-Change: 0.00053Iteration: 324, Log-Lik: -33723.915, Max-Change: 0.00023Iteration: 325, Log-Lik: -33723.915, Max-Change: 0.00018Iteration: 326, Log-Lik: -33723.915, Max-Change: 0.00053Iteration: 327, Log-Lik: -33723.915, Max-Change: 0.00014Iteration: 328, Log-Lik: -33723.915, Max-Change: 0.00059Iteration: 329, Log-Lik: -33723.914, Max-Change: 0.00026Iteration: 330, Log-Lik: -33723.914, Max-Change: 0.00053Iteration: 331, Log-Lik: -33723.914, Max-Change: 0.00033Iteration: 332, Log-Lik: -33723.914, Max-Change: 0.00060Iteration: 333, Log-Lik: -33723.914, Max-Change: 0.00027Iteration: 334, Log-Lik: -33723.914, Max-Change: 0.00022Iteration: 335, Log-Lik: -33723.914, Max-Change: 0.00053Iteration: 336, Log-Lik: -33723.914, Max-Change: 0.00017Iteration: 337, Log-Lik: -33723.914, Max-Change: 0.00014Iteration: 338, Log-Lik: -33723.914, Max-Change: 0.00053Iteration: 339, Log-Lik: -33723.914, Max-Change: 0.00057Iteration: 340, Log-Lik: -33723.913, Max-Change: 0.00026Iteration: 341, Log-Lik: -33723.913, Max-Change: 0.00052Iteration: 342, Log-Lik: -33723.913, Max-Change: 0.00021Iteration: 343, Log-Lik: -33723.913, Max-Change: 0.00017Iteration: 344, Log-Lik: -33723.913, Max-Change: 0.00053Iteration: 345, Log-Lik: -33723.913, Max-Change: 0.00067Iteration: 346, Log-Lik: -33723.913, Max-Change: 0.00027Iteration: 347, Log-Lik: -33723.913, Max-Change: 0.00052Iteration: 348, Log-Lik: -33723.913, Max-Change: 0.00021Iteration: 349, Log-Lik: -33723.913, Max-Change: 0.00017Iteration: 350, Log-Lik: -33723.913, Max-Change: 0.00052Iteration: 351, Log-Lik: -33723.913, Max-Change: 0.00014Iteration: 352, Log-Lik: -33723.913, Max-Change: 0.00059Iteration: 353, Log-Lik: -33723.912, Max-Change: 0.00025Iteration: 354, Log-Lik: -33723.912, Max-Change: 0.00052Iteration: 355, Log-Lik: -33723.912, Max-Change: 0.00033Iteration: 356, Log-Lik: -33723.912, Max-Change: 0.00060Iteration: 357, Log-Lik: -33723.912, Max-Change: 0.00026Iteration: 358, Log-Lik: -33723.912, Max-Change: 0.00021Iteration: 359, Log-Lik: -33723.912, Max-Change: 0.00052Iteration: 360, Log-Lik: -33723.912, Max-Change: 0.00017Iteration: 361, Log-Lik: -33723.912, Max-Change: 0.00014Iteration: 362, Log-Lik: -33723.912, Max-Change: 0.00052Iteration: 363, Log-Lik: -33723.912, Max-Change: 0.00053Iteration: 364, Log-Lik: -33723.912, Max-Change: 0.00026Iteration: 365, Log-Lik: -33723.911, Max-Change: 0.00052Iteration: 366, Log-Lik: -33723.911, Max-Change: 0.00020Iteration: 367, Log-Lik: -33723.911, Max-Change: 0.00016Iteration: 368, Log-Lik: -33723.911, Max-Change: 0.00051Iteration: 369, Log-Lik: -33723.911, Max-Change: 0.00066Iteration: 370, Log-Lik: -33723.911, Max-Change: 0.00026Iteration: 371, Log-Lik: -33723.911, Max-Change: 0.00051Iteration: 372, Log-Lik: -33723.911, Max-Change: 0.00021Iteration: 373, Log-Lik: -33723.911, Max-Change: 0.00017Iteration: 374, Log-Lik: -33723.911, Max-Change: 0.00051Iteration: 375, Log-Lik: -33723.911, Max-Change: 0.00013Iteration: 376, Log-Lik: -33723.911, Max-Change: 0.00055Iteration: 377, Log-Lik: -33723.911, Max-Change: 0.00025Iteration: 378, Log-Lik: -33723.910, Max-Change: 0.00051Iteration: 379, Log-Lik: -33723.910, Max-Change: 0.00031Iteration: 380, Log-Lik: -33723.910, Max-Change: 0.00057Iteration: 381, Log-Lik: -33723.910, Max-Change: 0.00025Iteration: 382, Log-Lik: -33723.910, Max-Change: 0.00021Iteration: 383, Log-Lik: -33723.910, Max-Change: 0.00051Iteration: 384, Log-Lik: -33723.910, Max-Change: 0.00016Iteration: 385, Log-Lik: -33723.910, Max-Change: 0.00013Iteration: 386, Log-Lik: -33723.910, Max-Change: 0.00051Iteration: 387, Log-Lik: -33723.910, Max-Change: 0.00053Iteration: 388, Log-Lik: -33723.910, Max-Change: 0.00025Iteration: 389, Log-Lik: -33723.910, Max-Change: 0.00050Iteration: 390, Log-Lik: -33723.909, Max-Change: 0.00020Iteration: 391, Log-Lik: -33723.909, Max-Change: 0.00016Iteration: 392, Log-Lik: -33723.909, Max-Change: 0.00050Iteration: 393, Log-Lik: -33723.909, Max-Change: 0.00063Iteration: 394, Log-Lik: -33723.909, Max-Change: 0.00026Iteration: 395, Log-Lik: -33723.909, Max-Change: 0.00050Iteration: 396, Log-Lik: -33723.909, Max-Change: 0.00020Iteration: 397, Log-Lik: -33723.909, Max-Change: 0.00017Iteration: 398, Log-Lik: -33723.909, Max-Change: 0.00050Iteration: 399, Log-Lik: -33723.909, Max-Change: 0.00013Iteration: 400, Log-Lik: -33723.909, Max-Change: 0.00055Iteration: 401, Log-Lik: -33723.909, Max-Change: 0.00024Iteration: 402, Log-Lik: -33723.909, Max-Change: 0.00050Iteration: 403, Log-Lik: -33723.909, Max-Change: 0.00031Iteration: 404, Log-Lik: -33723.908, Max-Change: 0.00057Iteration: 405, Log-Lik: -33723.908, Max-Change: 0.00024Iteration: 406, Log-Lik: -33723.908, Max-Change: 0.00020Iteration: 407, Log-Lik: -33723.908, Max-Change: 0.00050Iteration: 408, Log-Lik: -33723.908, Max-Change: 0.00016Iteration: 409, Log-Lik: -33723.908, Max-Change: 0.00065Iteration: 410, Log-Lik: -33723.908, Max-Change: 0.00028Iteration: 411, Log-Lik: -33723.908, Max-Change: 0.00051Iteration: 412, Log-Lik: -33723.908, Max-Change: 0.00038Iteration: 413, Log-Lik: -33723.908, Max-Change: 0.00014Iteration: 414, Log-Lik: -33723.908, Max-Change: 0.00049Iteration: 415, Log-Lik: -33723.908, Max-Change: 0.00016Iteration: 416, Log-Lik: -33723.907, Max-Change: 0.00049Iteration: 417, Log-Lik: -33723.907, Max-Change: 0.00065Iteration: 418, Log-Lik: -33723.907, Max-Change: 0.00026Iteration: 419, Log-Lik: -33723.907, Max-Change: 0.00049Iteration: 420, Log-Lik: -33723.907, Max-Change: 0.00021Iteration: 421, Log-Lik: -33723.907, Max-Change: 0.00017Iteration: 422, Log-Lik: -33723.907, Max-Change: 0.00049Iteration: 423, Log-Lik: -33723.907, Max-Change: 0.00013Iteration: 424, Log-Lik: -33723.907, Max-Change: 0.00054Iteration: 425, Log-Lik: -33723.907, Max-Change: 0.00024Iteration: 426, Log-Lik: -33723.907, Max-Change: 0.00049Iteration: 427, Log-Lik: -33723.907, Max-Change: 0.00031Iteration: 428, Log-Lik: -33723.907, Max-Change: 0.00056Iteration: 429, Log-Lik: -33723.907, Max-Change: 0.00024Iteration: 430, Log-Lik: -33723.906, Max-Change: 0.00020Iteration: 431, Log-Lik: -33723.906, Max-Change: 0.00048Iteration: 432, Log-Lik: -33723.906, Max-Change: 0.00016Iteration: 433, Log-Lik: -33723.906, Max-Change: 0.00064Iteration: 434, Log-Lik: -33723.906, Max-Change: 0.00028Iteration: 435, Log-Lik: -33723.906, Max-Change: 0.00052Iteration: 436, Log-Lik: -33723.906, Max-Change: 0.00038Iteration: 437, Log-Lik: -33723.906, Max-Change: 0.00014Iteration: 438, Log-Lik: -33723.906, Max-Change: 0.00048Iteration: 439, Log-Lik: -33723.906, Max-Change: 0.00016Iteration: 440, Log-Lik: -33723.906, Max-Change: 0.00048Iteration: 441, Log-Lik: -33723.906, Max-Change: 0.00064Iteration: 442, Log-Lik: -33723.906, Max-Change: 0.00026Iteration: 443, Log-Lik: -33723.905, Max-Change: 0.00048Iteration: 444, Log-Lik: -33723.905, Max-Change: 0.00020Iteration: 445, Log-Lik: -33723.905, Max-Change: 0.00017Iteration: 446, Log-Lik: -33723.905, Max-Change: 0.00048Iteration: 447, Log-Lik: -33723.905, Max-Change: 0.00013Iteration: 448, Log-Lik: -33723.905, Max-Change: 0.00055Iteration: 449, Log-Lik: -33723.905, Max-Change: 0.00024Iteration: 450, Log-Lik: -33723.905, Max-Change: 0.00047Iteration: 451, Log-Lik: -33723.905, Max-Change: 0.00031Iteration: 452, Log-Lik: -33723.905, Max-Change: 0.00056Iteration: 453, Log-Lik: -33723.905, Max-Change: 0.00024Iteration: 454, Log-Lik: -33723.905, Max-Change: 0.00020Iteration: 455, Log-Lik: -33723.905, Max-Change: 0.00047Iteration: 456, Log-Lik: -33723.904, Max-Change: 0.00016Iteration: 457, Log-Lik: -33723.904, Max-Change: 0.00065Iteration: 458, Log-Lik: -33723.904, Max-Change: 0.00028Iteration: 459, Log-Lik: -33723.904, Max-Change: 0.00051Iteration: 460, Log-Lik: -33723.904, Max-Change: 0.00038Iteration: 461, Log-Lik: -33723.904, Max-Change: 0.00014Iteration: 462, Log-Lik: -33723.904, Max-Change: 0.00047Iteration: 463, Log-Lik: -33723.904, Max-Change: 0.00016Iteration: 464, Log-Lik: -33723.904, Max-Change: 0.00047Iteration: 465, Log-Lik: -33723.904, Max-Change: 0.00065Iteration: 466, Log-Lik: -33723.904, Max-Change: 0.00026Iteration: 467, Log-Lik: -33723.904, Max-Change: 0.00047Iteration: 468, Log-Lik: -33723.904, Max-Change: 0.00021Iteration: 469, Log-Lik: -33723.904, Max-Change: 0.00017Iteration: 470, Log-Lik: -33723.903, Max-Change: 0.00046Iteration: 471, Log-Lik: -33723.903, Max-Change: 0.00013Iteration: 472, Log-Lik: -33723.903, Max-Change: 0.00054Iteration: 473, Log-Lik: -33723.903, Max-Change: 0.00024Iteration: 474, Log-Lik: -33723.903, Max-Change: 0.00046Iteration: 475, Log-Lik: -33723.903, Max-Change: 0.00031Iteration: 476, Log-Lik: -33723.903, Max-Change: 0.00056Iteration: 477, Log-Lik: -33723.903, Max-Change: 0.00024Iteration: 478, Log-Lik: -33723.903, Max-Change: 0.00020Iteration: 479, Log-Lik: -33723.903, Max-Change: 0.00046Iteration: 480, Log-Lik: -33723.903, Max-Change: 0.00016Iteration: 481, Log-Lik: -33723.903, Max-Change: 0.00065Iteration: 482, Log-Lik: -33723.903, Max-Change: 0.00028Iteration: 483, Log-Lik: -33723.903, Max-Change: 0.00052Iteration: 484, Log-Lik: -33723.903, Max-Change: 0.00038Iteration: 485, Log-Lik: -33723.902, Max-Change: 0.00014Iteration: 486, Log-Lik: -33723.902, Max-Change: 0.00045Iteration: 487, Log-Lik: -33723.902, Max-Change: 0.00016Iteration: 488, Log-Lik: -33723.902, Max-Change: 0.00045Iteration: 489, Log-Lik: -33723.902, Max-Change: 0.00064Iteration: 490, Log-Lik: -33723.902, Max-Change: 0.00026Iteration: 491, Log-Lik: -33723.902, Max-Change: 0.00047Iteration: 492, Log-Lik: -33723.902, Max-Change: 0.00020Iteration: 493, Log-Lik: -33723.902, Max-Change: 0.00017Iteration: 494, Log-Lik: -33723.902, Max-Change: 0.00045Iteration: 495, Log-Lik: -33723.902, Max-Change: 0.00013Iteration: 496, Log-Lik: -33723.902, Max-Change: 0.00055Iteration: 497, Log-Lik: -33723.902, Max-Change: 0.00024Iteration: 498, Log-Lik: -33723.901, Max-Change: 0.00045Iteration: 499, Log-Lik: -33723.901, Max-Change: 0.00031Iteration: 500, Log-Lik: -33723.901, Max-Change: 0.00056
## Warning in EM.group(pars = pars, constrain = constrain, Ls = Ls, PrepList =
## PrepList, : EM cycles terminated after 500 iterations.
# Output the summary of the model
summary(model_3pl)
## F1 h2
## Item_1 0.826 0.6819
## Item_2 0.204 0.0415
## Item_3 0.954 0.9096
## Item_4 0.548 0.3008
## Item_5 0.983 0.9660
## Item_6 0.832 0.6918
## Item_7 0.859 0.7380
## Item_8 0.118 0.0138
## Item_9 0.191 0.0366
## Item_10 0.955 0.9121
## Item_11 0.175 0.0307
## Item_12 0.768 0.5891
## Item_13 0.998 0.9955
## Item_14 0.226 0.0511
## Item_15 0.972 0.9457
## Item_16 0.227 0.0516
## Item_17 0.171 0.0292
## Item_18 0.906 0.8204
## Item_19 0.207 0.0429
## Item_20 0.251 0.0632
## Item_21 0.311 0.0969
## Item_22 0.846 0.7154
## Item_23 0.970 0.9401
##
## SS loadings: 10.664
## Proportion Var: 0.464
##
## Factor correlations:
##
## F1
## F1 1
# Extract item coefficients from the 3PL model
item_stats <- coef(model_3pl, IRTpars=TRUE, simplify=TRUE)
# View the item statistics table
item_stats
## $items
## a b g u
## Item_1 2.492 0.831 0.266 1
## Item_2 0.354 5.704 0.000 1
## Item_3 5.398 3.021 0.036 1
## Item_4 1.116 -0.210 0.001 1
## Item_5 9.067 0.617 0.041 1
## Item_6 2.550 0.715 0.058 1
## Item_7 2.856 0.640 0.144 1
## Item_8 0.202 -7.628 0.005 1
## Item_9 0.332 2.236 0.001 1
## Item_10 5.483 0.344 0.226 1
## Item_11 0.303 5.393 0.000 1
## Item_12 2.038 -0.044 0.000 1
## Item_13 25.185 0.781 0.008 1
## Item_14 0.395 1.694 0.000 1
## Item_15 7.104 0.519 0.026 1
## Item_16 0.397 1.171 0.000 1
## Item_17 0.295 -0.695 0.001 1
## Item_18 3.637 0.316 0.170 1
## Item_19 0.360 1.385 0.002 1
## Item_20 0.442 1.708 0.000 1
## Item_21 0.557 1.793 0.000 1
## Item_22 2.699 -0.085 0.663 1
## Item_23 6.744 0.510 0.060 1
##
## $means
## F1
## 0
##
## $cov
## F1
## F1 1
# Create the data frame from the provided item statistics
item_stats <- data.frame(
item = paste0("Item_", 1:23),
a = c(2.492, 0.354, 5.398, 1.116, 9.066, 2.550, 2.856, 0.202, 0.332, 5.483,
0.303, 2.038, 25.185, 0.395, 7.104, 0.397, 0.295, 3.637, 0.360, 0.442,
0.557, 2.699, 6.744),
b = c(0.831, 5.704, 3.021, -0.210, 0.617, 0.715, 0.640, -7.629, 2.236, 0.344,
5.393, -0.045, 0.781, 1.694, 0.519, 1.171, -0.695, 0.316, 1.385, 1.708,
1.793, -0.085, 0.510),
g = c(0.266, 0, 0.036, 0.001, 0.041, 0.058, 0.144, 0.005, 0.001, 0.226,
0, 0, 0.008, 0, 0.026, 0, 0.001, 0.170, 0.002, 0, 0, 0.663, 0.060)
)
# Find the easiest item (lowest b value)
easiest_item <- item_stats[which.min(item_stats$b),]
# Find the most difficult item (highest b value)
most_difficult_item <- item_stats[which.max(item_stats$b),]
# Output the easiest and most difficult items
easiest_item
## item a b g
## 8 Item_8 0.202 -7.629 0.005
most_difficult_item
## item a b g
## 2 Item_2 0.354 5.704 0
# Plot the ICC for Item 2 using the mirt package.
cat("Plotting ICC for Item 2\n")
## Plotting ICC for Item 2
plot(model_3pl, type = "trace", which.items = 2)
# Plot the ICC for Item 8 using the mirt package.
cat("Plotting ICC for Item 8\n")
## Plotting ICC for Item 8
plot(model_3pl, type = "trace", which.items = 8)
# Obtain item parameter estimates from the 3PL model output
item_params <- coef(model_3pl, IRTpars=TRUE, simplify=TRUE)
# Convert the list of item parameters to a data frame for easier manipulation
item_params_df <- as.data.frame(item_params)
# Rename the columns clearly for discrimination, difficulty, and guessing parameters
colnames(item_params_df) <- c("discrimination", "difficulty", "guessing")
# Output the full item parameter estimates to review
item_params_df
## discrimination difficulty guessing NA NA NA
## Item_1 2.4922223 0.83095722 0.2659943422 1 0 1
## Item_2 0.3543205 5.70357768 0.0003126850 1 0 1
## Item_3 5.3982546 3.02091959 0.0362084624 1 0 1
## Item_4 1.1164291 -0.21018070 0.0008037071 1 0 1
## Item_5 9.0665403 0.61685183 0.0409710976 1 0 1
## Item_6 2.5497818 0.71522453 0.0579314698 1 0 1
## Item_7 2.8564377 0.63997273 0.1441641991 1 0 1
## Item_8 0.2015628 -7.62810821 0.0047470592 1 0 1
## Item_9 0.3316297 2.23605642 0.0006417787 1 0 1
## Item_10 5.4832626 0.34446911 0.2255452890 1 0 1
## Item_11 0.3026939 5.39324989 0.0004724840 1 0 1
## Item_12 2.0379277 -0.04446747 0.0003560075 1 0 1
## Item_13 25.1847412 0.78061500 0.0081552884 1 0 1
## Item_14 0.3950907 1.69416520 0.0004645945 1 0 1
## Item_15 7.1042370 0.51866307 0.0262039360 1 0 1
## Item_16 0.3968793 1.17123768 0.0004225091 1 0 1
## Item_17 0.2951926 -0.69509842 0.0011984018 1 0 1
## Item_18 3.6370865 0.31634713 0.1699981483 1 0 1
## Item_19 0.3603339 1.38526002 0.0018273478 1 0 1
## Item_20 0.4420488 1.70805805 0.0004531190 1 0 1
## Item_21 0.5574628 1.79315783 0.0001501595 1 0 1
## Item_22 2.6987073 -0.08458097 0.6628333281 1 0 1
## Item_23 6.7442218 0.51017663 0.0600386775 1 0 1
# Plot the test information function (TIF)
cat("Plotting the Test Information Function\n")
## Plotting the Test Information Function
info_plot <- plot(model_3pl, type = "info", main = "Test Information Function")
# Calculate the standard error function from the information
# SE(θ) = 1 / sqrt(I(θ))
theta_vals <- seq(-4, 4, by=0.1)
info_vals <- testinfo(model_3pl, Theta = theta_vals)
se_vals <- 1 / sqrt(info_vals)
# Plot the standard error function
cat("Plotting the Standard Error Function\n")
## Plotting the Standard Error Function
plot(theta_vals, se_vals, type = "l", col = "blue", lwd = 2,
xlab = "Ability (θ)", ylab = "Standard Error",
main = "Standard Error Function")
# Add a grid for better visualization
grid()
# Display both plots
info_plot
# Count the number of correct answers for each examinee
correct_counts <- rowSums(item_data)
# Find two examinees who answered the same number of items correctly
# Get the indices of two examinees with the same score
same_score_examinees <- which(correct_counts == correct_counts[1])[1:2]
# Extract the item response patterns for these two examinees
examinee_1 <- item_data[same_score_examinees[1], ]
examinee_2 <- item_data[same_score_examinees[2], ]
# Check their raw scores (number of correct answers)
cat("Examinee 1 Correct Answers: ", sum(examinee_1), "\n")
## Examinee 1 Correct Answers: 2
cat("Examinee 2 Correct Answers: ", sum(examinee_2), "\n")
## Examinee 2 Correct Answers: 2
# Estimate abilities for all examinees
abilities <- fscores(model_3pl)
# Retrieve and compare the ability estimates for these two examinees
cat("Examinee 1 Ability Estimate: ", abilities[same_score_examinees[1], ], "\n")
## Examinee 1 Ability Estimate: -1.230896
cat("Examinee 2 Ability Estimate: ", abilities[same_score_examinees[2], ], "\n")
## Examinee 2 Ability Estimate: -1.393466
```