## ----setup, include=FALSE-----------------------------------------------------
knitr::opts_chunk$set(collapse = TRUE, comment = "#>")
library(aiDIF)

## ----data---------------------------------------------------------------------
eg <- make_aidif_eg()
str(eg, max.level = 2)

## ----fit----------------------------------------------------------------------
mod <- fit_aidif(
  human_mle = eg$human,
  ai_mle    = eg$ai,
  alpha     = 0.05
)
print(mod)

## ----summary------------------------------------------------------------------
summary(mod)

## ----dasb---------------------------------------------------------------------
sb <- scoring_bias_test(eg$human, eg$ai)
print(sb)

## ----effect-------------------------------------------------------------------
eff <- ai_effect_summary(mod$dif_human, mod$dif_ai)
print(eff)

## ----plots, fig.width=7, fig.height=5, eval=FALSE-----------------------------
# plot(mod, type = "dif_forest")   # human vs AI DIF side by side
# plot(mod, type = "dasb")         # DASB bar chart with error bars
# plot(mod, type = "weights")      # bi-square anchor weights

## ----sim----------------------------------------------------------------------
dat <- simulate_aidif_data(
  n_items    = 8,
  n_obs      = 600,
  dif_items  = c(1, 2),
  dif_mag    = 0.5,
  dasb_items = 5,
  dasb_mag   = 0.4,
  seed       = 123
)
sim_mod <- fit_aidif(dat$human, dat$ai)
print(sim_mod)

