Introduction to Item response theory (rasch model using ltm package in R)

Unraveling the Mathematical Intricacies of Item Response Theory in Psychometrics

Psychometrics is a fascinating field that utilizes statistical methods to measure and assess psychological traits. One of the fundamental concepts within psychometrics is Item Response Theory (IRT), which offers a robust mathematical framework for analyzing and interpreting test responses. In this article, we will delve into the intricate details of IRT, exploring its mathematical foundations, key equations, and applications in psychometric testing using R code.

The Rasch Model

At the heart of IRT lies the Rasch model, which assumes that the probability of a correct response to an item depends solely on the individual’s latent trait level and the item’s characteristics. Let’s implement the Rasch model using R code:

# Rasch model function
rasch_model <- function(theta, a, b) {
  p <- exp(a * (theta - b)) / (1 + exp(a * (theta - b)))
  return(p)
}

Estimation of Item Parameters

To estimate item parameters, including item difficulty and discrimination, we can use maximum likelihood estimation (MLE) in R. Let’s create a function to estimate the parameters using MLE:

# Maximum likelihood estimation (MLE)
estimate_parameters <- function(X) {
  # X is the matrix of observed responses
  N <- nrow(X)  # Number of individuals
  J <- ncol(X)  # Number of items
  
  # Log-likelihood function
  log_likelihood <- function(theta, a, b) {
    p <- rasch_model(theta, a, b)
    log_likelihood <- sum(X * log(p) + (1 - X) * log(1 - p))
    return(-log_likelihood)  # Minimize negative log-likelihood
  }
  
  # Optimization
  result <- optim(par = rep(0, J*2), fn = log_likelihood, method = "BFGS")
  a <- result$par[1:J]
  b <- result$par[(J+1):(J*2)]
  
  return(list(a = a, b = b))
}

Test Information Function

To calculate the Test Information Function (TIF), we can use the item characteristic curves (ICC) and combine them to obtain the TIF. Let’s implement the TIF calculation in R:

# Calculate Test Information Function (TIF)
calculate_tif <- function(theta, a, b) {
  tif <- sum(a^2 * exp(a * (theta - b)) / (1 + exp(a * (theta - b)))^2)
  return(tif)
}

Item Information Function

The Item Information Function (IIF) provides information about the precision of measurement for each individual item. We can differentiate the item characteristic curves (ICC) with respect to the latent trait level to obtain the IIF. Here’s the R code for calculating the IIF:

# Calculate Item Information Function (IIF)
calculate_iif <- function(theta, a, b) {
  iif <- a^2 * exp(a * (theta - b)) / (1 + exp(a * (theta - b)))^2
  return(iif)
}

Test Characteristic Curve

The Test Characteristic Curve (TCC) shows the probability of a correct response to the test as a function of the latent trait level.

We can visualize the TCC using R code. Let’s assume we have item parameters a and b estimated from the data:

# Plot Test Characteristic Curve (TCC)
plot_tcc <- function(a, b) {
  theta <- seq(-3, 3, by = 0.1)
  tcc <- rasch_model(theta, a, b)
  plot(theta, tcc, type = "l", xlab = "Latent Trait Level", ylab = "Probability of Correct Response", main = "Test Characteristic Curve")
}

Example: Analyzing Data using ltm Package

To further demonstrate the practical application of Item Response Theory (IRT), let’s analyze some example data using the ltm package in R. The ltm package provides a comprehensive set of functions for estimating IRT models and conducting various analyses.

Suppose we have a dataset data that consists of responses to a test with 10 items from a group of individuals. Each row represents an individual’s responses to the items, where 1 denotes a correct response and 0 denotes an incorrect response. Let’s estimate the item parameters and examine the Test Information Function (TIF) and Test Characteristic Curve (TCC) for this test using the ltm package.

# Example Data
data <- matrix(c(1, 1, 0, 1, 0, 1, 1, 0, 1, 0,
                 1, 1, 1, 0, 0, 1, 0, 1, 1, 0,
                 1, 0, 0, 1, 1, 0, 1, 0, 0, 1), nrow = 3, ncol = 10, byrow = TRUE)

# Load ltm Package
library(ltm)

# Fit the Rasch Model
rasch_model <- rasch(data)

# Extract Item Parameters
a <- coef(rasch_model)
b <- rasch_model$items$difficulty

# Calculate Test Information Function (TIF)
theta <- seq(-3, 3, by = 0.1)
tif <- information(rasch_model, theta)

# Plot Test Characteristic Curve (TCC)
plot(rasch_model, type = "ICC")

# Estimate Individuals' Abilities
abilities <- factor.scores(rasch_model)

# Display Individuals' Abilities
print(abilities)
## 
## Call:
## rasch(data = data)
## 
## Scoring Method: Empirical Bayes
## 
## Factor-Scores for observed response patterns:
##   Item 1 Item 2 Item 3 Item 4 Item 5 Item 6 Item 7 Item 8 Item 9 Item 10 Obs
## 1      1      0      0      1      1      0      1      0      0       1   1
## 2      1      1      0      1      0      1      1      0      1       0   1
## 3      1      1      1      0      0      1      0      1      1       0   1
##     Exp     z1 se.z1
## 1 0.001 -0.031 0.067
## 2 0.021  0.016 0.067
## 3 0.001  0.016 0.067

In this example, we utilized the ltm package to estimate the item parameters a (discrimination) and b (difficulty) using the example data. We fit the Rasch model to the data, and then extracted the item parameters. We also calculated the Test Information Function (TIF) for a range of latent trait levels using the itemInformation function. Finally, we plotted the Test Characteristic Curve (TCC) using the plot function to visualize the probability of a correct response as a function of the latent trait level.

The ltm package provides a range of additional functionalities, including model fit assessment, item and person parameter estimation, and model comparison. These features enable researchers and practitioners to conduct in-depth analyses and make informed decisions based on the data.

The example dataset data represents responses to a test with 10 items from a group of individuals. Each row in the dataset corresponds to one individual, and their responses are coded as 1 for a correct response and 0 for an incorrect response.

We start by fitting a Rasch model to the data using the rasch() function from the ltm package. This model estimates the item parameters, which include the discrimination (a) and difficulty (b) of each item. These parameters help us understand how well each item differentiates between individuals with different levels of the latent trait being measured.

Next, we calculate the Test Information Function (TIF) using the information() function. The TIF tells us the amount of information the test provides at different levels of the latent trait. Higher values indicate that the test is more informative for assessing individuals with those trait levels.

We then plot the Test Characteristic Curve (TCC) using the plot() function. The TCC shows the probability of a correct response for each item as a function of the latent trait level. It helps visualize how item difficulty relates to individuals’ abilities.

Lastly, we estimate individuals’ abilities based on the fitted Rasch model using the factor.scores() function. These abilities represent the latent trait levels for each individual, indicating their proficiency on the test.

Overall, the code demonstrates how the ltm package in R can be used to estimate item parameters, assess the information provided by a test, visualize item characteristics, and estimate individuals’ abilities in the context of Item Response Theory.

Comments

Popular posts from this blog

What does it mean to integrate out a variable?

How to use Classical test theory to bring different tests on the same scale?

Gumble Max trick and softmax using R