Skip to content

atlas-aai/tdcmStan

Repository files navigation

tdcmStan

Project Status: Active – The project has reached a stable, usable state and is being actively developed. lifecycle R package version Package downloads R-CMD-check
Codecov test coverage Netlify Status Signed by License

The goal of tdcmStan is to facilitate the production of Stan code for estimating transition diagnostic classification models (TDCMs). TDCMs are psychometric models that estimate respondents latent class membership longitudinally. Using R, tdcmStan uses the Q-matrix to automatically produce the Stan code. The tdcmStan package supports unconstrained TDCMs along with fungible TDCMs (i.e., TDCMs where the items parameters are assumed to be equivalent) and fungible TDCMs with no common items across time points. The tdcmStan package also supports estimation of multi-threaded TDCMs, which increases the efficiency of model estimation.

Installation

You can install the release version of tdcmStan from CRAN:

install.packages("tdcmStan")

To install the development version from GitHub use:

# install.packages("remotes")
remotes::install_github("atlas-aai/tdcmStan")

Usage

To demonstrate the workflow using tdcmStan, we present an example case for generating Stan code. For this example, we will assume that we are going to be estimating a TDCM for a 5-item 1-attribute assessment that is administered at two time points. The produced stan code is first saved in stan_code, and then the Stan code is saved as a Stan file in Stan/tdcm.stan where it can be read in for model estimation.

library(tibble)
library(here)
library(readr)
library(tdcmStan)

q_matrix <- tibble(rep(1, 5))
stan_code <- create_stan_tdcm(q_matrix)
stan_code %>%
    readr::write_lines(here("Stan/tdcm.stan"))

The tdcmStan package follows a similar process for the other variants of TDCMs. To estimate a multi-threaded TDCM for this 5-item 1-attribute assessment, we would run:

fng_stan_code <- create_threaded_stan_tdcm(q_matrix)

To estimate a fungible TDCM for this 5-item 1-attribute assessment, we would run:

fng_stan_code <- create_fng_stan_tdcm(q_matrix)

To estimate a fungible TDCM for a 1-attribute assessment where respondents complete 5 items at each time point but respondents do not complete the same item twice, we would run:

q_matrix <- tibble(rep(1, 10))
fng_no_cmn_items_stan_code <- create_fng_no_common_item_tdcm(q_matrix)

Contributions are welcome. To ensure a smooth process, please review the Contributing Guide. Please note that the dcm2 project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.