Sensitivity to diary-derived corrected midsleep

Replacing questionnaire MSFsc with MSFsc(diary) on matched observations

Published

November 11, 2026

source(".Rprofile")
library(dplyr)

Attaching package: 'dplyr'
The following objects are masked from 'package:stats':

    filter, lag
The following objects are masked from 'package:base':

    intersect, setdiff, setequal, union
library(tidyr)
library(ggplot2)
sensitivity_root <- "sensitivity/diary-msfsc"
knitr::read_chunk(file.path(sensitivity_root, "prepare.R"))
knitr::read_chunk(file.path(sensitivity_root, "scenario.R"))
knitr::read_chunk(file.path(sensitivity_root, "compare.R"))
knitr::read_chunk(file.path(sensitivity_root, "prepare-fixed-groups.R"))
knitr::read_chunk(file.path(sensitivity_root, "fixed-groups.R"))
knitr::read_chunk(file.path(sensitivity_root, "compare-fixed-groups.R"))
comparison <- function(name) read.csv(file.path(sensitivity_root, "comparison", paste0(name, ".csv")))
scenario_table <- function(scenario, name) read.csv(file.path(sensitivity_root, scenario, "results/tables", paste0(name, ".csv")))
source("R/report_tables.R")

1 Question and comparison design

This sensitivity asks whether the exposure patterns and subsequent analyses depend on using questionnaire-derived midsleep on free days corrected for sleep debt (MSFsc). We replace it with diary-derived corrected midsleep (MSFsc(diary)), a single timing measure per participant calculated from recorded sleep episodes. Daily phase is still defined relative to that participant’s stable timing measure, not the midpoint of each individual night’s sleep.

Three analyses separate changes in the timing measure from changes in the available sample:

  1. The original questionnaire-MSFsc analysis includes 140 near-eye participants.
  2. A matched questionnaire-MSFsc analysis retains only participants with a valid diary night before at least one work day and one free day. Quartiles and all models are refitted on this sample.
  3. The MSFsc(diary) analysis uses exactly the same exposure observations as the matched analysis, but recomputes quartiles and relative phase from MSFsc(diary).

A further comparison holds the matched questionnaire quartiles fixed while changing phase alignment to MSFsc(diary). This intermediate scenario separates the timing change from the subsequent reclassification on the same records. It repeats the near-eye phase and daylength models, their inference and diagnostics; the full downstream analyses listed below belong to the two complete matched analyses.

The established questionnaire-based MSFsc measure defines the primary analysis; MSFsc(diary) is a diary-derived correlate used for sensitivity assessment. The Gaussian response, cyclic smooths, random effects, photoperiod terms, autoregressive resets, covariance methods, seeds, and local-support requirement are retained. Clock-time models are also refitted because replacing the timing measure changes chronotype-group membership. Chest measurements, questionnaire-based chronotype sensitivity, predictive validation, attribution, and model-structure sensitivities are repeated in separate output directories.

The preparation script, scenario driver, generalized interval calculations, and comparison script produce the results below. The model fits and covariance simulations are precomputed; this render reads their recorded outputs. The actual producing code is shown beside each analytical stage. A frozen copy of the original R producers is retained in sensitivity/diary-msfsc/source-snapshot/.

2 Deriving MSFsc(diary)

For each diary night, midsleep is the midpoint between sleep onset and final awakening in local wall-clock time. The label comes from the waking day: sleep from Saturday to a free Sunday is free-day sleep; sleep from Sunday to a work Monday is work-day sleep. The same upstream interval eligibility and quarantine rules as the diary side-analysis apply. Means use a fixed noon boundary so that nearby sleep times on either side of midnight remain adjacent.

Let \(n_W\) and \(n_F\) be the numbers of recorded work- and free-day nights, \(SD_W\) and \(SD_F\) their mean sleep-period durations, and \(MS_F\) mean free-day midsleep. We calculate

\[ SD_{all}=\frac{n_W SD_W+n_F SD_F}{n_W+n_F},\qquad \mathrm{MSF}_{\mathrm{sc(diary)}}=MS_F-\frac{\max(0,SD_F-SD_{all})}{2}. \]

The work- and free-day means and the observed category counts determine the correction. This is a diary equivalent of MSFsc rather than a complete repeat of MCTQ scoring: the diary input does not identify whether an alarm ended free-day sleep. Participants with only one day type cannot supply the corrected measure and are excluded from both matched analyses.

paths <- input_paths()
chronotype <- readRDS(paths[["chronotype"]]) |>
  transmute(site, Id, questionnaire_msfsc_hours = as.numeric(msf_sc) / 3600)
diary <- readRDS(paths[["sleepdiaries"]]) |>
  left_join(chronotype, by = c("site", "Id"), relationship = "many-to-one") |>
  mutate(
    participant_key = paste(site, Id, sep = "::"),
    waking_date = as.Date(wake_wall, tz = "UTC"),
    daytype = factor(
      as.character(daytype2),
      levels = c("a work day", "a free day"),
      labels = c("Work", "Free")
    ),
    duration_hours = as.numeric(difftime(
      wake_wall,
      sleep_onset_wall,
      units = "hours"
    )),
    midpoint_wall = sleep_onset_wall + duration_hours * 3600 / 2,
    midsleep_hours = (as.numeric(midpoint_wall) / 3600) %% 24,
    midsleep_unwrapped = ((midsleep_hours + 12) %% 24) - 12,
    eligible_night = is.finite(questionnaire_msfsc_hours) &
      !is.na(sleep_onset_wall) &
      !is.na(wake_wall) &
      sleep_interval_analysis_eligible &
      !sleep_interval_quarantined &
      duration_hours > 0 &
      duration_hours < 24 &
      !is.na(daytype)
  )
valid <- diary |> filter(eligible_night)
stopifnot(!anyDuplicated(valid[c("participant_key", "waking_date")]))
derived <- valid |>
  summarise(
    nights = n(),
    midsleep = mean(midsleep_unwrapped),
    sleep_duration = mean(duration_hours),
    .by = c(site, Id, participant_key, daytype)
  ) |>
  pivot_wider(
    names_from = daytype,
    values_from = c(nights, midsleep, sleep_duration)
  ) |>
  mutate(
    eligible = !is.na(nights_Work) &
      !is.na(nights_Free) &
      nights_Work >= 1L &
      nights_Free >= 1L,
    weighted_sleep_duration = (nights_Work *
      sleep_duration_Work +
      nights_Free * sleep_duration_Free) /
      (nights_Work + nights_Free),
    correction_hours = pmax(0, sleep_duration_Free - weighted_sleep_duration) /
      2,
    diary_msfsc_hours = midsleep_Free - correction_hours
  ) |>
  left_join(chronotype, by = c("site", "Id"), relationship = "one-to-one") |>
  mutate(
    offset_minutes = wrap12(diary_msfsc_hours - questionnaire_msfsc_hours) * 60
  )
write.csv(
  diary,
  file.path(sensitivity_root, "diary-night-registry.csv"),
  row.names = FALSE
)
write.csv(
  derived,
  file.path(sensitivity_root, "derived-msfsc-participants.csv"),
  row.names = FALSE
)
parent_derivation <- read.csv(
  "results/tables/sleep_diary_msfsc_participants.csv"
) |>
  filter(eligible) |>
  select(site, Id, diary_msfsc_hours)
replication <- inner_join(
  filter(derived, eligible),
  parent_derivation,
  by = c("site", "Id"),
  suffix = c("", "_reported"),
  relationship = "one-to-one"
)
stopifnot(
  nrow(replication) == nrow(parent_derivation),
  max(abs(
    replication$diary_msfsc_hours - replication$diary_msfsc_hours_reported
  )) <
    1e-10
)
sample_summary <- comparison("samples_and_cutoffs")
show_table(sample_summary |> mutate(cutoffs = sprintf("%.2f / %.2f / %.2f", cutoff25, cutoff50, cutoff75)) |>
  select(scenario, participants, participant_days, half_hours, cutoffs), digits = 2)
Table 1: Samples and quartile cutoffs. Cutoffs are hours of local clock time.
Scenario Participants Participant-days Valid half-hours Cutoffs
Original questionnaire (140) 140 778 35,949 3.17 / 4.26 / 5.25
Matched questionnaire (135) 135 755 34,884 3.17 / 4.29 / 5.23
Diary MSFsc(diary) (135) 135 755 34,884 3.28 / 4.42 / 5.33
metric_summary <- comparison("metric_comparison")
show_table(metric_summary |> mutate(offset_IQR = sprintf("%.1f to %.1f",
  lower_quartile_offset_minutes, upper_quartile_offset_minutes)) |>
  select(correlation, median_offset_minutes, offset_IQR, median_absolute_offset_minutes))
reassignment <- read.csv(file.path(sensitivity_root, "quartile-reassignment.csv"))
changed_groups <- sum(reassignment$n[reassignment$questionnaire_quartile != reassignment$diary_quartile])
Table 2: Agreement between diary and questionnaire measures in the common near-eye sample. Offsets are diary minus questionnaire timing, in minutes.
Correlation Median offset minutes Offset IQR Median absolute offset minutes
0.787 6.095 -27.5 to 36.3 34.062

The two matched analyses retain 135 participants, 755 participant-days and 34,884 half-hours. The timing measures correlate at \(r=\) 0.79, with a median diary-minus-questionnaire difference of 6.1 minutes. Nevertheless, 50 participants change quartile, so this sensitivity tests both phase alignment and group classification.

show_table(reassignment |> pivot_wider(names_from = diary_quartile, values_from = n, values_fill = 0))
Table 3: Participant counts by questionnaire and diary quartile on the matched sample.
Questionnaire quartile Q1 Q2 Q3 Q4
Q1 28 6 1 0
Q2 6 19 5 3
Q3 0 8 16 9
Q4 0 1 11 22

The most common changes were Q4 to Q3 (11 participants, extreme to moderate evening type) and Q3 to Q4 (9 participants, moderate to extreme evening type). The full matrix above retains all transitions, including participants who stayed in the same quartile.

The night registry records waking-day labels and exclusions; the participant derivation records category means, counts and corrections. The MSFsc(diary) derivation is checked against the independently generated diary-side-analysis table before any models are fitted.

