Learn R Programming

guess (version 0.7.0)

fit_model: Goodness of fit statistics for transition matrix data

Description

Pearson chi-square goodness of fit between the observed transition counts and those the fitted model implies. Handles data with and without don't know responses automatically.

Degrees of freedom are the free cell probabilities less the parameters estimated from the same counts. The don't-know model leaves 1 degree of freedom. The model without don't know is saturated -- 3 free parameters against 3 free cell probabilities -- so no test is possible and both rows are `NA`.

Usage

fit_model(
  pre_test,
  pst_test,
  g,
  est_param,
  force9 = FALSE,
  na_as = c("dk", "missing"),
  missing_action = c("omit", "error")
)

fit_dk( pre_test, pst_test, g, est_param, force9 = FALSE, na_as = c("dk", "missing"), missing_action = c("omit", "error") )

fit_nodk( pre_test, pst_test, g, est_param, na_as = c("dk", "missing"), missing_action = c("omit", "error") )

Value

matrix with two rows: top row carrying chi-square value, bottom row p-values

Arguments

pre_test

data.frame carrying pre_test items

pst_test

data.frame carrying pst_test items

g

estimates of gamma produced from lca_cor

est_param

estimated parameters produced from lca_cor

force9

Optional. Force 9-column format even if no DK responses. Default is FALSE.

na_as

Classification of NA responses: `"dk"` (the default) treats them as observed don't know responses; `"missing"` treats them as structural missingness.

missing_action

How to handle structural missingness: `"omit"` excludes incomplete pairs and `"error"` rejects them.

Details

Unified Goodness of Fit Statistics

Examples

Run this code
if (FALSE) {
# Fit model first
transmatrix <- multi_transmat(pre_test, pst_test)
res <- lca_cor(transmatrix)

# Calculate goodness of fit
fit_stats <- fit_model(
  pre_test, pst_test, res$params[nrow(res$params), ],
  res$params[-nrow(res$params), ]
)
}

Run the code above in your browser using DataLab