knitr::opts_chunk$set(echo = TRUE) library(knitr)
psketti is a package for generating investigatory plots and tables for Rasch Analysis. Models should first be estimated using eRm, psketti then pskettifies your Rasch data and produces outputs using ggplot2.
devtools::install_github("SBGalvin/psketti") # install
Loading psketti will produce the below startup message. If any of the dependencies are already loaded, psketti will tell you. If the dependencies are not installed at the time of the loading, psketti will tell you which ones to install.
library(eRm) library(psketti)
----------------------------------------------------- Loading psketti v 0.1.0 Beta Software !!!! Dependencies: eRm (1.0.2) already loaded dplyr (1.0.4) already loaded ggplot2 (3.3.3) loaded by psketti viridis (0.5.1) loaded by psketti please install any NOT INSTALLED dependencies using: install.packages('dependency') -----------------------------------------------------
data("FakeData") # load data # restructure fake data Fake_Data_scores <- reshape(FakeData[, c("ID", "Item", "X")], timevar = "Item", idvar = "ID", direction = "wide") # for eRm new names names(Fake_Data_scores) <- c("ID", paste0("i", sprintf(fmt = "%02d", 1:23))) row.names(Fake_Data_scores) <- Fake_Data_scores$ID Fake_Data_scores$ID <- NULL fake_rm <- RM(Fake_Data_scores) # Estimate Rasch model
Convert your data into a format for psketti to use. Select confidence levels for empirical class interval values for empirical Item Characteristic Curves (ICC), and set the minimum and maximum x axis values for the Rasch Item Response Function (IRF).
psk_data <-pskettify(eRm.obj = fake_rm, conf.level = .95, Theta.lwr = -6, Theta.upr = 6)
Plot IRFs for individual items with empirical ICC, and class interval averages with confidence intervals
# plot ICC for one item psk_1_present <- psketto(psk_data, style = "present", item = "i01", item.label = "i01") psk_1_present
psk_1_print <- psketto(psk_data, style = "print", item = "i01", item.label = "i01") psk_1_print
...or use psketti() to plot ICC for all plots. psketti()
objects printed to the
console will print suggestions for how to call a plot.
# plot ICC for one item psk_IRF <- psketti(psk_data) psk_IRF
psk_IRF$Plot.List[["i06"]][[1]]
psk_IRF$Plot.List[["i12"]][[1]]
Produce a table of item fit statistics as per eRm
itemFit_psk <- item_fit_table(fake_rm) # round ouput to 2 places itemFit_psk[, -1] <- round(itemFit_psk[, -1], 2) itemFit_psk
Produce Plot of infit and outfit statistics
psketti_msq(x = itemFit_psk)
# response option categories r_o <- factor(sort(unique(FakeData$K)), levels = sort(unique(FakeData$K)), ordered = TRUE) tlt_data <- tabliatelle(x = FakeData, ID = "ID", Item = "Item", K = "K", response_options = r_o, eRm.obj = fake_rm) tlt_data
# multiple plots spag_plot <- psketti_distractor(ID = "ID", # set ID column Item = "Item", # set Item column K= "K", # Set resp categories x = FakeData, # select data eRm.obj = fake_rm, # select eRm object response_options = r_o, # set resp options p.style = "present") # set plotting style spag_plot$Plot.List[['i01']][[1]] # plot item 1
K_opt <- factor(LETTERS[1:5], levels = LETTERS[1:5], ordered = TRUE) score_report <- ingrediente(x = FakeData, Item = "Item", ID = "ID", Score = "X", K = "K", K_options = K_opt, Index = "Index") # show score report for values with a total score <= 1 score_report[score_report$total_score <= 1, ]
data("FakePCMData") F2 <- FakePCMData rownames(F2) <- F2$ID F2$ID <- NULL fake_pcm <- PCM(F2)
psk_pcm <- pskettify(eRm.obj = fake_pcm) # pskettify psk_pcm
psk_no_facet <- psketto(pskettified_data = psk_pcm, item = "i01", item.label = "i01") psk_no_facet
psk_facet <- psketto(pskettified_data = psk_pcm, item = "i01", item.label = "i01", facet_curves = TRUE) psk_facet
By default psketti()
produces faceted plots for partial credit models
print_facet <- psketti(pskettified_data = psk_pcm) print_facet$Plot.List[['i01']][[1]] # output
However, you can turn off this behaviour by using the Force_no_facet=True
argument.
print_no_facet <- psketti(pskettified_data = psk_pcm, p.empICC = FALSE, Force_no_facet = TRUE) print_no_facet$Plot.List[['i02']][[1]]
Item fit statistic.
fake_ifit <- item_fit_table(eRm.obj = fake_pcm) # round ouput to 2 places fake_ifit[, -c(1, 2)] <- round(fake_ifit[, -c(1, 2)], 2) fake_ifit
Infit and Outfit MSQ plot.
psketti_msq(x = fake_ifit)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.