Show matched-sample preparation and phase reassignment
original <- readRDS("results/data/prepared.rds")
eligible <- filter(derived, eligible)
scenarios <- c("matched-msfsc", "dmsfsc")
for (scenario in scenarios) {
  scenario_root <- file.path(sensitivity_root, scenario)
  dir.create(
    file.path(scenario_root, "R"),
    recursive = TRUE,
    showWarnings = FALSE
  )
  for (folder in c(
    "data",
    "tables",
    "models",
    "figures",
    "diagnostics",
    "subsets",
    "validation",
    "provenance",
    "logs"
  ))
    dir.create(
      file.path(scenario_root, "results", folder),
      recursive = TRUE,
      showWarnings = FALSE
    )
  for (file in list.files(snapshot, full.names = TRUE))
    if (!file.exists(file.path(scenario_root, "R", basename(file))))
      stopifnot(file.copy(file, file.path(scenario_root, "R", basename(file))))
  if (!file.exists(file.path(scenario_root, "input-data")))
    stopifnot(file.symlink(
      file.path(original_root, "input-data"),
      file.path(scenario_root, "input-data")
    ))
  stopifnot(file.copy(
    ".Rprofile",
    file.path(scenario_root, ".Rprofile"),
    overwrite = TRUE
  ))
  frames <- lapply(original$frames, function(x) {
    z <- x |>
      inner_join(
        select(eligible, participant_key, diary_msfsc_hours),
        by = "participant_key",
        relationship = "many-to-one"
      ) |>
      mutate(
        questionnaire_msfsc_hours = msf_hours,
        msf_hours = if (scenario == "dmsfsc") diary_msfsc_hours else msf_hours,
        phase = wrap24(clock - msf_hours),
        phase_display = wrap12(clock - msf_hours)
      ) |>
      assign_sequences()
    stopifnot(
      all(is.finite(z$msf_hours)),
      !anyDuplicated(z[c("participant_day_key", "clock_bin")])
    )
    z
  })
  cutoffs <- quartile_cutoffs(frames$glasses)
  frames <- lapply(frames, apply_quartiles, cutoffs = cutoffs)
  registry <- bind_rows(frames, .id = "placement") |>
    select(
      all_of(names(original$registry)),
      questionnaire_msfsc_hours,
      diary_msfsc_hours
    )
  flow <- bind_rows(lapply(names(frames), function(placement) {
    bind_rows(
      mutate(
        count_sample(original$frames[[placement]]),
        stage = "Original analysis sample"
      ),
      mutate(
        count_sample(frames[[placement]]),
        stage = "Both diary day types available"
      )
    ) |>
      mutate(placement = placement, .before = 1)
  }))
  participants <- distinct(
    frames$glasses,
    participant_key,
    quartile,
    direction,
    extremity,
    msf_hours,
    meq,
    meq_type
  )
  prepared <- list(
    frames = frames,
    registry = registry,
    cutoffs = cutoffs,
    manifest = original$manifest,
    flow = flow,
    participants = participants,
    scenario = scenario,
    derivation = eligible,
    signature = digest::digest(list(scenario, frames, eligible))
  )
  saveRDS(
    prepared,
    file.path(scenario_root, "results/data/prepared.rds"),
    compress = FALSE
  )
  write.csv(
    registry,
    file.path(scenario_root, "results/data/sample_registry.csv"),
    row.names = FALSE
  )
  write.csv(
    flow,
    file.path(scenario_root, "results/tables/sample_flow.csv"),
    row.names = FALSE
  )
  write.csv(
    tibble(
      percentile = c(25, 50, 75),
      msf_hours = cutoffs,
      clock_time = clock_label(cutoffs)
    ),
    file.path(scenario_root, "results/tables/quartile_cutoffs.csv"),
    row.names = FALSE
  )
  write.csv(
    participants,
    file.path(scenario_root, "results/tables/participants.csv"),
    row.names = FALSE
  )
  write.csv(
    bind_rows(frames, .id = "placement") |>
      summarise(
        participants = n_distinct(participant_key),
        participant_days = n_distinct(participant_day_key),
        half_hours = n(),
        .by = c(placement, quartile, daytype)
      ),
    file.path(scenario_root, "results/tables/group_day_counts.csv"),
    row.names = FALSE
  )
}
matched <- readRDS(file.path(
  sensitivity_root,
  "matched-msfsc/results/data/prepared.rds"
))
changed <- readRDS(file.path(
  sensitivity_root,
  "dmsfsc/results/data/prepared.rds"
))
for (placement in names(matched$frames)) {
  unchanged <- c(
    "participant_key",
    "participant_day_key",
    "clock_bin",
    "clock",
    "response",
    "daytype",
    "photoperiod_hours",
    "AR_start",
    "source_utc_start",
    "true_elapsed_sequence_id"
  )
  stopifnot(identical(
    matched$frames[[placement]][unchanged],
    changed$frames[[placement]][unchanged]
  ))
}
overlap <- inner_join(
  select(
    matched$participants,
    participant_key,
    questionnaire_quartile = quartile
  ),
  select(changed$participants, participant_key, diary_quartile = quartile),
  by = "participant_key",
  relationship = "one-to-one"
)
write.csv(
  overlap,
  file.path(sensitivity_root, "quartile-reassignment-participants.csv"),
  row.names = FALSE
)
write.csv(
  count(overlap, questionnaire_quartile, diary_quartile),
  file.path(sensitivity_root, "quartile-reassignment.csv"),
  row.names = FALSE
)
write.csv(
  bind_rows(lapply(
    scenarios,
    function(scenario)
      mutate(
        read.csv(file.path(
          sensitivity_root,
          scenario,
          "results/tables/sample_flow.csv"
        )),
        scenario = scenario
      )
  )),
  file.path(sensitivity_root, "sample-flow.csv"),
  row.names = FALSE
)
capture.output(
  sessionInfo(),
  file = file.path(sensitivity_root, "preparation-session.txt")
)
cat(
  "Prepared matched and dMSFsc scenarios:",
  nrow(matched$participants),
  "near-eye participants.\n"
)

3 Exposure models and contrasts

Both time coordinates use the original full model structure. Near-eye quartile cutoffs also define groups in the chest analysis. Main contrasts have 95% simultaneous coverage across the registered contrast family and all grid points within each time coordinate. The four-participant local-support rule is applied separately to every contributing quartile/day-type cell. The primary exposure-curve bands use the original simultaneous-curve convention.

if (stage == "primary") {
  for (label in c("primary", "chest")) {
    raw <- prepared$frames[[if (label == "primary") "glasses" else "chest"]]
    prep <- fit_preprocess(raw, prepared$cutoffs)
    for (axis in c("clock", "phase")) {
      bundle <- fit_pair(raw, prep, axis, label)
      inference <- infer_curves(bundle)
      inference$individual_draws <- NULL
      atomic_rds(
        inference,
        paste0("results/data/", label, "_", axis, "_inference.rds")
      )
      intervals <- interval_average_contrasts(inference, bundle)
      save_table(intervals, paste0(label, "_", axis, "_interval_averages"))
      diagnose_model(bundle)
      save_table(model_summary(bundle), paste0(label, "_", axis, "_model_fit"))
      rm(bundle, inference)
      gc()
    }
  }
}
fit_summary <- comparison("model_fit")
show_table(fit_summary |> select(scenario, axis, ordinary_R2, adjusted_R2, rho, edf), digits = 3)
Table 4: Fit statistics for the original and matched near-eye models.
Scenario Axis Ordinary R² Adjusted R² Rho Edf
Original questionnaire (140) clock 0.795 0.789 0.594 1,095.208
Original questionnaire (140) phase 0.794 0.787 0.596 1,127.071
Matched questionnaire (135) clock 0.795 0.789 0.595 1,058.461
Matched questionnaire (135) phase 0.794 0.787 0.597 1,086.651
Diary MSFsc(diary) (135) clock 0.797 0.790 0.593 1,062.285
Diary MSFsc(diary) (135) phase 0.794 0.788 0.594 1,071.727

Ordinary in-sample R² changes little: the matched questionnaire models explain 0.795 and 0.794 in clock and relative time; the corresponding MSFsc(diary) values are 0.797 and 0.794. Thus any changes in group contrasts occur within broadly similar overall fit.

diagnostics <- comparison("primary_diagnostics")
show_table(diagnostics |> select(scenario, axis, convergence_ok, basis_flag,
  standardized_lag1, spread_ratio))
Table 5: Primary-model convergence, basis checks, residual dependence and spread.
Scenario Axis Convergence ok Basis flag Standardized lag1 Spread ratio
Original questionnaire (140) clock TRUE FALSE 0.079 5.636
Matched questionnaire (135) clock TRUE FALSE 0.080 5.544
Diary MSFsc(diary) (135) clock TRUE FALSE 0.080 5.490
Original questionnaire (140) phase TRUE FALSE 0.080 5.912
Matched questionnaire (135) phase TRUE FALSE 0.081 5.778
Diary MSFsc(diary) (135) phase TRUE FALSE 0.084 5.682

All four restricted primary fits converge without a basis-dimension flag. Standardized lag-one residual correlations remain about 0.08. Unequal residual spread remains similar to the original analysis; the diary measure does not resolve that feature of the Gaussian model.

knitr::include_graphics(file.path(sensitivity_root, "comparison/contrasts.png"))
Two panels compare extreme evening-to-morning exposure ratios by clock time and relative midsleep time. Three curves distinguish the original questionnaire analysis, its matched-sample repeat, and the diary-derived analysis.
Figure 1: Extreme evening-type/morning-type exposure ratios using questionnaire MSFsc and MSFsc(diary). The matched analyses contain identical light observations. Bands are simultaneous within coordinate. A ratio of one denotes equal fitted exposure; the timing metric and group definitions differ between the two matched analyses.
selected_windows <- comparison("primary_significant_windows") |>
  filter(axis == "phase", contrast == "evening_morning_Extreme_Overall")
show_table(selected_windows |> select(scenario, start, end, wraps_boundary, duration_hours, mean_ratio))
Table 6: Simultaneously supported extreme-group windows in the phase models. A TRUE circular-boundary flag means the interval continues through +12/−12 hours; its start is therefore numerically greater than its end.
Scenario Start End Wraps boundary Duration hours Mean ratio
Original questionnaire (140) −11.250 −9.583 FALSE 1.667 0.158
Original questionnaire (140) 0.917 4.417 FALSE 3.500 13.999
Matched questionnaire (135) 0.917 4.583 FALSE 3.667 14.174
Diary MSFsc(diary) (135) 11.917 −5.250 TRUE 6.833 0.149
Diary MSFsc(diary) (135) 0.917 5.250 FALSE 4.333 23.430

The matched questionnaire repeat and MSFsc(diary) analysis identify their own significant windows. These selected intervals need not have the same endpoints. A window that crosses +12/−12 hours is displayed as circular and should not be interpreted as a simple interval ending at midnight or at MSFsc.

The matched-questionnaire analysis retains a post-MSFsc window but its pre-MSFsc contrast no longer excludes equality throughout any interval under the simultaneous bands. With MSFsc(diary), the post-midsleep window extends from approximately 0.9 to 5.3 hours; the opposite difference extends from +11.9 hours through +12/−12 to −5.3 hours. The latter includes the transferred DLMO reference interval, whose applicability to MSFsc(diary) remains an assumption.

