## ----setup, include=FALSE----------------------------------------------------- knitr::opts_chunk$set(collapse = TRUE, comment = "#>") library(gp3bayes) ## ----------------------------------------------------------------------------- bayesian_backend_capabilities() ## ----------------------------------------------------------------------------- binary_sim <- simulate_hierarchical_binary_data( n_participants = 12, trials_per_participant = 8, n_items = 6, random_slope_sd = 0, seed = 2026 ) binary_contract <- create_model_contract( family = "binary", outcome_col = "selected", participant_col = "participant_id", item_col = "item_id", trial_col = "trial_id", condition_col = "condition", predictors = c("participant_covariate", "trial_covariate"), interaction = c("condition", "participant_covariate"), random_slope = FALSE ) binary_prepared <- prepare_hierarchical_binary_data( binary_sim$data, binary_contract, condition_levels = c("control", "treatment") ) binary_spec <- specify_binary_model_with_interaction_prior( binary_prepared, baseline = 0.35 ) interaction_prior_summary(binary_spec) ## ----eval=FALSE--------------------------------------------------------------- # fit_rstan <- fit_binary_model_backend( # binary_spec, # backend = "rstan" # ) # # fit_cmdstanr <- fit_binary_model_backend( # binary_spec, # backend = "cmdstanr" # ) ## ----eval=requireNamespace("detectseparation", quietly=TRUE)------------------ separation_screen <- detect_binary_separation(binary_spec) separation_screen plot(separation_screen) ## ----eval=FALSE--------------------------------------------------------------- # loo_a <- compute_psis_loo(fit_a) # loo_b <- compute_psis_loo(fit_b) # # comparison <- compare_psis_loo(list(contract_a = loo_a, contract_b = loo_b)) # comparison # # weights <- compute_loo_model_weights(comparison, method = "stacking") # weights ## ----eval=FALSE--------------------------------------------------------------- # sensitivity <- assess_powerscaled_sensitivity( # fit_rstan, # variable = c("b_Intercept", "b_condition") # ) # # sensitivity # plot(sensitivity, type = "ecdf") # plot(sensitivity, type = "quantities") ## ----eval=FALSE--------------------------------------------------------------- # plan <- create_brms_sbc_plan( # binary_spec, # n_sims = 50, # backend = "cmdstanr" # ) # # sbc_result <- run_sbc_plan(plan) # sbc_result # plot(sbc_result, type = "rank") # plot(sbc_result, type = "ecdf")