The irtPlot function is a flexible utility used to create publication-quality graphics for various aspects of dichotomous IRT models. This function also provides several useful utilities to facilitate graphic creation. The general flow of tasks within the function is as follows:
ltm
package to estimate a model based on the given data. ggplot2
. irtPlot is part of the irtPlot package available on github. To download the package, install the devtools
package and run the following lines:
library(devtools) install_github("ppanko/irtPlot")
Before using irtPlot, the user must provide two primary arguments. First, the user must declare a data set for which he or she wishes to create graphics. Second, a sequence of theta values should be selected in order to plot the parameters. In the example below, the data are drawn from ltm
package and the theta values are chosen accordingly using the seq
function.
library(irtPlot) data <- LSAT theta <- seq(-6,3, 0.01)
Next, the user must choose which model
and type
to plot. This function supports "1PL"
, "2PL"
, and "3PL"
models as well as Item Characteristic Curves ("icc"
), Test Characterstic Curves ("tcc"
), Item Information Functions ("iif"
), Test Information Functions ("tif"
), and Ability Parameter Estimation ("likl"
, "logl"
) types. See relevant sections below for more information on types.
Having dispensed with the required arguments, the user is free to select a number of optional commands to personalize the desired plot. Most of the the arguments in this section are used to tweak default setting for the save
utility.
ddir: A character string specifying the directory in which to save plots. Default is the current working directory.
save: A logical value specifying whether or not to save the resultant graphics. Requires TRUE/FALSE
; default is FALSE
.
title: A character string to specify the name of the plot. Default behavior is to specify the plot type and the number of items in the model.
filename: A character string indicating the desired filename for the saved plot. The default filename is based on the model and type arguments.
dpi: An integer value specifying the resolution of the saved graphic. Default value is 300; recommended value for standard poster-size figures is 600.
width: A numeric value for the desired width of the figure in inches. Default is 8.5 inches.
height: A numeric value for the desired height of the figure in inches. Default is 10 inches.
itmNam: A vector of character strings specifying the name of the items displayed in the legend. Default values are the names of the columns in the specified data set.
subS: A data frame used to subset the supplied data for the "likl"
and "logl"
types. See the relevant section below for further details.
silent: A logical value specifying whether or not to print graphics to screen. This feature is primarily used when the user simply wants to save a plot without examining it. Default is FALSE
.
The user is encouraged to view the help files using the ?irtPlot
function.
For dichotomous items, Item Characteristic Curves are used to model the probability of answering a given item correctly across a range of ability values. The 3PL probability of a correct answer for ability s on item i is given by the following formula:
$$P(Y_{is}=1|\theta_s) = c_i + (1 - c_i)\frac{exp(1.7a_i(\theta_s - b_i))}{1 + exp(1.7a_i(\theta_s - b_i))}$$
Similarly, Test Characteristic Curves represent the probability of observing a certain response total over a range of ability values. The probability of the expected score on the test for ability s is shown below:
$$TCC(\theta_s) = \sum_{i=1}^I P(Y_{is} = 1|\theta_s)$$
Examples using the LSAT
data are shown below for each type of plot.
irtPlot(data, theta, model = "3PL", type = "icc") irtPlot(data, theta, model = "3PL", type = "tcc")
The measurement reliability of a given item can be approximated using Item Information Function. The information of a given item i can be plotted against a range of $\theta$ values to determine the usefulness of i across ability levels, as shown below:
$$I_i(\theta) = \frac{1.7_2a_i^2(1-c_i)}{[c_i + exp(1.7a_i(\theta - b_i))][1 + exp(1.7a_i(\theta - b_i))]}$$
Furthermore, the reliability of a test across ability levels can be estimated by summing the i items of a given model:
$$I(\theta) = \sum_{i = 1}^I I_i(\theta) $$
Examples of each plot type are shown below.
Previous Section \ Back to top \ Next Section
irtPlot(data, theta, model = "3PL", type = "iif") irtPlot(data, theta, model = "3PL", type = "tif")
The likelihood of a given response pattern can be computed for a set of ability values. This process can be used to determine a participant's ability level indicated by a peak in the plotted curve. The formula below shows the computational form of the likelihood for person n for item set j given $\theta$:
$$L(u_1...,u_j...,u_n|\theta) = \prod_{j = 1}^n P_j^{u_j} (1-P_j)^{1-u_j}$$
Additionally, it is also possible to plot the log-likelihood estimates. This transformation can be expressed:
$$ln[L(\mathbf{u}|\theta)] = \sum_{j = 1}^n [u_jlnP_j + (1 - u_j)ln(1 - P_j)]$$
Note: Due to the fact that likelihoods are computed for one row at a time, this function make take a very long time with a large data sets. Users are strongly encouraged to use the subS = data[x,]
where data
is the data frame entered in the first argument and x
is a vector of select observations.
Previous Section \ Back to top \ Next Section
irtPlot(data, theta, model = "2PL", type = "likl", subS = data[1,]) irtPlot(data, theta, model = "2PL", type = "logl", subS = data[1,])
Embertson, S.E., & Reise, S. P. (2000). Item Response Theory for Psychologists. Hillsdale, NJ: Erlbaum.
Lee, J. (2016). Lectures on Item Response Theory. Personal Collection of J. Lee, Texas Tech University, Lubbock, TX.
Rizopoulos D. (2006). ltm: An R package for Latent Variable Modelling and Item Response Theory Analyses. Journal of Statistical Software, 17(5), 1-25. URL http://www.jstatsoft.org/v17/i05/
Wickham, H. (2009). ggplot2: Elegant Graphics for Data Analysis. New York: Springer-Verlag.
Please leave comments at the project repository: https://www.github.com/ppanko/irtPlot
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.