Alternative preprocessing analysis

The primary analysis derives its metrics from the downloaded recordings using explicit rules for missing intervals, temporal support, and measurement states. This sensitivity analysis asks how the results change when the metrics instead start from a fixed prepared baseline that is less explicit about gap timing. The model specifications are held fixed within each hypothesis.

Fixed local inputs

The six files in data/alternative-baseline/ contain near-eye and chest data:

  • metrics_glasses.RData and metrics_chest.RData contain participant and daily metrics.
  • metrics_separate_glasses.RData and metrics_separate_chest.RData contain the prepared 30-minute values.
  • preprocessed_glasses_2.RData and preprocessed_chest_2.RData contain the minute series used to derive hourly means and MDER.

Preparation of the analysis datasets imports these local inputs on every render. It checks their object structure, applies the metric crosswalk, derives hourly means, and recalculates MDER as the mean of positive, finite simultaneous minute ratios. MDER requires at least 720 viable ratios on a complete 1,440-minute local-clock grid. Other baseline metrics retain their input values.

The prepared baseline is the input to this alternative analysis. The primary analysis is reproduced from the downloaded recordings. No network download is needed when either analysis is rendered.

Compare metric values and sample support

The following comparison uses the model-ready inputs from the same render. It reports available rows in each scenario and differences on their common sample. Participant-level metrics use one row per participant; daily metrics use one row per participant and date. Missing alternatives remain explicit.

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(tibble)
library(gt)
source("scripts/project.R")
analysis_setup()
source("scripts/hypotheses/H01/h01_contract.R")
source("scripts/hypotheses/H01/h01_modeling.R")
root <- getOption("nh.root")
inputs <- h01_input_contract(root)
primary <- readRDS(inputs$main$path)
alternative <- readRDS(inputs$alternative_preprocessing$path)
registry <- h01_metric_registry()
comparisons <- list()
for (placement in c("glasses", "chest")) {
  for (i in seq_len(nrow(registry))) {
    spec <- registry[i, , drop = FALSE]
    main_frame <- h01_prepare_model_frame(primary, spec, placement, "all_available")
    alternative_frame <- h01_prepare_model_frame(alternative, spec, placement, "all_available")
    common <- if (nrow(main_frame) && nrow(alternative_frame)) {
      inner_join(
        select(main_frame, site, participant_key, local_date, primary_value = value),
        select(alternative_frame, site, participant_key, local_date, alternative_value = value),
        by = c("site", "participant_key", "local_date"),
        relationship = "one-to-one")
    } else {
      tibble(primary_value = numeric(), alternative_value = numeric())
    }
    difference <- common$alternative_value - common$primary_value
    comparisons[[paste(placement, spec$metric_id)]] <- tibble(
      placement = placement, metric_id = spec$metric_id,
      analysis_unit = spec$analysis_unit,
      primary_rows = nrow(main_frame), alternative_rows = nrow(alternative_frame),
      common_rows = nrow(common),
      mean_alternative_minus_primary = if (length(difference)) mean(difference) else NA_real_,
      maximum_absolute_difference = if (length(difference)) max(abs(difference)) else NA_real_)
  }
}
comparison <- bind_rows(comparisons)
metric_labels <- readr::read_csv("config/metric_display_registry.csv",
  show_col_types = FALSE) |>
  select(metric_id, manuscript_name, display_unit)
comparison |>
  left_join(metric_labels, by = "metric_id", relationship = "many-to-one") |>
  mutate(
    placement = recode(placement, glasses = "Near eye", chest = "Chest"),
    analysis_unit = recode(analysis_unit,
      participant = "Participant", participant_day = "Participant-day"),
    display_unit = if_else(display_unit == "clock time", "min", display_unit)
  ) |>
  select(placement, manuscript_name, display_unit, analysis_unit,
    primary_rows, alternative_rows, common_rows,
    mean_alternative_minus_primary, maximum_absolute_difference) |>
  gt(groupname_col = "placement", rowname_col = "manuscript_name") |>
  cols_label(display_unit = "Unit", analysis_unit = "Analysis unit",
    primary_rows = "Primary rows", alternative_rows = "Alternative rows",
    common_rows = "Common rows", mean_alternative_minus_primary = "Mean difference",
    maximum_absolute_difference = "Maximum absolute difference") |>
  fmt_number(columns = c(mean_alternative_minus_primary, maximum_absolute_difference), decimals = 3)