To compare effect sizes over the same phase range, we also average each fitted contrast over the original primary windows and over the matched-questionnaire windows. These interval-average 95% confidence intervals are unadjusted, treat the selected window as fixed, and differ from the simultaneous bands used to locate the windows. The table includes the minimum contributing cell count and whether the complete window passes the local-support rule.

Show fixed-window contrasts and their covariance calculation
curves <- contrasts <- windows <- fixed_intervals <- fits <- list()
original_windows <- read.csv(
  "results/tables/primary_phase_significant_windows.csv"
) |>
  filter(contrast == "evening_morning_Extreme_Overall") |>
  mutate(window_source = "Original primary fixed")
matched_windows <- read.csv(file.path(
  paths[[2]],
  "results/tables/primary_phase_significant_windows.csv"
)) |>
  filter(contrast == "evening_morning_Extreme_Overall") |>
  mutate(window_source = "Matched questionnaire fixed")
for (scenario in names(paths))
  for (axis in c("clock", "phase")) {
    bundle <- readRDS(file.path(
      paths[[scenario]],
      paste0("results/models/primary_", axis, ".rds")
    ))
    inference <- readRDS(file.path(
      paths[[scenario]],
      paste0("results/data/primary_", axis, "_inference.rds")
    ))
    key <- paste(scenario, axis)
    curves[[key]] <- mutate(inference$curves, scenario = scenario, axis = axis)
    contrasts[[key]] <- mutate(
      inference$contrasts,
      scenario = scenario,
      axis = axis
    )
    windows[[key]] <- mutate(
      inference$windows,
      scenario = scenario,
      axis = axis
    )
    fits[[key]] <- mutate(model_summary(bundle), scenario = scenario)
    if (axis == "phase") {
      selected <- bind_rows(
        original_windows,
        matched_windows,
        filter(
          inference$windows,
          contrast == "evening_morning_Extreme_Overall"
        ) |>
          mutate(window_source = "Scenario-selected")
      )
      cv <- covariance_info(bundle$fit)
      for (i in seq_len(nrow(selected)))
        for (context in c("Overall", "Work", "Free")) {
          id <- paste0("evening_morning_Extreme_", context)
          weights <- inference$registry$W[id, ]
          D <- Reduce(
            `+`,
            Map(function(X, w) X * w, inference$cell_design$X, weights)
          )
          ix <- which(
            wrap24(inference$cell_design$x - selected$start[i]) <
              selected$duration_hours[i] - 1e-10
          )
          estimate <- linear_summary(
            matrix(colMeans(D[ix, , drop = FALSE]), nrow = 1),
            coef(bundle$fit),
            cv$V
          )
          local_support <- filter(
            inference$contrasts,
            contrast == id,
            x %in% inference$cell_design$x[ix]
          )
          fixed_intervals[[length(fixed_intervals) + 1L]] <- bind_cols(
            selected[i, c("start", "end", "duration_hours", "window_source")],
            estimate
          ) |>
            mutate(
              scenario = scenario,
              context = context,
              phase_label = ifelse(end < 0, "Pre-MSFsc", "Post-MSFsc"),
              crosses_boundary = start >= end,
              ratio = 10^estimate,
              ratio_lower = 10^lower,
              ratio_upper = 10^upper,
              supported = all(local_support$supported),
              minimum_cell_participants = min(
                local_support$minimum_cell_participants
              ),
              interval_method = "Mean log contrast; selected window fixed; unadjusted 95% Gaussian interval"
            )
        }
    }
    rm(bundle, inference)
    gc()
  }
curves <- bind_rows(curves)
contrasts <- bind_rows(contrasts)
windows <- bind_rows(windows)
comparison_table(curves, "primary_curves")
comparison_table(contrasts, "primary_contrasts")
comparison_table(windows, "primary_significant_windows")
comparison_table(bind_rows(fixed_intervals), "phase_interval_averages")
comparison_table(bind_rows(fits), "model_fit")
comparison_table(
  bind_rows(lapply(
    c("clock", "phase"),
    function(axis)
      read_scenarios(paste0("diagnostics/primary_", axis, "_verdict.csv"))
  )),
  "primary_diagnostics"
)
intervals <- comparison("phase_interval_averages")
show_table(intervals |> filter(window_source == "Original primary fixed", context == "Overall") |>
  mutate(ratio_CI = sprintf("%.2f (%.2f–%.2f)", ratio, ratio_lower, ratio_upper)) |>
  select(scenario, phase_label, ratio_CI, supported, minimum_cell_participants))
fixed_primary <- intervals |> filter(window_source == "Original primary fixed", context == "Overall")
fixed_post <- fixed_primary |> filter(phase_label == "Post-MSFsc")
fixed_pre <- fixed_primary |> filter(phase_label == "Pre-MSFsc")
Table 7: Like-for-like comparisons over the original primary phase windows, using interval-average 95% confidence intervals.
Scenario Phase label Ratio CI Supported Minimum cell participants
Original questionnaire (140) Pre-MSFsc 0.16 (0.06–0.40) TRUE 33
Original questionnaire (140) Post-MSFsc 14.00 (5.63–34.82) TRUE 33
Matched questionnaire (135) Pre-MSFsc 0.18 (0.07–0.46) TRUE 33
Matched questionnaire (135) Post-MSFsc 14.74 (5.77–37.69) TRUE 34
Diary MSFsc(diary) (135) Pre-MSFsc 0.13 (0.05–0.33) TRUE 31
Diary MSFsc(diary) (135) Post-MSFsc 28.32 (11.32–70.86) TRUE 31

On the original fixed windows, the evening-type/morning-type ratio changes from 0.18 to 0.13 pre-MSFsc and from 14.7 to 28.3 post-MSFsc. The direction of both exposure differences is preserved, with larger separation under diary-based classification. These ratios describe the fitted log-scale exposure contrast; their change is not itself a formal between-model test.

show_table(intervals |> filter(window_source == "Original primary fixed", context != "Overall") |>
  mutate(ratio_CI = sprintf("%.2f (%.2f–%.2f)", ratio, ratio_lower, ratio_upper)) |>
  select(scenario, context, phase_label, ratio_CI, supported))
Table 8: Work/free-day comparisons over the same original primary windows.
Scenario Context Phase label Ratio CI Supported
Original questionnaire (140) Work Pre-MSFsc 0.13 (0.05–0.34) TRUE
Original questionnaire (140) Free Pre-MSFsc 0.21 (0.08–0.55) TRUE
Original questionnaire (140) Work Post-MSFsc 15.53 (6.14–39.31) TRUE
Original questionnaire (140) Free Post-MSFsc 12.02 (4.64–31.09) TRUE
Matched questionnaire (135) Work Pre-MSFsc 0.15 (0.06–0.39) TRUE
Matched questionnaire (135) Free Pre-MSFsc 0.24 (0.09–0.64) TRUE
Matched questionnaire (135) Work Post-MSFsc 16.82 (6.45–43.82) TRUE
Matched questionnaire (135) Free Post-MSFsc 12.22 (4.58–32.60) TRUE
Diary MSFsc(diary) (135) Work Pre-MSFsc 0.14 (0.05–0.35) TRUE
Diary MSFsc(diary) (135) Free Pre-MSFsc 0.12 (0.05–0.33) TRUE
Diary MSFsc(diary) (135) Work Post-MSFsc 39.87 (15.62–101.74) TRUE
Diary MSFsc(diary) (135) Free Post-MSFsc 17.39 (6.63–45.63) TRUE

4 Photoperiod and civil daylight

The expanded phase model retains the constrained quartile-specific photoperiod interaction. Main targets are one hour below, at, and one hour above each site’s mean observed civil photoperiod. Participant-weighted quartile and 10th/90th-percentile targets are repeated as sensitivities. The daylength figures retain 95% pointwise intervals, as in the main report. Low local support withholds significance rather than preventing a scenario from being calculated.

if (stage == "daylight") {
  raw <- prepared$frames$glasses
  prep <- fit_preprocess(raw, prepared$cutoffs)
  bundle <- daylight_fit(raw, prep)
  checks <- daylight_basis_checks(bundle)
  stopifnot(all(checks$passed))
  diagnose_model(bundle)
  save_table(model_summary(bundle), "daylight_model_summary")
  own_windows <- read.csv(
    "results/tables/primary_phase_significant_windows.csv"
  ) |>
    filter(contrast == "evening_morning_Extreme_Overall")
  original_windows <- read.csv(
    "../../../results/tables/primary_phase_significant_windows.csv"
  ) |>
    filter(contrast == "evening_morning_Extreme_Overall")
  windows <- bind_rows(
    mutate(own_windows, window_source = "Scenario-selected"),
    mutate(original_windows, window_source = "Original primary fixed")
  )
  if (scenario == "dmsfsc") {
    matched_windows <- read.csv(
      "../matched-msfsc/results/tables/primary_phase_significant_windows.csv"
    ) |>
      filter(contrast == "evening_morning_Extreme_Overall")
    windows <- bind_rows(
      windows,
      mutate(matched_windows, window_source = "Matched questionnaire fixed")
    )
  }
  all_intervals <- list()
  for (specification in c("fixed", "quartiles", "p10_p90")) {
    prefix <- if (specification == "fixed") "daylight" else
      paste0("daylight_", specification)
    design <- diary_daylight_design(bundle$data, specification, prefix)
    inference <- daylight_inference(bundle, design)
    daylight_windows(bundle, inference, design)
    all_intervals[[specification]] <- diary_daylight_intervals(
      bundle,
      inference,
      design,
      windows
    ) |>
      mutate(target_specification = specification)
  }
  save_table(bind_rows(all_intervals), "daylight_interval_comparison")
  diary_solar_summary(bundle, windows)
}
if (stage == "daylight-validation") daylight_validation(prepared)
knitr::include_graphics(file.path(sensitivity_root, "comparison/daylength.png"))
Three moderation curves compare the original questionnaire, matched questionnaire, and diary-derived analyses. The horizontal line at one denotes no photoperiod moderation.
Figure 2: Change in the extreme-group exposure ratio from shorter (−1 h) to longer (+1 h) days. Bands are 95% pointwise intervals. Each model uses its own phase metric and quartile membership; the light observations match between the two restricted analyses.
daylength <- comparison("daylength_intervals")
show_table(daylength |> filter(window_source == "Original primary fixed", contrast == "Longer_minus_shorter") |>
  mutate(ratio_CI = sprintf("%.2f (%.2f–%.2f)", ratio, ratio_lower, ratio_upper)) |>
  select(scenario, target_specification, phase_label, ratio_CI, supported, minimum_cell_participants))
daylength_post <- daylength |> filter(window_source == "Original primary fixed",
  contrast == "Longer_minus_shorter", target_specification == "fixed", phase_label == "Post-MSFsc")
