## ----setup, include=FALSE-----------------------------------------------------
knitr::opts_chunk$set(collapse = TRUE, comment = "#>")
library(gp3bayes)

## -----------------------------------------------------------------------------
binary_scenarios <- c(
  "null_contrast",
  "weak_information",
  "severe_imbalance",
  "near_separation",
  "omitted_random_slope",
  "sparse_item_structure",
  "all_zero_participants",
  "rank_deficiency",
  "missing_outcomes"
)

binary_results <- lapply(
  binary_scenarios,
  simulate_binary_pathology,
  seed = 2026
)

data.frame(
  scenario = binary_scenarios,
  expected_gate = vapply(
    binary_results,
    `[[`,
    character(1),
    "expected_gate"
  )
)

## -----------------------------------------------------------------------------
rank_failure <- simulate_binary_pathology(
  "rank_deficiency",
  seed = 2026
)
evaluate_pathological_simulation(rank_failure)
plot(rank_failure)

## -----------------------------------------------------------------------------
duration_scenarios <- c(
  "null_ratio",
  "high_group_heterogeneity",
  "weak_information",
  "severe_imbalance",
  "heavy_tailed_contamination",
  "mixture",
  "censoring",
  "incorrect_unit",
  "zero_duration",
  "negative_duration"
)

duration_results <- lapply(
  duration_scenarios,
  simulate_duration_pathology,
  seed = 2026
)

data.frame(
  scenario = duration_scenarios,
  expected_gate = vapply(
    duration_results,
    `[[`,
    character(1),
    "expected_gate"
  )
)

## -----------------------------------------------------------------------------
censored <- simulate_duration_pathology("censoring", seed = 2026)
wrong_unit <- simulate_duration_pathology("incorrect_unit", seed = 2026)

evaluate_pathological_simulation(censored)
evaluate_pathological_simulation(wrong_unit)

