atlas-aai / dcm2

Calculate the M2 statistic for DCMs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

dcm2

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 dcm2 is to provide a generic function for calculating the $M_2$ statistic described by Liu et al. (2016). The package provides native support for models estimated with GDINA, but package authors can create methods for different classes of models.

Installation

You can install the release version of dcm2 from CRAN:

install.packages("dcm2")

To install the development version from GitHub use:

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

Usage

Once dcm2 has been installed, we can estimate a DCM and apply the $M_2$ statistic to estimate the evidence of model fit.

library(dcm2)
library(tidyverse)
library(GDINA)

We included simulated data in the dcm2 package to demonstrate how the package can be used. We can load in this data using:

fullData <- dcm2::sample_data
q_matrix <- fullData$q_matrix
data <- fullData$data

Then, we want to estimate a DCM to fit this data. We will use the GDINA package to estimate a log-linear cognitive diagnosis model [LCDM; @henson_2009]. However, we need to format the data prior to fitting the LCDM.

fit_dat <- data %>%
             tidyr::pivot_wider(names_from = "item_id",
                                values_from = "score") %>%
             dplyr::select(-"resp_id") %>%
             as.matrix() %>%
             unname()

Now that the data is formatted, we can fit the model using:

gdina_mod <- GDINA::GDINA(dat = fit_dat,
                          Q = data.frame(q_matrix),
                          model = "logitGDINA",
                          control = list(conv.type = "neg2LL"))

Finally, we use the fit_m2() function to estimate the model fit using the $M_2$ fit statistic for the model estimated from the GDINA package. This function produces a tibble with all of the output for the $M_2$ fit statistic.

fit_m2(gdina_mod, ci = 0.9)

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.

About

Calculate the M2 statistic for DCMs


Languages

Language:R 89.8%Language:C++ 7.5%Language:TeX 2.8%