## ----synth-availability-data--------------------------------------------------
set.seed(20261022)
participant <- rep(seq_len(20L), each = 50L)
scenario <- rep(c("Scenario A", "Scenario B"), each = 500L)
loss_probability <- rep(c(rep(0.08, 10L), rep(0.32, 10L)), each = 50L)
recorded <- stats::rbinom(length(participant), 1L, 1 - loss_probability)
dat <- data.frame(participant = participant, scenario = scenario,
                  recorded = recorded)
per_person <- stats::aggregate(recorded ~ participant + scenario, data = dat,
                               FUN = mean)
names(per_person)[3L] <- "recorded_fraction"
stopifnot(nrow(per_person) == 20L, nrow(dat) == 1000L,
          all(per_person$recorded_fraction >= 0),
          all(per_person$recorded_fraction <= 1))
stats::aggregate(recorded_fraction ~ scenario, per_person, mean)

## ----availability-person-figure, fig.width=8, fig.height=4, fig.cap="Original R plot of synthetic recording-window availability. All points are synthetic participants; labels are deliberately non-demographic."----
graphics::stripchart(recorded_fraction ~ scenario, data = per_person,
                     method = "jitter", jitter = 0.08, vertical = TRUE,
                     pch = 19, col = "#24577B",
                     ylab = "Proportion of planned windows recorded",
                     main = "Availability must precede signal interpretation",
                     ylim = c(0, 1))
graphics::abline(h = 1, lty = 3, col = "#888888")

## ----availability-coverage-figure, fig.width=9, fig.height=4, fig.cap="One synthetic recording availability timeline for each scenario; filled cells indicate the presence of a recorded window, not sensor validity."----
example_ids <- c(1L, 11L)
rows <- lapply(example_ids, function(i) dat$recorded[dat$participant == i])
matrix_availability <- do.call(rbind, rows)
graphics::image(x = seq_len(ncol(matrix_availability)),
                y = seq_len(nrow(matrix_availability)),
                z = t(matrix_availability),
                col = c("#E8D3CA", "#AECEDC"),
                xlab = "Planned time-window index", ylab = "Synthetic scenario",
                yaxt = "n", main = "Observed / not observed")
graphics::axis(2, at = seq_along(example_ids),
               labels = c("A", "B"), las = 1)