Table 9: Longer/shorter ratios of the extreme-group exposure ratio within the original primary windows. These are interval-average, unadjusted 95% confidence intervals.
Scenario Target specification Phase label Ratio CI Supported Minimum cell participants
Matched questionnaire (135) fixed Pre-MSFsc 0.80 (0.32–1.97) TRUE 12
Matched questionnaire (135) fixed Post-MSFsc 2.66 (1.10–6.43) TRUE 12
Matched questionnaire (135) quartiles Pre-MSFsc 0.78 (0.30–2.08) TRUE 8
Matched questionnaire (135) quartiles Post-MSFsc 2.88 (1.11–7.48) TRUE 8
Matched questionnaire (135) p10_p90 Pre-MSFsc 0.60 (0.08–4.66) TRUE 4
Matched questionnaire (135) p10_p90 Post-MSFsc 9.22 (1.24–68.29) TRUE 4
Diary MSFsc(diary) (135) fixed Pre-MSFsc 1.05 (0.54–2.03) TRUE 11
Diary MSFsc(diary) (135) fixed Post-MSFsc 1.15 (0.52–2.54) TRUE 11
Diary MSFsc(diary) (135) quartiles Pre-MSFsc 1.05 (0.51–2.15) TRUE 5
Diary MSFsc(diary) (135) quartiles Post-MSFsc 1.17 (0.50–2.74) TRUE 5
Diary MSFsc(diary) (135) p10_p90 Pre-MSFsc 1.11 (0.25–5.00) FALSE 3
Diary MSFsc(diary) (135) p10_p90 Post-MSFsc 1.38 (0.23–8.27) FALSE 3

The post-MSFsc daylength association is sensitive to the timing measure. On the same original window, the matched questionnaire model gives a longer/shorter ratio of 2.66 (95% CI 1.10–6.43), compared with 1.15 (0.52–2.54) using MSFsc(diary). The diary-based interval includes one. The pre-MSFsc moderation remains unresolved in both models. This comparison changes both timing and grouping. The fixed-group comparison below separates these steps while retaining the same participants.

Civil dawn and dusk are independently reprojected onto each participant’s timing measure. Astronomical daylight uses the original participant/day weighting and an absolute-daylength median split. It describes opportunity for daylight, whereas the exposure model uses site-centered photoperiod.

civil <- bind_rows(lapply(c("matched-msfsc", "dmsfsc"), function(scenario)
  mutate(scenario_table(scenario, "daylight_civil_interval_summaries"), scenario = scenario)))
show_table(civil |> filter(window_source == "Original primary fixed") |>
  mutate(phase_window = ifelse(end < 0, "Pre-MSFsc", "Post-MSFsc")) |>
  select(scenario, phase_window, quartile, daylength, availability_percent, participants))
Table 10: Civil-daylight availability within the original primary phase windows.
Scenario Phase window Quartile Daylength Availability percent Participants
matched-msfsc Pre-MSFsc Q1 Longer 100.000 19
matched-msfsc Pre-MSFsc Q4 Shorter 25.292 20
matched-msfsc Pre-MSFsc Q1 Shorter 100.000 16
matched-msfsc Pre-MSFsc Q4 Longer 88.778 15
matched-msfsc Post-MSFsc Q1 Longer 68.960 19
matched-msfsc Post-MSFsc Q4 Shorter 81.889 20
matched-msfsc Post-MSFsc Q1 Shorter 20.337 16
matched-msfsc Post-MSFsc Q4 Longer 100.000 15
dmsfsc Pre-MSFsc Q1 Longer 100.000 17
dmsfsc Pre-MSFsc Q1 Shorter 100.000 18
dmsfsc Pre-MSFsc Q4 Shorter 16.409 22
dmsfsc Pre-MSFsc Q4 Longer 88.821 13
dmsfsc Post-MSFsc Q1 Longer 60.598 17
dmsfsc Post-MSFsc Q1 Shorter 24.140 18
dmsfsc Post-MSFsc Q4 Shorter 85.879 22
dmsfsc Post-MSFsc Q4 Longer 100.000 13

5 Separating phase alignment from quartile classification

We add an intermediate scenario with diary-based phase alignment and fixed questionnaire quartiles. Comparing it with the matched questionnaire analysis changes only alignment; comparing it with the full MSFsc(diary) analysis then changes classification while retaining diary alignment. All three use the same light records, site photoperiod centers, model formulas, standardization weights and support rule. Smoothing parameters and residual autocorrelation are re-estimated for each fit.

Here questionnaire membership means the matched 135-person reference. Its refitted questionnaire cutoffs place three retained participants in a different quartile from the original 140-person analysis. The intermediate scenario preserves every matched-reference assignment.

The preparation and model driver use the frozen model producers. The following code was executed before rendering. It copies questionnaire membership into the diary-timed data and preserves that membership when the shared preprocessing would otherwise assign quartiles again.

group_columns <- c("quartile", "direction", "extremity", "group_label")
raw <- diary$frames$glasses
reference <- matched$frames$glasses
changing_columns <- c("msf_hours", "phase", "phase_display", group_columns)
unchanged_columns <- setdiff(names(reference), changing_columns)
stopifnot(
  identical(raw[unchanged_columns], reference[unchanged_columns]),
  !anyDuplicated(raw[c("participant_day_key", "clock_bin")])
)
raw[group_columns] <- reference[group_columns]
stopifnot(
  identical(raw[group_columns], reference[group_columns]),
  identical(raw$phase, diary$frames$glasses$phase),
  all(abs(raw$phase - wrap24(raw$clock - raw$diary_msfsc_hours)) < 1e-12),
  all(abs(raw$msf_hours - raw$diary_msfsc_hours) < 1e-12)
)
prepared <- list(
  frames = list(glasses = raw),
  cutoffs = matched$cutoffs,
  participants = distinct(
    raw,
    participant_key,
    quartile,
    direction,
    extremity,
    questionnaire_msfsc_hours,
    diary_msfsc_hours
  ),
  scenario = "dmsfsc-fixed-groups",
  grouping_metric = "Questionnaire MSFsc on the matched sample",
  phase_metric = "Diary-derived dMSFsc",
  signature = digest::digest(list(raw, matched$cutoffs, "fixed-groups-1.0"))
)
# The shared preprocessing normally reassigns groups from msf_hours. Use the
# questionnaire value only for classification, then restore diary timing.
original_apply_quartiles <- apply_quartiles
apply_quartiles <- function(x, cutoffs) {
  stopifnot(all(is.finite(x$questionnaire_msfsc_hours)))
  diary_timing <- x$msf_hours
  x$msf_hours <- x$questionnaire_msfsc_hours
  x <- original_apply_quartiles(x, cutoffs)
  x$msf_hours <- diary_timing
  x
}
raw <- prepared$frames$glasses
prep <- fit_preprocess(raw, prepared$cutoffs)
model_data <- apply_preprocess(raw, prep, "phase")
reference <- readRDS("../matched-msfsc/results/models/primary_phase.rds")$data
diary_data <- readRDS("../dmsfsc/results/models/primary_phase.rds")$data
fixed_columns <- setdiff(
  names(reference),
  c("msf_hours", "phase", "phase_display", "t")
)
stopifnot(
  identical(model_data[fixed_columns], reference[fixed_columns]),
  identical(
    model_data[c("t", "phase", "phase_display", "msf_hours")],
    diary_data[c("t", "phase", "phase_display", "msf_hours")]
  )
)
show_table(comparison("fixed_groups_samples") |>
  select(alignment, classification, participants, participant_days, half_hours))
Table 11: Matched comparison design. The intermediate scenario changes phase alignment while preserving questionnaire classification.
Alignment Classification Participants Participant-days Valid half-hours
Questionnaire Questionnaire 135 755 34,884
Diary Questionnaire 135 755 34,884
Diary Diary 135 755 34,884

The intermediate scenario repeats the primary phase fit and its simultaneous inference, followed by the photoperiod extension and all three target specifications. It addresses the exposure contrast and daylength moderation directly; it does not repeat the clock-time fits, prediction, attribution or PRC calculations, whose two full-scenario comparisons remain above and below.

if (stage == "primary") {
  bundle <- fit_pair(raw, prep, "phase", "primary")
  stopifnot(identical(bundle$data$quartile, reference$quartile))
  inference <- infer_curves(bundle)
  inference$individual_draws <- NULL
  atomic_rds(inference, "results/data/primary_phase_inference.rds")
  save_table(
    interval_average_contrasts(inference, bundle),
    "primary_phase_interval_averages"
  )
  diagnose_model(bundle)
  save_table(model_summary(bundle), "primary_phase_model_fit")
}
if (stage == "daylight") {
  bundle <- daylight_fit(raw, prep)
  stopifnot(identical(bundle$data$quartile, reference$quartile))
  basis_checks <- daylight_basis_checks(bundle)
  stopifnot(all(basis_checks$passed))
  save_table(basis_checks, "daylight_basis_checks", "results/provenance")
  diagnose_model(bundle)
  save_table(model_summary(bundle), "daylight_model_summary")
  windows <- read.csv(
    "../../../results/tables/primary_phase_significant_windows.csv"
  ) |>
    filter(contrast == "evening_morning_Extreme_Overall") |>
    mutate(window_source = "Original primary fixed")
  interval_results <- list()
  for (specification in c("fixed", "quartiles", "p10_p90")) {
    prefix <- if (specification == "fixed") "daylight" else
      paste0("daylight_", specification)
    design <- diary_daylight_design(bundle$data, specification, prefix)
    inference <- daylight_inference(bundle, design)
    daylight_windows(bundle, inference, design)
    interval_results[[specification]] <- diary_daylight_intervals(
      bundle,
      inference,
      design,
      windows
    ) |>
      mutate(target_specification = specification)
  }
  save_table(bind_rows(interval_results), "daylight_interval_comparison")
}
show_table(comparison("fixed_groups_diagnostics") |>
  select(scenario, model, convergence_ok, basis_flag, standardized_lag1, spread_ratio))
Table 12: Convergence and residual checks for the three matched phase and daylength comparisons.
Scenario Model Convergence ok Basis flag Standardized lag1 Spread ratio
matched-msfsc Near-eye TRUE FALSE 0.081 5.778
matched-msfsc daylight TRUE FALSE 0.081 6.120
dmsfsc-fixed-groups Near-eye TRUE FALSE 0.083 5.925
dmsfsc-fixed-groups daylight TRUE FALSE 0.083 5.936
dmsfsc Near-eye TRUE FALSE 0.084 5.682
dmsfsc daylight TRUE FALSE 0.083 5.594

For a common comparison, we average the primary contrast and daylength moderation within the original pre- and post-MSFsc windows. Their endpoints remain fixed. The comparison script calculates interval uncertainty from the covariance of the average design vector, as in the preceding fixed-window tables.

