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

## -----------------------------------------------------------------------------
backend_capabilities()
validate_backend_environment("rstan")
validate_backend_environment("cmdstanr")

## ----eval=FALSE---------------------------------------------------------------
# validate_backend_environment("rstan", compile_test = TRUE)
# validate_backend_environment("cmdstanr", compile_test = TRUE)

## -----------------------------------------------------------------------------
rstan_summary <- data.frame(
  variable = c("b_Intercept", "b_conditiontreatment"),
  mean = c(-0.60, 0.40),
  sd = c(0.20, 0.15),
  mcse_mean = c(0.01, 0.01)
)

cmdstanr_summary <- data.frame(
  variable = c("b_Intercept", "b_conditiontreatment"),
  mean = c(-0.59, 0.41),
  sd = c(0.21, 0.15),
  mcse_mean = c(0.01, 0.01)
)

parity <- audit_backend_parity(
  rstan_summary,
  cmdstanr_summary
)
parity
plot(parity)

## ----eval=FALSE---------------------------------------------------------------
# parity <- audit_backend_parity(
#   fit_rstan,
#   fit_cmdstanr,
#   variables = c("b_Intercept", "b_conditiontreatment")
# )

## -----------------------------------------------------------------------------
contract <- create_model_contract(
  "binary", "selected", "participant_id",
  condition_col = "condition"
)

schema <- capture_gp3bayes_schema(contract)
schema

validation <- validate_gp3bayes_schema(contract, schema)
validation

## -----------------------------------------------------------------------------
frozen_schema <- freeze_gp3bayes_schema(schema)

schema_file <- tempfile(fileext = ".rds")
freeze_gp3bayes_schema(frozen_schema, schema_file)
read_gp3bayes_schema(schema_file)
unlink(schema_file)

