View source: R/api-estimation.R
| compare_mfrm | R Documentation |
Produce a side-by-side comparison of multiple fit_mfrm() results using
information criteria, log-likelihood, and parameter counts. When exactly
two nested models are supplied, a likelihood-ratio test is included.
compare_mfrm(..., labels = NULL, warn_constraints = TRUE, nested = FALSE)
... |
Two or more |
labels |
Optional character vector of labels for each model.
If |
warn_constraints |
Logical. If |
nested |
Logical. Set to |
Models should be fit to the same data (same rows, same person/facet columns) for the comparison to be meaningful. The function checks that observation counts match and warns otherwise.
Information-criterion ranking is reported only when all candidate models
use the package's MML estimation path, analyze the same observations, and
converge successfully. Raw AIC and BIC values are still shown for each
model, but Delta_*, weights, and preferred-model summaries are suppressed
when the likelihood basis is not comparable enough for primary reporting.
Nesting: Two models are nested when one is a special case of the other obtained by imposing equality constraints. The most common nesting in MFRM is RSM (shared thresholds) inside PCM (item-specific thresholds). Models that differ only in estimation method (MML vs JML) on the same specification are not nested in the usual sense—use information criteria rather than LRT for that comparison.
The likelihood-ratio test (LRT) is reported only when exactly two
models are supplied, nested = TRUE, the structural audit passes, and the
difference in the number of parameters is positive:
\Lambda = -2 (\ell_{\mathrm{restricted}} - \ell_{\mathrm{full}})
\sim \chi^2_{\Delta p}
The LRT is asymptotically valid when models are nested and the data are independent. With small samples or boundary conditions (e.g., variance components near zero), treat p-values as approximate.
An object of class mfrm_comparison (named list) with:
table: data.frame of model-level statistics (LogLik, AIC, BIC,
Delta_AIC, AkaikeWeight, Delta_BIC, BICWeight, npar, nobs, Model,
Method, Converged, ICComparable).
lrt: data.frame with likelihood-ratio test result (only when two models
are supplied and nested = TRUE). Contains ChiSq, df, p_value.
evidence_ratios: data.frame of pairwise Akaike-weight ratios (Model1,
Model2, EvidenceRatio). NULL when weights cannot be computed.
preferred: named list with the preferred model label by each criterion.
comparison_basis: list describing whether IC and LRT comparisons were
considered comparable. Includes a conservative nesting_audit.
In addition to raw AIC and BIC values, the function computes:
Delta_AIC / Delta_BIC: difference from the best (minimum) value. A Delta < 2 is typically considered negligible; 4–7 suggests moderate evidence; > 10 indicates strong evidence against the higher-scoring model (Burnham & Anderson, 2002).
AkaikeWeight / BICWeight: model probabilities derived from
exp(-0.5 * Delta), normalised across the candidate set. An
Akaike weight of 0.90 means the model has a 90\
being the best in the candidate set.
Evidence ratios: pairwise ratios of Akaike weights, quantifying the relative evidence for one model over another (e.g., an evidence ratio of 5 means the preferred model is 5 times more likely).
AIC penalises complexity less than BIC; when they disagree, AIC favours the more complex model and BIC the simpler one.
compare_mfrm() is a same-basis model-comparison helper. Its strongest
claims apply only when the models were fit to the same response data,
under a compatible likelihood basis, and with compatible constraint
structure.
Do not treat AIC/BIC differences as primary evidence when
table$ICComparable is FALSE.
Do not interpret the LRT unless nested = TRUE and the structural audit
in comparison_basis$nesting_audit passes.
Do not compare models fit to different datasets, different score codings, or materially different constraint systems as if they were commensurate.
Lower AIC/BIC values indicate better parsimony-accuracy trade-off only
when table$ICComparable is TRUE.
A significant LRT p-value suggests the more complex model provides a meaningfully better fit only when the nesting assumption truly holds.
preferred indicates the model preferred by each criterion.
evidence_ratios gives pairwise Akaike-weight ratios (returned only
when Akaike weights can be computed for at least two models).
When comparing more than two models, interpret evidence ratios cautiously—they do not adjust for multiple comparisons.
table: first-pass comparison table; start with ICComparable,
Model, Method, AIC, and BIC.
comparison_basis: records whether IC and LRT claims are defensible for
the supplied models.
lrt: nested-model test summary, present only when the requested and
audited conditions are met.
preferred: candidate preferred by each criterion when those summaries
are available.
Inspect comparison_basis before writing conclusions. If comparability is
weak, treat the result as descriptive and revise the model setup (for
example, explicit step_facet, common data, or common constraints) before
using IC or LRT results in reporting.
Fit two models with fit_mfrm() (e.g., RSM and PCM).
Compare with compare_mfrm(fit_rsm, fit_pcm).
Inspect summary(comparison) for AIC/BIC diagnostics and, when
appropriate, an LRT.
fit_mfrm(), diagnose_mfrm()
toy <- load_mfrmr_data("example_core")
fit_rsm <- fit_mfrm(toy, "Person", c("Rater", "Criterion"), "Score",
method = "MML", model = "RSM", maxit = 25)
fit_pcm <- fit_mfrm(toy, "Person", c("Rater", "Criterion"), "Score",
method = "MML", model = "PCM",
step_facet = "Criterion", maxit = 25)
comp <- compare_mfrm(fit_rsm, fit_pcm, labels = c("RSM", "PCM"))
comp$table
comp$evidence_ratios
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.