## ----setup, include=FALSE-----------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

## ----core-installation, eval=FALSE--------------------------------------------
# install.packages(
#   "gp3bayes",
#   repos = NULL,
#   type = "source"
# )

## ----rstan-packages, eval=FALSE-----------------------------------------------
# install.packages(
#   c(
#     "brms",
#     "rstan",
#     "posterior",
#     "bayesplot"
#   )
# )

## ----cmdstanr-common-packages, eval=FALSE-------------------------------------
# install.packages(
#   c(
#     "brms",
#     "posterior",
#     "bayesplot"
#   )
# )

## ----cmdstanr-installation, eval=FALSE----------------------------------------
# install.packages(
#   "cmdstanr",
#   repos = c(
#     "https://stan-dev.r-universe.dev",
#     getOption("repos")
#   )
# )
# 
# cmdstanr::check_cmdstan_toolchain()
# cmdstanr::install_cmdstan()

## ----windows-build-tools, eval=FALSE------------------------------------------
# pkgbuild::has_build_tools(
#   debug = TRUE
# )

## ----cmdstanr-preflight, eval=FALSE-------------------------------------------
# cmdstanr::check_cmdstan_toolchain()
# check_cmdstan_backend(strict = TRUE)

## ----backend-capabilities, eval=FALSE-----------------------------------------
# bayesian_backend_capabilities()

## ----rstan-preflight, eval=FALSE----------------------------------------------
# stopifnot(
#   requireNamespace("brms", quietly = TRUE),
#   requireNamespace("rstan", quietly = TRUE),
#   requireNamespace("posterior", quietly = TRUE)
# )

## ----cmdstanr-namespace-preflight, eval=FALSE---------------------------------
# stopifnot(
#   requireNamespace("brms", quietly = TRUE),
#   requireNamespace("cmdstanr", quietly = TRUE),
#   requireNamespace("posterior", quietly = TRUE)
# )
# 
# check_cmdstan_backend(strict = TRUE)

## ----compilation-smoke, eval=FALSE--------------------------------------------
# simulation <- simulate_hierarchical_binary_data(
#   n_participants = 8,
#   trials_per_participant = 6,
#   n_items = 4,
#   random_slope_sd = 0,
#   seed = 7001
# )
# 
# contract <- create_model_contract(
#   family = "binary",
#   outcome_col = "selected",
#   participant_col = "participant_id",
#   item_col = "item_id",
#   trial_col = "trial_id",
#   condition_col = "condition"
# )
# 
# prepared <- prepare_hierarchical_binary_data(
#   simulation$data,
#   contract,
#   condition_levels = c(
#     "control",
#     "treatment"
#   )
# )
# 
# specification <- specify_binary_model(
#   prepared,
#   baseline = 0.35
# )
# 
# smoke_fit <- fit_binary_model_backend(
#   specification,
#   backend = "rstan",
#   chains = 2,
#   iter = 300,
#   warmup = 150,
#   cores = 2,
#   seed = 7002,
#   refresh = 0
# )

