| infit_post | R Documentation |
Postprocesses the output of infit_statistic to produce summary tables
of posterior predictive infit statistics and a combined slab +
interval plot comparing observed infit values to the posterior
predictive distribution.
infit_post(infit_draws, ci = 0.84)
infit_draws |
A data frame (or tibble) as returned by
|
ci |
Numeric in |
Two complementary summary tables are provided:
summaryReports the posterior mean observed and replicated infit values alongside the posterior predictive p-value (ppp). The ppp is the proportion of draws where the replicated infit exceeds the observed infit. Under good fit, the ppp should be near 0.5. A ppp near 0 indicates the observed infit is consistently larger than expected (underfit); a ppp near 1 indicates it is consistently smaller (overfit).
hdiReports the probability that the observed infit falls above (underfit) or below (overfit) the HDI of the replicated distribution. This provides a more distributional assessment than the ppp alone.
The plot uses two layers from the ggdist package:
stat_slabDisplays the posterior predictive (replicated) infit distribution as a filled density slab per item, shaded by credible interval level.
stat_slabintervalDisplays the observed infit distribution per item as a semi-transparent slab with point and interval summaries.
Under good model fit, the observed infit distribution should overlap substantially with the replicated distribution. Items where the observed distribution sits systematically above the replicated HDI indicate underfit (more variation than expected); items below indicate overfit (less variation than expected).
A list with three elements:
A tibble with one row per
item containing: item, infit_obs (posterior
mean of observed infit), infit_rep (posterior mean of
replicated infit), and infit_ppp (posterior predictive
p-value: proportion of draws where the replicated infit
exceeds the observed infit). Values near 0.5 indicate good
fit; values near 0 suggest underfit; values near 1 suggest
overfit.
A tibble with one row per
item containing: item, underfit (posterior
probability that the observed infit exceeds the upper HDI
bound of the replicated distribution), and overfit
(posterior probability that the observed infit falls below
the lower HDI bound).
A ggplot object showing
the posterior predictive distribution of replicated infit
(grey filled slab) overlaid with the observed infit
distribution (coloured slab + interval), with a dashed
reference line at 1 (perfect fit).
infit_statistic,
item_restscore_post.
## Not run:
library(brms)
library(ggplot2)
# Assuming fit_pcm is a fitted brmsfit object
infit_draws <- infit_statistic(fit_pcm)
result <- infit_post(infit_draws)
result$summary
result$hdi
result$plot
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.