## ----setup, include=FALSE-----------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.width = 7,
  fig.height = 4.5
)
library(gp3bayes)

## ----estimand-draws-----------------------------------------------------------
grid <- expand.grid(
  .event_time = seq(0, 1, length.out = 21),
  .condition = factor(c("control", "treatment")),
  KEEP.OUT.ATTRS = FALSE
)
set.seed(2026)
mu <- ifelse(grid$.condition == "treatment", 0.15, 0) +
  0.25 * sin(pi * grid$.event_time)
draws <- matrix(
  rnorm(300 * nrow(grid), rep(mu, each = 300), 0.06),
  nrow = 300
)
pred <- as_pupil_prediction_draws(draws, grid, "millimetres")

## ----trajectory---------------------------------------------------------------
trajectory <- estimate_pupil_trajectory(pred, probability = 0.95)
head(pupil_trajectory_table(trajectory))

## ----declared-estimands-------------------------------------------------------
contrast <- pupil_condition_contrast(
  pred,
  contrast = c("treatment", "control"),
  threshold = 0.10
)
window <- estimate_pupil_window(pred, window = c(0.3, 0.8))
auc <- estimate_pupil_auc(pred, window = c(0.3, 0.8))
peak <- estimate_pupil_peak(pred, window = c(0.3, 0.8))
latency <- estimate_pupil_peak_latency(pred, window = c(0.3, 0.8))

head(as.data.frame(contrast))
as.data.frame(window)
as.data.frame(auc)
as.data.frame(peak)
as.data.frame(latency)

