# Estimate the M_{2} fit statistic for
diagnostic classification models

Source: `R/m2-methods.R`

`fit_m2.Rd`

For diagnostic classification models, the
M_{2} statistic is calculated as
described by Hansen et al. (2016) and Liu et al. (2016).

## Usage

```
# S3 method for measrdcm
fit_m2(model, ..., ci = 0.9, force = FALSE)
```

## Arguments

- model
An estimated diagnostic classification model.

- ...
Unused, for extensibility.

- ci
The confidence interval for the RMSEA.

- force
If the M

_{2}has already been saved to the model object with`add_fit()`

, should it be recalculated. Default is`FALSE`

.

## Value

A data frame created by `dcm2::fit_m2()`

.

## References

Hansen, M., Cai, L., Monroe, S., & Li, Z. (2016).
Limited-information goodness-of-fit testing of diagnostic classification
item response models. *British Journal of Mathematical and Statistical
Psychology, 69*(3), 225-252. doi:10.1111/bmsp.12074

Liu, Y., Tian, W., & Xin, T. (2016). An application of
M_{2} statistic to evaluate the fit
of cognitive diagnostic models. *Journal of Educational and Behavioral
Statistics, 41*(1), 3-26. doi:10.3102/1076998615621293

## Examples

```
rstn_mdm_lcdm <- measr_dcm(
data = mdm_data, missing = NA, qmatrix = mdm_qmatrix,
resp_id = "respondent", item_id = "item", type = "lcdm",
method = "optim", seed = 63277, backend = "rstan"
)
fit_m2(rstn_mdm_lcdm)
#> # A tibble: 1 × 8
#> m2 df pval rmsea ci_lower ci_upper `90% CI` srmsr
#> <dbl> <int> <dbl> <dbl> <dbl> <dbl> <chr> <dbl>
#> 1 0.0219 1 0.882 0 0 0.110 [0, 0.1102] 0.0456
```