easyRaschBayes

CRAN Version Downloads Downloads Status Buy Me A Coffee

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.

Statement of need

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.

Installation

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")

Key design principles

Functions by domain

Item fit

Local dependence

Dimensionality

Differential item functioning

Response categories

Targeting and reliability

Item and person parameters

Hurdle partial credit model

Data visualization

Data

Vignettes

There is also a comparison with frequentist Rasch tools in R.

Example

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)

References

Credits

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.

License

GPL (>= 3)