
With R and Stan
W. Jake Thompson, Ph.D.
The research reported here was supported by the Institute of Education Sciences, U.S. Department of Education, through Grants R305D210045 and R305D240032 to the University of Kansas Center for Research, Inc., ATLAS. The opinions expressed are those of the authors and do not represent the views of the the Institute or the U.S. Department of Education.

Measurement and structural models

Model misspecifications

All materials are available on the workshop website:
install.packages(c("measr", "tidyverse", "pysch", "here", "fs", "usethis"))
# Optional
install.packages(
c("rstan", "StanHeaders", "cmdstanr"),
repos = c("https://stan-dev.r-universe.dev", getOption("repos"))
)
## check toolchain
cmdstanr::check_cmdstan_toolchain()
cmdstanr::install_cmdstan(cores = 2)For help installing RStan, CmdStanR, or configuring the toolchain, see the prework page.
Latent class models use responses to probabilistically place individuals into latent classes
DCMs are confirmatory latent class models
Respondents (r): The individuals from whom behavioral data are collected
Items (i): Assessment questions used to classify/diagnose respondents
Attributes (a): Unobserved latent categorical characteristics underlying the behaviors (i.e., diagnostic status)
With binary attributes, there are 2A possible profiles
Example 3-attribute assessment:
[0, 0, 0]
[1, 0, 0]
[0, 1, 0]
[0, 0, 1]
[1, 1, 0]
[1, 0, 1]
[0, 1, 1]
[1, 1, 1]
\[ \color{#D55E00}{P(X_r=x_r)} = \sum_{c=1}^C\color{#009E73}{\nu_c} \prod_{i=1}^I\color{#56B4E9}{\pi_{ic}^{x_{ir}}(1-\pi_{ic})^{1 - x_{ir}}} \]
\[ \color{#D55E00}{P(X_r=x_r)} = \sum_{c=1}^C\color{#009E73}{\nu_c} \prod_{i=1}^I\color{#56B4E9}{\pi_{ic}^{x_{ir}}(1-\pi_{ic})^{1 - x_{ir}}} \]
Structural component: Proportion of examinees in each class\[ \color{#D55E00}{P(X_r=x_r)} = \sum_{c=1}^C\color{#009E73}{\nu_c} \prod_{i=1}^I\color{#56B4E9}{\pi_{ic}^{x_{ir}}(1-\pi_{ic})^{1 - x_{ir}}} \]
Measurement component: Product of item response probabilitiesSoftware Programs
R Packages

Very tedious—prone to typos
Complexity increases with the number of attributes and item structure
Stan code must be customized to each particular Q-matrix
Just need to automate the creation of the Stan scripts…
Diagnostic classification models
A quick review