Show the matched fixed-window calculations
intervals <- curves <- daylength <- fits <- diagnostics <- samples <- list()
model_data <- list()
for (i in seq_len(nrow(scenarios))) {
  scenario <- scenarios$scenario[i]
  result_path <- file.path(root, scenario, "results")
  bundle <- readRDS(file.path(result_path, "models/primary_phase.rds"))
  inference <- readRDS(file.path(
    result_path,
    "data/primary_phase_inference.rds"
  ))
  covariance <- covariance_info(bundle$fit)
  model_data[[scenario]] <- bundle$data
  samples[[scenario]] <- bind_cols(scenarios[i, ], count_sample(bundle$data))
  fits[[scenario]] <- mutate(model_summary(bundle), scenario = scenario)
  for (context in c("Overall", "Work", "Free")) {
    id <- paste0("evening_morning_Extreme_", context)
    weights <- inference$registry$W[id, ]
    contrast_matrix <- Reduce(
      `+`,
      Map(function(x, w) x * w, inference$cell_design$X, weights)
    )
    for (j in seq_len(nrow(windows))) {
      inside <- wrap24(inference$cell_design$x - windows$start[j]) <
        windows$duration_hours[j] - 1e-10
      summary <- linear_summary(
        matrix(colMeans(contrast_matrix[inside, , drop = FALSE]), nrow = 1),
        coef(bundle$fit),
        covariance$V
      )
      support <- inference$contrasts |>
        filter(contrast == id, x %in% inference$cell_design$x[inside])
      intervals[[length(intervals) + 1L]] <- bind_cols(
        scenarios[i, ],
        summary
      ) |>
        mutate(
          context = context,
          phase_label = ifelse(windows$end[j] < 0, "Pre-MSFsc", "Post-MSFsc"),
          start = windows$start[j],
          end = windows$end[j],
          grid_points = sum(inside),
          ratio = 10^estimate,
          ratio_lower = 10^lower,
          ratio_upper = 10^upper,
          supported = all(support$supported),
          minimum_cell_participants = min(support$minimum_cell_participants)
        )
    }
  }
  curves[[scenario]] <- inference$contrasts |>
    filter(contrast == "evening_morning_Extreme_Overall") |>
    transmute(
      scenario = scenario,
      label = scenarios$label[i],
      x = wrap12(x),
      ratio,
      lower = ratio_lower,
      upper = ratio_upper,
      supported,
      significant,
      band = "95% simultaneous"
    )
  daylength[[scenario]] <- read.csv(file.path(
    result_path,
    "tables/daylight_interval_comparison.csv"
  )) |>
    filter(window_source == "Original primary fixed") |>
    mutate(
      scenario = scenario,
      alignment = scenarios$alignment[i],
      classification = scenarios$classification[i],
      label = scenarios$label[i]
    )
  diagnostics[[scenario]] <- bind_rows(lapply(
    c("primary", "daylight"),
    function(model) {
      read.csv(file.path(
        result_path,
        "diagnostics",
        paste0(model, "_phase_verdict.csv")
      )) |>
        mutate(scenario = scenario, model = model)
    }
  ))
  rm(bundle, inference, covariance)
  gc()
}
intervals <- export_comparison(
  bind_rows(intervals),
  "fixed_groups_exposure_intervals"
)
daylength <- export_comparison(
  bind_rows(daylength),
  "fixed_groups_daylength_intervals"
)
export_comparison(bind_rows(samples), "fixed_groups_samples")
export_comparison(bind_rows(fits), "fixed_groups_model_fit")
export_comparison(bind_rows(diagnostics), "fixed_groups_diagnostics")
fixed_groups_exposure <- comparison("fixed_groups_exposure_intervals") |>
  filter(context == "Overall")
show_table(fixed_groups_exposure |>
  mutate(ratio_CI = sprintf("%.2f (%.2f–%.2f)", ratio, ratio_lower, ratio_upper)) |>
  select(alignment, classification, phase_label, ratio_CI, minimum_cell_participants))
Table 13: Overall extreme evening-type/morning-type exposure ratios within the original primary windows. Intervals are unadjusted 95% intervals for the average log contrast.
Alignment Classification Phase label Ratio CI Minimum cell participants
Questionnaire Questionnaire Pre-MSFsc 0.18 (0.07–0.46) 33
Questionnaire Questionnaire Post-MSFsc 14.74 (5.77–37.69) 34
Diary Questionnaire Pre-MSFsc 0.29 (0.11–0.76) 33
Diary Questionnaire Post-MSFsc 8.67 (3.47–21.71) 34
Diary Diary Pre-MSFsc 0.13 (0.05–0.33) 31
Diary Diary Post-MSFsc 28.32 (11.32–70.86) 31
fixed_groups_daylength <- comparison("fixed_groups_daylength_intervals") |>
  filter(target_specification == "fixed", contrast == "Longer_minus_shorter")
show_table(fixed_groups_daylength |>
  mutate(ratio_CI = sprintf("%.2f (%.2f–%.2f)", ratio, ratio_lower, ratio_upper)) |>
  select(alignment, classification, phase_label, ratio_CI, minimum_cell_participants))
timing_only_post <- fixed_groups_daylength |>
  filter(scenario == "dmsfsc-fixed-groups", phase_label == "Post-MSFsc")
Table 14: Longer/shorter ratios of extreme-group exposure ratios at −1 and +1 hour from the site mean, averaged within the original primary windows. Intervals are unadjusted 95% intervals. One denotes no daylength moderation.
Alignment Classification Phase label Ratio CI Minimum cell participants
Questionnaire Questionnaire Pre-MSFsc 0.80 (0.32–1.97) 12
Questionnaire Questionnaire Post-MSFsc 2.66 (1.10–6.43) 12
Diary Questionnaire Pre-MSFsc 0.80 (0.31–2.06) 12
Diary Questionnaire Post-MSFsc 2.39 (0.95–6.02) 12
Diary Diary Pre-MSFsc 1.05 (0.54–2.03) 11
Diary Diary Post-MSFsc 1.15 (0.52–2.54) 11
knitr::include_graphics(file.path(sensitivity_root, "comparison/fixed_groups.png"))
Two panels compare questionnaire timing and groups, diary timing with questionnaire groups retained, and diary timing and groups. The upper panel shows exposure ratios and the lower panel shows longer-day to shorter-day moderation ratios. All three use identical light observations.
Figure 3: Sequential changes in alignment and classification on identical observations. A: primary extreme-group exposure contrasts with 95% simultaneous bands. B: daylength moderation from −1 to +1 hour of centered photoperiod, with 95% pointwise bands. Grey areas mark the original pre- and post-MSFsc comparison windows; zero marks the midsleep measure used in each scenario.

Both fixed-group fits converge without a basis-dimension flag. Standardized residual lag-one correlation is approximately 0.083, with residual spread similar to the other matched fits. Both exposure contrasts retain their directions with questionnaire membership fixed: 0.29 (95% CI 0.11–0.76) pre-MSFsc and 8.7 (3.5–21.7) post-MSFsc.

Changing alignment alone gives a post-MSFsc daylength factor of 2.39 (95% CI 0.95–6.02), compared with 2.66 (1.10–6.43) under matched questionnaire timing. The point estimate remains similar, but its interval now includes one. Also changing the quartile classification reduces the estimate to 1.15 (0.52–2.54). Thus reclassification produces the larger reduction in the estimated association in this sequence, while alignment alone is sufficient for the interval to cross the no-moderation reference. Pre-MSFsc daylength moderation remains unresolved in all three scenarios.

The complete target comparison also contains the quartile and 10th/90th-percentile targets. The comparisons isolate successive changes in the analysis specification; they do not constitute a formal test of the difference between the fitted moderation estimates.

fixed_group_checks <- comparison("fixed_groups_checks")
stopifnot(all(fixed_group_checks$passed))
show_table(fixed_group_checks)
Table 15: Checks that alignment and classification change separately.
Check Passed
Timing-only scenario preserves all non-timing fields TRUE
Timing-only scenario uses exactly the diary alignment TRUE
Final classification change preserves all non-group fields TRUE
All fixed-window exposure comparisons meet the four-person support rule TRUE
All main fixed-window daylength comparisons meet the four-person support rule TRUE
Fixed-group model inputs and producers have unchanged hashes TRUE

6 PRC weighting and the Emens-style balance

The same reconstructed one-hour light PRC is integrated against the estimated extreme-group curves. Published raw and drift-corrected baselines, zero-exposure centering, the original covariance calculation, all five PRC alignment offsets, and the Emens-style regional exposure balance are retained. These are conceptual summaries of exposure timing, not predicted shifts in hours.

The published DLMO-to-MSFsc offsets were established relative to questionnaire MSFsc. Reusing them relative to MSFsc(diary) is a sensitivity assumption, not a new calibration of diary midsleep against DLMO. The central offset remains −6.45 h, the published-reference-interval endpoints −6.95 and −5.95 h, and the wider PRC stress tests −8.45 and −4.45 h. The Emens-style calculation retains its three original reference alignments.

if (stage == "prc") {
  prc <- phase_response_read_prc()
  bundle <- readRDS("results/models/primary_phase.rds")
  inference <- readRDS("results/data/primary_phase_inference.rds")
  result <- phase_response_integrate(prc, bundle, inference)
  phase_response_export(result)
  emens_balance_export(emens_balance(bundle, inference))
}

capture.output(
  sessionInfo(),
  file = paste0("results/provenance/", stage, "_session.txt")
)
save_table(
  tibble(
    stage = stage,
    scenario = scenario,
    started = as.character(started),
    finished = as.character(Sys.time()),
    elapsed_seconds = as.numeric(difftime(Sys.time(), started, units = "secs")),
    prepared_signature = prepared$signature,
    seed = cfg$seed,
    covariance_draws = cfg$draws,
    bootstrap_draws = cfg$bootstrap,
    support_n = cfg$support_n,
    within_coordinate_coverage = cfg$curve_coverage
  ),
  paste0(stage, "_run"),
  "results/provenance"
)
log_step("Completed", scenario, stage)
knitr::include_graphics(file.path(sensitivity_root, "comparison/prc.png"))
Two panels compare raw and drift-corrected PRC group contrasts across all three analyses, with confidence intervals and a zero reference line.
Figure 4: Overall extreme evening-minus-morning PRC-weighted index at the central transferred DLMO alignment. Intervals are 95% coefficient intervals conditional on the external PRC and its alignment. Positive values indicate a relatively more advance-weighted evening-type pattern.
prc <- comparison("prc_contrasts")
show_table(prc |> arrange(scenario, factor(prc_baseline, c("Published raw", "Drift corrected")), context) |>
  select(scenario, prc_baseline, context, estimate, lower, upper))
