Introduction

This is an RMarkdown document displaying R code for a multi-faceted plot based on 2PL item characteristics. The basic structure of the plot is to graph items by their a and b parameters as y and x axes, respectively.

In addition to this, three cut-scores are represented by three different colored vertical lines.

Lastly, item information for each item is calculated for each cut-score and summarized in a color-based visual in the plot. Specifically, plotted points of items will match the color of the cut-score they provide the most information towards. Items that provide minimal information at each cut-score will be black.

Item parameters and cut-scores are randomly generated for 30 items for 3 different tests. B parameters and cut-scores are simulated so as to come from different distributions for each specific test.

This plot was created with the intention of providing a unique dynamic visual of 2PL item characteristics.

Simulation of Cut-scores and Item Parameters and Data Frame Preparation

The first block of code accomplished the following:

  1. Load appropriate R packages.
  2. Simulate 3 cut-scores for 3 different tests.
  3. Simulate a and b parameters for 30 items for 3 different tests.
  4. Coerce all components into a single data frame.
library(ggplot2)
library(plyr)
library(dplyr)

Test <- c(rep(1, 30), rep(2, 30), rep(3, 30))
Test <- data.frame(Test)

Cut_1 <- c(rep(rnorm(1,-1,.2),30), rep(rnorm(1,-1,.2),30), rep(rnorm(1,-1,.2),30))
Cut_2 <- c(rep(rnorm(1,0,.2),30), rep(rnorm(1,0,.2),30), rep(rnorm(1,0,.2),30))
Cut_3 <- c(rep(rnorm(1,1,.2),30), rep(rnorm(1,1,.2),30), rep(rnorm(1,1,.2),30))

a <- rnorm(90, 1.25, .33)
b <- c(rnorm(30, -.25, .9), rnorm(30, 0, 1), rnorm(30, .25, .9))

a <- as.data.frame(a)
b <- as.data.frame(b)

Item_set <- cbind(Test, a, b, Cut_1, Cut_2, Cut_3)

Calculate Item Information (2PL Model) and Flag Items Based on Information

The following section of code will calculate item information for each item at each of the three corresponding test cut-scores. The items are then flagged in the following manner:

  1. Flagged as “1” if information is too low for all cut-scores.
  2. If not a “1”, then flag as “2”, “3”, or “4” depending on which cut-score the item provides most information towards.

The flagged value will be used to color the points on the plot.

Item_set <- Item_set %>% mutate(Inf_1 = (a^2)*(1/(1 + exp(-a*(Cut_1-b))))*(exp(-a*(Cut_1-b))/(1 + exp(-a*(Cut_1-b)))))

Item_set <- Item_set %>% mutate(Inf_2 = (a^2)*(1/(1 + exp(-a*(Cut_2-b))))*(exp(-a*(Cut_2-b))/(1 + exp(-a*(Cut_2-b)))))

Item_set <- Item_set %>% mutate(Inf_3 = (a^2)*(1/(1 + exp(-a*(Cut_3-b))))*(exp(-a*(Cut_3-b))/(1 + exp(-a*(Cut_3-b)))))

Item_set <- Item_set %>% rowwise() %>% mutate(max_inf = max(Inf_1, Inf_2, Inf_3))
Item_set <- Item_set %>% mutate(flag = ifelse(max_inf < .1, 1, ifelse(max_inf == Inf_1, 2, ifelse(max_inf == Inf_2, 3, 4)))) 

Item_set <- as.data.frame(Item_set)
Item_set$flag <- as.factor(Item_set$flag)

Create Two-dimensional Item Plots for Each Test

The plots are then created for each test. The plot will allow a psychometrician to inspect several aspects of item-level characteristics for a given test:

  1. Overall distribution of discrimination.
  2. Overall distribution of difficulties.
  3. Flagging of low-discrimination items.
  4. Balance of items in terms of information provided across cut-scores.
colorset = c("1"="black","2"="indianred","3"="blue","4"="green3")

twodim_plot <- Item_set %>% ggplot(aes(x=b,y=a)) + geom_point(aes(color = flag)) + geom_vline(aes(xintercept = Cut_1), linetype ="dashed",color="indianred") +  geom_vline(aes(xintercept = Cut_2), linetype ="dashed",color="blue") +  geom_vline(aes(xintercept = Cut_3), linetype ="dashed",color="green3") + scale_color_manual(values = colorset) + ylim(0,3) + facet_wrap(~Test) 

twodim_plot