Unit Analysis unit Primary rows Alternative rows Common rows Mean difference Maximum absolute difference
Near eye
Interdaily stability dimensionless Participant 141 141 141 0.002 0.116
Intradaily variability dimensionless Participant 141 141 141 0.048 0.935
Mean melEDI lx Participant-day 816 811 809 −0.046 5.352
Brightest 10 h mean lx Participant-day 816 811 809 7.095 466.849
Darkest 10 h mean lx Participant-day 816 811 809 −0.015 2.244
Time above 1,000 lx melEDI h Participant-day 816 811 809 −0.010 0.833
Time above 250 lx melEDI during wake h Participant-day 737 755 719 −0.020 0.833
Time below 10 lx melEDI before sleep h Participant-day 655 780 653 −0.003 0.417
Time below 1 lx melEDI during sleep h Participant-day 778 790 771 −0.004 1.817
Longest continuous period above 250 lx melEDI h Participant-day 816 811 809 0.022 3.733
Midpoint of the brightest 10 hours min Participant-day 816 811 809 3.517 687.000
Midpoint of the darkest 10 hours min Participant-day 816 811 809 2.871 1,415.000
Mean timing of exposure above 250 lx melEDI min Participant-day 742 778 737 −1.842 702.424
First light timing above 250 lx melEDI min Participant-day 727 778 720 0.274 117.000
Last light timing above 250 lx melEDI min Participant-day 687 778 684 −0.841 240.000
melEDI dose lx·h Participant-day 761 811 757 −289.470 23,366.879
Melanopic daylight efficacy ratio dimensionless Participant-day 702 687 687 0.000 0.026
Chest
Interdaily stability dimensionless Participant 153 154 153 0.003 0.110
Intradaily variability dimensionless Participant 153 154 153 0.051 1.086
Mean melEDI lx Participant-day 902 897 894 −0.038 4.169
Brightest 10 h mean lx Participant-day 902 897 894 8.937 1,107.461
Darkest 10 h mean lx Participant-day 902 897 894 −0.016 4.314
Time above 1,000 lx melEDI h Participant-day 902 897 894 −0.010 0.800
Time above 250 lx melEDI during wake h Participant-day 818 839 800 −0.017 0.833
Time below 10 lx melEDI before sleep h Participant-day 743 867 740 −0.002 0.417
Time below 1 lx melEDI during sleep h Participant-day 861 878 853 −0.007 1.817
Longest continuous period above 250 lx melEDI h Participant-day 902 897 894 0.022 3.383
Midpoint of the brightest 10 hours min Participant-day 902 897 894 1.187 501.000
Midpoint of the darkest 10 hours min Participant-day 902 897 894 9.541 1,430.000
Mean timing of exposure above 250 lx melEDI min Participant-day 831 867 826 0.478 334.002
First light timing above 250 lx melEDI min Participant-day 802 867 795 0.582 331.000
Last light timing above 250 lx melEDI min Participant-day 787 867 784 −0.790 188.000
melEDI dose lx·h Participant-day 851 897 847 −306.973 31,485.135
Melanopic daylight efficacy ratio dimensionless Participant-day 732 723 723 0.000 0.071

Differences in available rows describe changes in the analysis sample. Differences on common rows describe changes in the untransformed metric values, calculated as alternative minus primary. Timing values are stored as minutes since midnight, so their differences use that linear scale, not the shortest circular distance across midnight. These summaries alone do not assess the stability of model estimates. The individual hypothesis pages fit both scenarios where the alternative metric is available and report their estimates and uncertainty.

Code
readr::write_csv(comparison,
  "results/csv/source_data/alternative_preprocessing_metric_comparison.csv")

Download the metric and sample comparison for the full-precision values and metric identifiers.