Introduction

This is an RMarkdown document displaying R code for generated Conditional SEM plots for multiple tests. The plot is intended to display CSEM as a function of scaled score. Additionally, cut-scores are displayed as vertical dashed lines. The data is create three different parabolic shapes for CSEM across three hypothetical tests (not simulated).

The intent is to use this code as a flexible tool of visualizing CSEM in the case of multiple assessments.

Creation of Cut-score Data Frame

The first block of code accomplished the following:

  1. Load appropriate R packages.
  2. Create a data frame that will aid in displaying cut-scores on the CSEM plots (3 cut-scores are simulated for each of 3 tests).
library(ggplot2)
library(dplyr)

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

Cut_1 <- rnorm(3,300,25)
Cut_2 <- rnorm(3,400,25)
Cut_3 <- rnorm(3,500,25)

Cut_set <- cbind(Test, Cut_1, Cut_2, Cut_3)

Creation of Scale Score/CSEM Data Frame

The next chunk of code creates a data frame for a hypothetical set of CSEMs across scale scores for three separate tests. Scale scores are assumed to be on a range of 200-600 and three different parabolic shapes are chosen for each of the three tests to represent SEM as a function of scale score. The three parabolic functions are centered at three different points on the spectrum of scale scores.

A data frame is then created from these components.

Full_scale <- seq(200,600,5)

SEM1 <- 20+(.0005*((Full_scale - 400)^2))
SEM2 <- 20+(.0005*((Full_scale - 350)^2))
SEM3 <- 20+(.0005*((Full_scale - 450)^2))

Scale_score <- rep(seq(200,600,5),3)

SEM1 <- as.data.frame(SEM1)
SEM2 <- as.data.frame(SEM2)
SEM3 <- as.data.frame(SEM3)
Scale_score <- as.data.frame(Scale_score)

colnames(SEM1) <- "SEM"
colnames(SEM2) <- "SEM"
colnames(SEM3) <- "SEM"
Sem_set <- rbind(SEM1, SEM2, SEM3)

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

CSEM_set <- cbind(Test, Scale_score, Sem_set)

Creation of CSEM plots

The previous data frames are then used to create a set of CSEM plots. One plot is generated for each test and includes two elements: a line plot of SEM as a function of Scale Score, and vertical dashed lines presenting the different cut-scores.

csemplot <- CSEM_set %>% ggplot(aes(x = Scale_score, y = SEM)) + 
geom_line(color = "lightcoral") + 
geom_vline(data = Cut_set, aes(xintercept = Cut_1), linetype = "dashed", color = "black") + 
geom_vline(data = Cut_set, aes(xintercept = Cut_2), linetype = "dashed", color = "black") + 
geom_vline(data = Cut_set, aes(xintercept = Cut_3), linetype = "dashed", color = "black") + 
xlim(200,600) + ylim(0,40) + facet_wrap(~Test)

csemplot