prc_diary <- prc |> filter(scenario == "Diary dMSFsc (135)", context == "Overall")
Table 16: Extreme evening-minus-morning PRC-weighted indices at the central alignment.
Scenario Prc baseline Context Estimate Lower Upper
Diary MSFsc(diary) (135) Published raw Free 0.201 −0.105 0.507
Diary MSFsc(diary) (135) Published raw Overall 0.306 0.008 0.604
Diary MSFsc(diary) (135) Published raw Work 0.380 0.079 0.682
Diary MSFsc(diary) (135) Drift corrected Free 0.131 −0.132 0.394
Diary MSFsc(diary) (135) Drift corrected Overall 0.236 −0.021 0.494
Diary MSFsc(diary) (135) Drift corrected Work 0.310 0.051 0.570
Matched questionnaire (135) Published raw Free 0.193 −0.105 0.491
Matched questionnaire (135) Published raw Overall 0.219 −0.072 0.510
Matched questionnaire (135) Published raw Work 0.238 −0.057 0.532
Matched questionnaire (135) Drift corrected Free 0.202 −0.054 0.458
Matched questionnaire (135) Drift corrected Overall 0.180 −0.071 0.431
Matched questionnaire (135) Drift corrected Work 0.165 −0.089 0.418
Original questionnaire (140) Published raw Free 0.172 −0.127 0.472
Original questionnaire (140) Published raw Overall 0.198 −0.094 0.491
Original questionnaire (140) Published raw Work 0.216 −0.080 0.512
Original questionnaire (140) Drift corrected Free 0.166 −0.091 0.423
Original questionnaire (140) Drift corrected Overall 0.146 −0.106 0.398
Original questionnaire (140) Drift corrected Work 0.132 −0.122 0.387

Both MSFsc(diary) PRC contrasts remain in the more advance-weighted evening-type direction. The published raw curve gives 0.306 (95% CI 0.008 to 0.604), just excluding zero, whereas the drift-corrected contrast is 0.236 (-0.021 to 0.494) and includes zero. This distinction remains conditional on the transferred DLMO alignment and PRC baseline.

alignment <- comparison("prc_alignment_contrasts")
show_table(alignment |> filter(scenario == "Diary dMSFsc (135)", context == "Overall") |>
  arrange(factor(prc_baseline, c("Published raw", "Drift corrected")), dlmo_offset) |>
  select(prc_baseline, dlmo_offset, estimate, lower, upper))
Table 17: MSFsc(diary) overall PRC contrasts across all transferred DLMO alignments. Offsets are hours relative to MSFsc(diary).
Prc baseline Dlmo offset Estimate Lower Upper
Published raw −8.450 0.592 0.293 0.890
Published raw −6.950 0.391 0.093 0.690
Published raw −6.450 0.306 0.008 0.604
Published raw −5.950 0.213 −0.083 0.510
Published raw −4.450 −0.104 −0.395 0.188
Drift corrected −8.450 0.493 0.235 0.751
Drift corrected −6.950 0.313 0.054 0.571
Drift corrected −6.450 0.236 −0.021 0.494
Drift corrected −5.950 0.153 −0.104 0.409
Drift corrected −4.450 −0.133 −0.384 0.119

At the earlier reference-interval endpoint (−6.95 h), both MSFsc(diary) PRC contrasts exclude zero; at the later endpoint (−5.95 h), both include zero. The wider −4.45 h stress test changes both point estimates to the opposite direction, with intervals spanning zero. Thus the central raw-PRC result does not establish an alignment-independent group difference.

emens <- comparison("emens_contrasts")
show_table(emens |> filter(dlmo_offset == -6.45, contrast == "Evening / morning") |>
  select(scenario, context, estimate, lower, upper))
Table 18: Ratio of extreme evening-type to morning-type Emens-style advance/delay exposure balances at the central alignment. One denotes equal balances between groups.
Scenario Context Estimate Lower Upper
Original questionnaire (140) Overall 1.764 1.207 2.579
Original questionnaire (140) Work 1.824 1.258 2.649
Original questionnaire (140) Free 1.671 1.119 2.502
Matched questionnaire (135) Overall 1.796 1.233 2.653
Matched questionnaire (135) Work 1.872 1.295 2.747
Matched questionnaire (135) Free 1.685 1.125 2.559
Diary MSFsc(diary) (135) Overall 2.075 1.423 3.035
Diary MSFsc(diary) (135) Work 2.246 1.556 3.235
Diary MSFsc(diary) (135) Free 1.808 1.207 2.743

The Emens-style balance retains the same group ordering. At the central alignment the overall evening-type/morning-type balance ratio is 2.08 for MSFsc(diary), compared with 1.80 for matched questionnaire MSFsc; both intervals exclude one.

7 Prediction, attribution and other sensitivities

The five participant-held-out folds and the known-participant final-day holdout are regenerated on the common sample. The two restricted analyses use identical held-out participants and light records. Each training fold estimates its own quartile cutoffs, site photoperiod centers, smoothing parameters and AR correlation. MSFsc(diary) itself is the participant’s stable summary of all available diary nights, so validation evaluates held-out light prediction conditional on having that diary summary; it does not represent prediction before diary collection.

if (stage == "validation") run_validation(prepared)
validation <- comparison("validation_scores")
show_table(validation |> select(scenario, target, axis, RMSE, predictive_R2), digits = 3)
Table 19: Held-out prediction on the original and restricted samples.
Scenario Target Axis RMSE Predictive R²
Original questionnaire (140) Known participants: final day clock 0.852 0.674
Original questionnaire (140) Known participants: final day phase 0.855 0.672
Original questionnaire (140) New participants clock 0.887 0.668
Original questionnaire (140) New participants phase 0.908 0.652
Matched questionnaire (135) Known participants: final day clock 0.856 0.673
Matched questionnaire (135) Known participants: final day phase 0.858 0.672
Matched questionnaire (135) New participants clock 0.888 0.668
Matched questionnaire (135) New participants phase 0.906 0.655
Diary MSFsc(diary) (135) Known participants: final day clock 0.850 0.677
Diary MSFsc(diary) (135) Known participants: final day phase 0.854 0.674
Diary MSFsc(diary) (135) New participants clock 0.883 0.672
Diary MSFsc(diary) (135) New participants phase 0.896 0.662
paired_validation <- comparison("paired_metric_validation")
show_table(paired_validation |> select(target, axis, metric, diary_minus_questionnaire, lower, upper), digits = 4)
Table 20: Paired diary-minus-questionnaire predictive differences on identical held-out records. Intervals use 2,000 participant bootstrap samples stratified by site.
Target Axis Metric Diary minus questionnaire Lower Upper
Known participants: final day clock RMSE −0.0053 −0.0111 0.0005
Known participants: final day clock predictive_R2 0.0040 −0.0004 0.0083
New participants clock RMSE −0.0050 −0.0115 0.0019
New participants clock predictive_R2 0.0037 −0.0014 0.0086
Known participants: final day phase RMSE −0.0034 −0.0108 0.0043
Known participants: final day phase predictive_R2 0.0026 −0.0033 0.0081
New participants phase RMSE −0.0095 −0.0221 0.0037
New participants phase predictive_R2 0.0072 −0.0027 0.0170

The MSFsc(diary) models have slightly lower held-out RMSE and higher predictive R² for new participants. However, the paired intervals include zero for both coordinates, so the small numerical gains do not establish better prediction. Holding out known participants’ final days answers a separate question and is reported in the same table.

show_table(comparison("daylength_validation_differences") |>
  filter(metric %in% c("RMSE", "predictive_R2")) |>
  select(scenario, metric, expanded_minus_primary, lower, upper))
Table 21: Expanded-minus-primary prediction differences for held-out participants. Positive RMSE differences favor the primary model.
Scenario Metric Expanded minus primary Lower Upper
Original questionnaire (140) RMSE 0.004 −0.001 0.010
Original questionnaire (140) predictive_R2 −0.003 −0.008 0.001
Matched questionnaire (135) RMSE 0.002 −0.003 0.008
Matched questionnaire (135) predictive_R2 −0.002 −0.006 0.002
Diary MSFsc(diary) (135) RMSE 0.006 0.002 0.012
Diary MSFsc(diary) (135) predictive_R2 −0.005 −0.009 −0.001

The photoperiod interaction does not improve prediction in either restricted analysis. With MSFsc(diary) it increases held-out RMSE by 0.0065 (95% CI 0.0016–0.0118); the matched-questionnaire increase is 0.0020 (−0.0033–0.0076).

Shapley attribution repeats all 128 model subsets for each time coordinate, holding the full-model AR coefficient fixed as in the primary analysis. Its 2,000 site/participant/day bootstrap replicates use the fitted subset predictions.

if (stage == "attribution") run_attribution(prepared)
shapley <- comparison("shapley")
show_table(shapley |> select(scenario, axis, component, allocation, lower, upper))
chronotype_allocation <- shapley |> filter(axis == "phase", component %in% c("direction", "extremity")) |>
  summarise(allocation = sum(allocation), .by = scenario)
Table 22: Shapley allocations of ordinary in-sample R². Bootstrap intervals retain the original fitted-prediction convention.
Scenario Axis Component Allocation Lower Upper
Original questionnaire (140) clock Chronotype direction 0.006 0.002 0.010
Original questionnaire (140) clock Chronotype strength 0.001 0.000 0.003
Original questionnaire (140) clock daytype 0.009 0.002 0.016
Original questionnaire (140) clock site 0.015 0.008 0.024
Original questionnaire (140) clock photoperiod 0.007 0.001 0.013
Original questionnaire (140) clock participant 0.091 0.072 0.116
Original questionnaire (140) clock participant_day 0.043 0.031 0.058
Matched questionnaire (135) clock Chronotype direction 0.005 0.002 0.009
Matched questionnaire (135) clock Chronotype strength 0.001 0.000 0.002
Matched questionnaire (135) clock daytype 0.009 0.002 0.016
Matched questionnaire (135) clock site 0.016 0.008 0.027
Matched questionnaire (135) clock photoperiod 0.008 0.001 0.013
Matched questionnaire (135) clock participant 0.090 0.069 0.117
Matched questionnaire (135) clock participant_day 0.043 0.030 0.059
Diary MSFsc(diary) (135) clock Chronotype direction 0.006 0.003 0.011
Diary MSFsc(diary) (135) clock Chronotype strength 0.002 0.000 0.003
Diary MSFsc(diary) (135) clock daytype 0.009 0.002 0.017
Diary MSFsc(diary) (135) clock site 0.016 0.008 0.027
Diary MSFsc(diary) (135) clock photoperiod 0.008 0.001 0.013
Diary MSFsc(diary) (135) clock participant 0.089 0.069 0.116
Diary MSFsc(diary) (135) clock participant_day 0.043 0.030 0.059
Original questionnaire (140) phase Chronotype direction 0.010 0.004 0.016
Original questionnaire (140) phase Chronotype strength 0.002 0.000 0.005
Original questionnaire (140) phase daytype 0.008 0.002 0.015
Original questionnaire (140) phase site 0.012 0.005 0.023
Original questionnaire (140) phase photoperiod 0.007 0.001 0.013
Original questionnaire (140) phase participant 0.110 0.087 0.141
Original questionnaire (140) phase participant_day 0.042 0.031 0.057
Matched questionnaire (135) phase Chronotype direction 0.010 0.004 0.016
Matched questionnaire (135) phase Chronotype strength 0.002 −0.001 0.004
Matched questionnaire (135) phase daytype 0.008 0.002 0.015
Matched questionnaire (135) phase site 0.012 0.005 0.025
Matched questionnaire (135) phase photoperiod 0.007 0.002 0.013
Matched questionnaire (135) phase participant 0.108 0.084 0.138
Matched questionnaire (135) phase participant_day 0.042 0.030 0.058
Diary MSFsc(diary) (135) phase Chronotype direction 0.012 0.006 0.018
Diary MSFsc(diary) (135) phase Chronotype strength 0.003 0.001 0.005
Diary MSFsc(diary) (135) phase daytype 0.009 0.003 0.016
Diary MSFsc(diary) (135) phase site 0.011 0.004 0.023
Diary MSFsc(diary) (135) phase photoperiod 0.007 0.001 0.012
Diary MSFsc(diary) (135) phase participant 0.102 0.085 0.124
Diary MSFsc(diary) (135) phase participant_day 0.043 0.030 0.058

