Skip to content

Provides a comparison of two TDCMs. Can be used to compare different measurement models or assess measurement invariance over time or over groups in the multigroup TDCM case. Only accepts two models.

Usage

tdcm.compare(model1, model2)

Arguments

model1

a gdina object returned from the tdcm or mg.tdcm function.

model2

a second gdina object returned from the tdcm or mg.tdcm function

Value

This function returns a data frame with model fit statistics (AIC/BIC) and results from a likelihood ratio or deviance test.

Note

  • Currently, this function currently accepts two models for comparison.

  • Both models must be fit to the same item responses and Q-matrix.

  • The function will provide results for two non-nested models. Please ensure that models are nested before interpreting the likelihood ratio test for nested models.

  • The likelihood ratio test is not valid for some model comparisons (e.g., LCDM vs DINA) because of model constraints.

Examples

# \donttest{
## Example 1: T = 2, A = 4
data(data.tdcm01, package = "TDCM")
dat1 <- data.tdcm01$data
qmat1 <- data.tdcm01$q.matrix

# estimate TDCM with invariance assumed and full LCDM
m1 <- TDCM::tdcm(dat1, qmat1, num.time.points = 2, invariance = TRUE, rule = "GDINA")

# estimate TDCM with invariance not assumed
m2 <- TDCM::tdcm(dat1, qmat1, num.time.points = 2, invariance = FALSE, rule = "GDINA")

# compare models to assess measurement invariance.
TDCM::tdcm.compare(m1, m2)
#>   Model   loglike Deviance Npars      AIC      BIC Chisq df      p
#> 1    m1 -21429.51 42859.02    93 43045.02 43501.44 58.14 56 0.3965
#> 2    m2 -21400.44 42800.88   149 43098.88 43830.14    NA NA     NA
# }