easyRaschBayes provides Rasch measurement theory
analysis workflows for Bayesian item response theory models fitted with
brms. It supports
dichotomous Rasch models, partial credit and rating scale models, and a
hurdle partial credit model for data with many zero responses. All
output exposes the full posterior distribution.
The frequentist counterpart is easyRasch2,
which uses conditional maximum likelihood and simulation-based critical
values. Both packages include the same phq9 example data,
and their vignettes analyse it side by side. For broader Rasch-analysis
tutorials, see the vignette
for the archived package easyRasch.
brms fits Rasch-family models flexibly, with full
posterior uncertainty and with extensions such as person covariates,
extra facets and custom families (Bürkner, 2021). It does not provide
the diagnostics a Rasch analysis needs: item fit, local dependence,
dimensionality, differential item functioning, response category
functioning, targeting and reliability. easyRaschBayes
provides these for brms models, with one consistent
interface, and reports each diagnostic with its posterior
uncertainty.
Install the stable version from CRAN:
install.packages("easyRaschBayes")Or install the development version from GitHub:
# install.packages("remotes") # if needed
remotes::install_github("pgmj/easyRaschBayes")The development version changes several defaults and outputs, among them conditional item fit given the total score and a new targeting plot. See the changelog.
The hurdle partial credit model needs a patched version of
brms, since CRAN brms 2.23 cannot fit custom
ordinal families with item-specific thresholds:
remotes::install_github("rpsychologist/brms@fix-custom-ordinal-grouped-thres")brms and Stan. Item thresholds are read from the posterior
draws in the same way by every function, for partial credit models
(thres(gr = item)), rating scale models and dichotomous
models with fixed or random item effects. Person locations are posterior
means (EAP), with Warm’s weighted likelihood estimates (WLE) as an
alternative.ggplot2
figures. Infit, item-restscore and Q3 are computed per draw by
*_statistic() functions and summarised and plotted by
*_post() functions, so the draws stay available for further
analysis._hpcm for functions for the hurdle partial credit
model.infit_statistic() + infit_post():
conditional infit (and outfit) mean squares with posterior predictive
p-values; method = "theta" for infit given each draw’s
person locationsitem_restscore_statistic() +
item_restscore_post(): item-restscore association
(Goodman-Kruskal’s gamma) against its expected value given the total
scores, with a max-T adjustment for the number of itemsplot_icc(): conditional item characteristic curves in
class intervals of the total scorefit_statistic_pcm(), fit_statistic_rm():
general posterior predictive item and person fit with user-supplied
criteriaq3_statistic() + q3_post(): Yen’s Q3
residual correlations given the total scores, against replicated data,
with a max-T adjustment for the number of item pairs;
method = "theta" for residuals given each draw’s person
locationsplot_residual_pca(): first residual contrast, observed
against replicated eigenvalue, with item loadings and locationsdif_statistic(): refits the model with item-specific
group differences, estimates the difference in latent means (impact)
separately, and summarises the posterior of each item’s DIFplot_icc() with dif_var: conditional item
characteristic curves by group, with partial gammaplot_ipf(): item category probability curves with
credible bandsitem_parameters(): thresholds, with the posterior
probability that each item’s thresholds are disorderedplot_targeting(): person-item targeting plot with the
ranges where each response category is the most likely, threshold
credible intervals, and the posterior probability of collapsed
categories and disordered thresholdsRMUreliability(): reliability from relative measurement
uncertainty (Bignardi et al., 2026)item_parameters(): item locations and thresholds with
credible intervalsperson_parameters(): EAP and WLE person locations, and
a sum score to WLE tableposterior_to_prior(): informative priors from a fitted
model, for use in a new modelhurdle_acat() + hurdle_acat_stanvars():
custom brms family: a hurdle for any response above 0 and a
partial credit model for the positive categories, each with its own
person locationinfit_statistic_hpcm(),
q3_statistic_hpcm(), item_parameters_hpcm(),
person_parameters_hpcm(),
RMUreliability_hpcm(), plot_icc_hpcm(),
plot_targeting_hpcm(): the diagnostics above for each part
of the modelplot_tile(), plot_bars(),
plot_stackedbars(): response distributions from wide
dataphq9: PHQ-9 depression screener, 600 NHANES respondents
selected to have few zero sum scores, with gender, age and education.
The same data as in easyRasch2phq9_nhanes: PHQ-9, a random sample of 1000 NHANES
respondents with the many zero responses of a general population sample,
for the hurdle partial credit modelphq9phq9_nhanes analysed with an
ordinary and a hurdle partial credit modelThere is also a comparison with frequentist Rasch tools in R.
library(brms)
library(dplyr)
library(tidyr)
library(tibble)
library(easyRaschBayes)
# Long format, one row per person and item. The acat family expects
# response categories starting at 1.
df <- phq9[, 1:9] %>%
rownames_to_column("id") %>%
pivot_longer(!id, names_to = "item", values_to = "response") %>%
mutate(response = response + 1)
# Partial credit model
fit <- brm(
response | thres(gr = item) ~ 1 + (1 | id),
data = df,
family = acat,
chains = 4, cores = 4
)
# Conditional item fit: item-restscore and infit
item_restscore_post(item_restscore_statistic(fit))
infit_post(infit_statistic(fit))
# Local dependence with Yen's Q3
q3_post(q3_statistic(fit))
# Response categories and targeting
plot_ipf(fit)
plot_targeting(fit)This started as a small side project to update the code to assess item fit included in Bürkner (2020). With the help of Claude Opus things expanded to try to reproduce core Rasch analysis aspects with Bayesian methods. Most of the code in this package is produced by the LLM.
Magnus Johansson is a licensed psychologist with a PhD in behavior analysis. He works as a research specialist at Karolinska Institutet, Department of Clinical Neuroscience, Center for Psychiatry Research.
GPL (>= 3)