Chronotype direction and strength together receive 0.015 R² under MSFsc(diary) phase alignment, compared with 0.012 under matched questionnaire alignment. Individual daily patterns remain the largest allocation in both analyses.

The MEQ sensitivity repeats its paired grouping comparison on the eligible sample. Larger bases, lower/higher AR correlation, deletion of the most concentrated site and influential participant, variance weighting, and noncyclic group margins retain their original specifications. The noncyclic run permits a discontinuity at the phase boundary rather than treating it as a failed cyclic model. Chest and matched-placement summaries use diary eligibility appropriate to the chest sample, not just the near-eye participants.

Show the paired MEQ sensitivity
if (stage == "meq") {
  raw <- meq_prepare(prepared)
  prep <- fit_preprocess(raw, prepared$cutoffs)
  curves <- contrasts <- windows <- summaries <- checks <- list()
  for (classification in c("MEQ", "MSFsc"))
    for (axis in c("clock", "phase")) {
      key <- paste(classification, axis, sep = "_")
      bundle <- meq_fit(raw, prep, axis, classification)
      inference <- meq_inference(bundle)
      summaries[[key]] <- mutate(
        model_summary(bundle),
        classification = classification
      )
      curves[[key]] <- inference$curves
      contrasts[[key]] <- inference$contrasts
      windows[[key]] <- inference$windows
      diagnose_model(bundle)
      checks[[key]] <- tibble(
        classification,
        axis,
        observations_match = identical(
          bundle$data$participant_day_key,
          raw$participant_day_key
        ) &&
          identical(bundle$data$clock_bin, raw$clock_bin),
        support_valid = all(
          !inference$contrasts$candidate_interval |
            inference$contrasts$minimum_cell_participants >= cfg$support_n
        )
      )
      rm(bundle, inference)
      gc()
    }
  save_table(bind_rows(curves), "meq_all_curves")
  save_table(bind_rows(contrasts), "meq_all_contrasts")
  save_table(bind_rows(windows), "meq_candidate_windows")
  save_table(bind_rows(summaries), "meq_model_fit")
  checks <- bind_rows(checks)
  stopifnot(all(checks$observations_match), all(checks$support_valid))
  save_table(checks, "meq_acceptance", "results/provenance")
}
if (stage == "sensitivity") run_sensitivity(prepared)
Show noncyclic group-margin sensitivity
if (stage == "noncyclic") {
  for (axis in c("clock", "phase")) {
    bundle <- noncyclic_sz_fit(axis)
    inference <- infer_curves(bundle)
    inference$windows <- noncyclic_sz_windows(inference, bundle)
    save_table(
      inference$windows,
      paste0("noncyclic_sz_", axis, "_significant_windows")
    )
    atomic_rds(
      inference,
      paste0("results/data/noncyclic_sz_", axis, "_inference.rds")
    )
    boundary <- noncyclic_sz_boundary(bundle)
    save_table(
      boundary$curves,
      paste0("noncyclic_sz_", axis, "_boundary_curves")
    )
    save_table(
      boundary$contrasts,
      paste0("noncyclic_sz_", axis, "_boundary_contrasts")
    )
    save_table(
      model_summary(bundle),
      paste0("noncyclic_sz_", axis, "_model_fit")
    )
    diagnose_model(bundle)
    rm(bundle, inference)
    gc()
  }
}
show_table(comparison("meq_fit") |>
  select(scenario, classification, axis, ordinary_R2, participants, participant_days))
Table 23: MEQ sensitivity fit and analytical sample.
Scenario Classification Axis Ordinary R² Participants Participant-days
Original questionnaire (140) MEQ clock 0.799 68 379
Original questionnaire (140) MEQ phase 0.797 68 379
Original questionnaire (140) MSFsc clock 0.798 68 379
Original questionnaire (140) MSFsc phase 0.797 68 379
Matched questionnaire (135) MEQ clock 0.799 65 365
Matched questionnaire (135) MEQ phase 0.797 65 365
Matched questionnaire (135) MSFsc clock 0.798 65 365
Matched questionnaire (135) MSFsc phase 0.797 65 365
Diary MSFsc(diary) (135) MEQ clock 0.799 65 365
Diary MSFsc(diary) (135) MEQ phase 0.797 65 365
Diary MSFsc(diary) (135) MSFsc clock 0.798 65 365
Diary MSFsc(diary) (135) MSFsc phase 0.796 65 365
show_table(comparison("meq_windows") |>
  filter(axis == "phase", context == "Overall") |>
  select(scenario, classification, start, end, direction, factor_at_mean_difference))
Table 24: Phase-aligned overall morning/evening differences within the paired MEQ sensitivity. The MSFsc classification uses the timing measure named by each scenario.
Scenario Classification Start End Chronotype direction Factor at mean difference
Original questionnaire (140) MEQ 0.917 3.917 Evening higher 8.082
Original questionnaire (140) MSFsc 0.917 4.250 Evening higher 8.489
Matched questionnaire (135) MEQ 1.083 3.917 Evening higher 8.984
Matched questionnaire (135) MSFsc 0.917 4.250 Evening higher 8.976
Diary MSFsc(diary) (135) MEQ 1.083 4.417 Evening higher 11.380
Diary MSFsc(diary) (135) MSFsc 0.917 4.583 Evening higher 12.280

The MEQ-defined comparison also retains higher evening-type exposure post-midsleep when aligned to MSFsc(diary), from about 1.1 to 4.4 hours, compared with 1.1 to 3.9 hours under matched questionnaire alignment. The MEQ group definitions themselves remain unchanged.

show_table(comparison("model_sensitivities") |>
  select(scenario, axis, sensitivity, maximum_contrast_change, rms_contrast_change, convergence))
Table 25: Changes in registered contrasts under the existing model-structure sensitivities. Differences are on the log10 response scale.
Scenario Axis Sensitivity Maximum contrast change Rms contrast change Convergence
Original questionnaire (140) clock larger_basis 0.200 0.034 TRUE
Original questionnaire (140) clock lower_rho 0.041 0.013 TRUE
Original questionnaire (140) clock higher_rho 0.220 0.036 TRUE
Original questionnaire (140) clock delete_site 0.376 0.083 TRUE
Original questionnaire (140) clock delete_participant 0.063 0.014 TRUE
Original questionnaire (140) clock variance_weighted 0.202 0.053 TRUE
Original questionnaire (140) phase larger_basis 0.259 0.043 TRUE
Original questionnaire (140) phase lower_rho 0.050 0.014 TRUE
Original questionnaire (140) phase higher_rho 0.084 0.019 TRUE
Original questionnaire (140) phase delete_site 0.337 0.074 TRUE
Original questionnaire (140) phase delete_participant 0.113 0.028 TRUE
Original questionnaire (140) phase variance_weighted 0.283 0.060 TRUE
Matched questionnaire (135) clock larger_basis 0.245 0.051 TRUE
Matched questionnaire (135) clock lower_rho 0.160 0.035 TRUE
Matched questionnaire (135) clock higher_rho 0.351 0.056 TRUE
Matched questionnaire (135) clock delete_site 0.323 0.070 TRUE
Matched questionnaire (135) clock delete_participant 0.140 0.033 TRUE
Matched questionnaire (135) clock variance_weighted 0.188 0.054 TRUE
Matched questionnaire (135) phase larger_basis 0.194 0.044 TRUE
Matched questionnaire (135) phase lower_rho 0.115 0.030 TRUE
Matched questionnaire (135) phase higher_rho 0.083 0.026 TRUE
Matched questionnaire (135) phase delete_site 0.290 0.069 TRUE
Matched questionnaire (135) phase delete_participant 0.034 0.012 TRUE
Matched questionnaire (135) phase variance_weighted 0.301 0.069 TRUE
Diary MSFsc(diary) (135) clock larger_basis 0.189 0.032 TRUE
Diary MSFsc(diary) (135) clock lower_rho 0.037 0.009 TRUE
Diary MSFsc(diary) (135) clock higher_rho 0.041 0.010 TRUE
Diary MSFsc(diary) (135) clock delete_site 0.223 0.059 TRUE
Diary MSFsc(diary) (135) clock delete_participant 0.071 0.015 TRUE
Diary MSFsc(diary) (135) clock variance_weighted 0.204 0.047 TRUE
Diary MSFsc(diary) (135) phase larger_basis 0.269 0.038 TRUE
Diary MSFsc(diary) (135) phase lower_rho 0.053 0.016 TRUE
Diary MSFsc(diary) (135) phase higher_rho 0.082 0.027 TRUE
Diary MSFsc(diary) (135) phase delete_site 0.242 0.063 TRUE
Diary MSFsc(diary) (135) phase delete_participant 0.053 0.014 TRUE
Diary MSFsc(diary) (135) phase variance_weighted 0.344 0.092 TRUE

All model-structure sensitivity fits converge. Among the MSFsc(diary) phase runs, variance weighting produces the largest change in a registered contrast (0.344 log10 units), followed by larger bases (0.269) and deletion of the most concentrated site (0.242). These summaries quantify changes in fitted contrasts rather than a separate significance test.

show_table(comparison("chest_windows") |>
  filter(axis == "phase", contrast == "evening_morning_Extreme_Overall") |>
  select(scenario, start, end, wraps_boundary, duration_hours, mean_ratio))
