calc_m2 {dcm2}R Documentation

Calculate the M2

Description

Calculate the M2

Usage

calc_m2(
  data,
  struc_params,
  pi_matrix,
  qmatrix,
  ci = 0.9,
  link = "logit",
  model_type = c("LCDM", "GDINA", "ACDM", "LLM", "RRUM", "DINO", "DINA", "BUGDINO")
)

Arguments

data

A data frame containing the raw data, where there is one row per respondent and one column per item

struc_params

A vector containing the structural parameters of the estimated model

pi_matrix

An item-by-class matrix containing the probability of a correct response by members of each latent class

qmatrix

A data frame containing the Q-matrix

ci

The confidence interval for the RMSEA, computed from the M2

link

A character containing the link function.

model_type

A character containing the model type (e.g., LCDM) that was estimated.

Value

A data frame containing:

Examples

possible_prof <- dcm2::as_binary(ncol(sample_data$q_matrix))

fit_dat <- sample_data$data %>%
             tidyr::pivot_wider(names_from = "item_id",
                                values_from = "score") %>%
             dplyr::select(-"resp_id") %>%
             as.matrix() %>%
             unname()
gdina_mod <- GDINA::GDINA(dat = fit_dat,
                          Q = data.frame(sample_data$q_matrix),
                          model = "logitGDINA",
                          control = list(conv.type = "neg2LL"))
struc_params <- gdina_mod$struc.parm
pi_matrix <- gdina_mod$LC.prob %>%
               as.matrix() %>%
               unname()
calc_m2(data = fit_dat, struc_params, pi_matrix,
        qmatrix = data.frame(sample_data$q_matrix), ci = 0.9, link = "logit",
        model_type = "LCDM")


[Package dcm2 version 1.0.2 Index]