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

## ----overview-sim-------------------------------------------------------------
sim <- simulate_pupil_timecourse(
  n_participants = 6,
  trials_per_participant = 4,
  sampling_frequency = 20,
  time_window = c(-0.5, 1.5),
  seed = 20260814
)
str(sim$truth, max.level = 1)

## ----overview-contract--------------------------------------------------------
contract <- create_pupil_contract(
  outcome_col = "pupil_mm",
  participant_col = "participant_id",
  trial_col = "trial_id",
  item_col = "item_id",
  condition_col = "condition",
  time_col = "event_time",
  pupil_unit = "millimetres",
  sampling_frequency = 20,
  eye = "combined",
  source_vendor = "synthetic",
  blink_col = "blink",
  interpolation_col = "interpolated",
  gaze_x_col = "gaze_x",
  gaze_y_col = "gaze_y",
  luminance_col = "luminance",
  baseline_window = c(-0.5, 0),
  baseline_method = "none"
)
prepared <- prepare_pupil_timecourse(sim$data, contract)
audit <- audit_pupil_readiness(prepared)
pupil_readiness_table(audit)

## ----overview-spec------------------------------------------------------------
spec <- specify_pupil_timecourse_model(
  prepared,
  temporal_structure = "smooth",
  condition_trajectory = TRUE,
  smooth_basis_dimension = 6,
  autocorrelation = "ar1",
  participant_trajectory = "none",
  item_effects = TRUE
)
pupil_specification_table(spec)