Table 26: Simultaneously supported extreme-group windows in the chest phase models.
Scenario Start End Wraps boundary Duration hours Mean ratio
Original questionnaire (140) 11.250 −4.750 TRUE 8.000 0.106
Original questionnaire (140) 0.583 5.250 FALSE 4.667 15.766
Matched questionnaire (135) 11.583 −4.583 TRUE 7.833 0.105
Matched questionnaire (135) 0.583 5.583 FALSE 5.000 18.740
Diary MSFsc(diary) (135) 11.750 −5.083 TRUE 7.167 0.126
Diary MSFsc(diary) (135) 0.583 5.917 FALSE 5.333 29.014

Chest measurements retain both directions of the extreme-group difference. The positive MSFsc(diary) window runs approximately 0.6–5.9 hours post-midsleep; the opposite window crosses the circular boundary and continues to about 5.1 hours before midsleep.

show_table(comparison("noncyclic_windows") |>
  filter(axis == "phase", contrast == "evening_morning_Extreme_Overall") |>
  select(scenario, native_start, native_end, start, end, duration_hours, mean_ratio))
Table 27: Extreme-group windows under noncyclic group margins on the matched samples. Native endpoints retain the model’s 0–24-hour boundary.
Scenario Native start Native end Start End Duration hours Mean ratio
Matched questionnaire (135) 0.917 4.583 0.917 4.583 3.667 12.926
Diary MSFsc(diary) (135) 0.917 5.250 0.917 5.250 4.333 19.514
Diary MSFsc(diary) (135) 12.417 15.250 −11.583 −8.750 2.833 0.160
Diary MSFsc(diary) (135) 16.250 18.750 −7.750 −5.250 2.500 0.178

With noncyclic group margins, the MSFsc(diary) post-midsleep window remains about 0.9–5.3 hours. The broad opposite cyclic window separates into two pre-midsleep sections, approximately −11.6 to −8.8 hours and −7.8 to −5.3 hours. Thus its precise span depends on the group-curve boundary specification.

Individual-curve and peak-timing calculations are also repeated with the original 1,000 joint coefficient draws. Their complete timing table, matched-placement summaries, and each scenario’s plots retain the detailed outputs.

Show individual timing, common photoperiod and placement calculations
if (stage == "outputs") {
  for (label in c("primary", "chest")) {
    curves <- contrasts <- list()
    for (axis in c("clock", "phase")) {
      bundle <- readRDS(paste0("results/models/", label, "_", axis, ".rds"))
      inference <- readRDS(paste0(
        "results/data/",
        label,
        "_",
        axis,
        "_inference.rds"
      ))
      curves[[axis]] <- mutate(inference$curves, axis = axis)
      contrasts[[axis]] <- mutate(inference$contrasts, axis = axis)
      photoperiod_figure(bundle)
      if (label == "primary") {
        set.seed(cfg$seed + if (axis == "phase") 1L else 0L)
        joint_draws <- as.matrix(gratia::gaussian_draws(
          bundle$fit,
          n = cfg$draws,
          unconditional = covariance_info(bundle$fit)$unconditional
        ))
        inference$individual_draws <- joint_draws[
          seq_len(1000L),
          ,
          drop = FALSE
        ]
        rm(joint_draws)
        individual_curves(bundle, inference)
      }
      rm(bundle, inference)
      gc()
    }
    for (context in c("Overall", "Work", "Free")) {
      save_plot(
        pattern_figure(bind_rows(curves), context, label),
        paste0(label, "_patterns_", tolower(context)),
        12,
        11
      )
      for (family in c("Evening minus morning", "Extreme minus moderate"))
        save_plot(
          difference_figure(bind_rows(contrasts), family, context, label),
          paste0(
            label,
            "_",
            gsub(" ", "_", tolower(family)),
            "_",
            tolower(context)
          ),
          12,
          11
        )
    }
    for (family in c("Free minus work", "Interactions"))
      save_plot(
        difference_figure(bind_rows(contrasts), family, placement = label),
        paste0(label, "_", gsub(" ", "_", tolower(family))),
        12,
        14
      )
  }
  matched_placement_check(prepared)
}

8 Checks and reproducibility

This sensitivity’s code, prepared inputs and retained comparison outputs are included in the chronotype analysis repository, whose released snapshots are preserved in the Zenodo archive, doi:10.5281/zenodo.24140946.

The comparison verifies matched light records and AR ordering, identical validation folds, and training-only cutoffs and site centers. Input hashes cover the fixed normalized inputs, original model/inference files and shared R source. Separately requested diary-figure styling and annotation edits are recorded as authorized display changes; all code outside the plot and scatter-display-data stages is checked against the original snapshot. No primary fit or result is replaced by this sensitivity.

checks <- comparison("implementation_checks")
stopifnot(all(checks$passed))
show_table(checks)
Table 28: Implementation checks for the isolated sensitivity.
Check Passed
glasses matched observation rows, response, day labels and AR ordering TRUE
chest matched observation rows, response, day labels and AR ordering TRUE
Identical held-out participant folds TRUE
Matched questionnaire (135) clock fold 1 training-only cutoffs and photoperiod centers TRUE
Matched questionnaire (135) phase fold 1 training-only cutoffs and photoperiod centers TRUE
Matched questionnaire (135) clock fold 2 training-only cutoffs and photoperiod centers TRUE
Matched questionnaire (135) phase fold 2 training-only cutoffs and photoperiod centers TRUE
Matched questionnaire (135) clock fold 3 training-only cutoffs and photoperiod centers TRUE
Matched questionnaire (135) phase fold 3 training-only cutoffs and photoperiod centers TRUE
Matched questionnaire (135) clock fold 4 training-only cutoffs and photoperiod centers TRUE
Matched questionnaire (135) phase fold 4 training-only cutoffs and photoperiod centers TRUE
Matched questionnaire (135) clock fold 5 training-only cutoffs and photoperiod centers TRUE
Matched questionnaire (135) phase fold 5 training-only cutoffs and photoperiod centers TRUE
Diary MSFsc(diary) (135) clock fold 1 training-only cutoffs and photoperiod centers TRUE
Diary MSFsc(diary) (135) phase fold 1 training-only cutoffs and photoperiod centers TRUE
Diary MSFsc(diary) (135) clock fold 2 training-only cutoffs and photoperiod centers TRUE
Diary MSFsc(diary) (135) phase fold 2 training-only cutoffs and photoperiod centers TRUE
Diary MSFsc(diary) (135) clock fold 3 training-only cutoffs and photoperiod centers TRUE
Diary MSFsc(diary) (135) phase fold 3 training-only cutoffs and photoperiod centers TRUE
Diary MSFsc(diary) (135) clock fold 4 training-only cutoffs and photoperiod centers TRUE
Diary MSFsc(diary) (135) phase fold 4 training-only cutoffs and photoperiod centers TRUE
Diary MSFsc(diary) (135) clock fold 5 training-only cutoffs and photoperiod centers TRUE
Diary MSFsc(diary) (135) phase fold 5 training-only cutoffs and photoperiod centers TRUE
All scenario-stage completion, Shapley and noncyclic-basis checks pass TRUE
Matched questionnaire (135) frozen scientific producers match the initial source snapshot TRUE
Diary MSFsc(diary) (135) frozen scientific producers match the initial source snapshot TRUE
Original scientific inputs and models unchanged; authorized diary display edits recorded TRUE
show_table(comparison("completed_stages") |>
  mutate(elapsed_minutes = elapsed_seconds / 60) |>
  select(scenario, stage, finished, elapsed_minutes), digits = 1)
Table 29: Completed calculation stages in the two isolated scenarios. Cached replays record their own elapsed time.
Scenario Stage Finished Elapsed minutes
matched-msfsc Near-eye 2026-11-06 13:38:13.344033 15.3
matched-msfsc validation 2026-11-06 12:43:42.078926 0.0
matched-msfsc attribution 2026-11-06 13:32:54.6052 54.8
matched-msfsc sensitivity 2026-11-06 13:09:20.757327 11.6
matched-msfsc outputs 2026-11-06 13:19:09.660578 1.2
matched-msfsc meq 2026-11-06 12:57:42.579322 2.7
matched-msfsc daylight 2026-11-06 12:49:04.180671 5.4
matched-msfsc daylight-validation 2026-11-06 12:54:59.852946 5.9
matched-msfsc noncyclic 2026-11-06 13:17:57.367284 8.6
matched-msfsc prc 2026-11-06 12:25:16.396598 0.0
dmsfsc Near-eye 2026-11-06 13:35:33.686993 12.0
dmsfsc validation 2026-11-06 12:42:43.354807 0.0
dmsfsc attribution 2026-11-06 13:32:19.682999 54.3
dmsfsc sensitivity 2026-11-06 13:10:16.665236 12.6
dmsfsc outputs 2026-11-06 13:20:23.162255 1.2
dmsfsc meq 2026-11-06 12:57:37.164505 2.8
dmsfsc daylight 2026-11-06 12:48:49.084368 6.1
dmsfsc daylight-validation 2026-11-06 12:54:47.252444 6.0
dmsfsc noncyclic 2026-11-06 13:19:11.509331 8.9
dmsfsc prc 2026-11-06 12:25:15.173488 0.0

To reproduce, run Rscript --vanilla sensitivity/diary-msfsc/prepare.R from the project root. In each scenario directory, run Rscript --vanilla -e 'source("../scenario.R")' with the stages primary, validation, daylight, daylight-validation, prc, meq, sensitivity, noncyclic, outputs, and attribution, then run Rscript --vanilla ../verify-stages.R. Set MELIDOS_MAIN and MELIDOS_R_LIBRARY to the existing project library paths, as shown in the run instructions. Finally run Rscript --vanilla sensitivity/diary-msfsc/compare.R and render this document. The matched questionnaire primary stage must finish before the MSFsc(diary) daylight stage, which also summarizes its fixed windows.

Each scenario keeps saved fits, prediction draws, contrasts, registries, diagnostics, validations, tables and figures under its own results/. Comparison figure data are exported under sensitivity/diary-msfsc/data/intermediate/. The complete interval comparison retains window selection and local support; PRC contrasts retain the main group comparisons. Original-input preservation records the before/after checksums.

For the focused fixed-group extension, run Rscript --vanilla sensitivity/diary-msfsc/prepare-fixed-groups.R, then run Rscript --vanilla -e 'source("../fixed-groups.R")' primary and the corresponding daylight stage inside dmsfsc-fixed-groups/. From the project root, Rscript --vanilla sensitivity/diary-msfsc/compare-fixed-groups.R produces the fixed-group comparisons. The run instructions give the directory and library setup. The new fits, diagnostics, input hashes and R session records stay in that isolated scenario directory.