Skip to contents

Generated anomalies are represented by ordinary raw-log omissions and a matching manual diary/decision report. The source events themselves are never patched. Study Manager snake-case, camelCase, and QR aliases are accepted, including multiple registration blocks and opaque saliva IDs.

Usage

generate_synthetic_study_data(
  output_dir,
  study_config = NULL,
  n_participants = NULL,
  non_compliant_sample_ratio = 0.1,
  missing_awakening_time_ratio = 0.01,
  missing_sampling_time_ratio = 0.02,
  random_state = 42L,
  create_cortisol_data = FALSE,
  overwrite = FALSE,
  validate = TRUE
)

Arguments

output_dir

Target directory.

study_config

Study Manager-style list, decoded CARWATCH; QR payload, or NULL for the four-day CAR default.

n_participants

Number of generated participants. When NULL, use the configured value or the Study Manager default of 80.

non_compliant_sample_ratio

Proportion of expected samples with timing deliberately outside the default compliance tolerance. Relative and fixed clock-time samples use their respective tolerance-aware deviation ranges.

missing_awakening_time_ratio

Proportion of participant-days with a missing awakening event and first sample.

missing_sampling_time_ratio

Total proportion of expected scans omitted.

random_state

Integer seed, or NULL for unseeded generation. Separate deterministic streams are used for timings, anomaly selection, and cortisol.

create_cortisol_data

Whether to create position-indexed cortisol.csv.

overwrite

Whether an existing target directory may be replaced.

validate

Run advisory and submitted-decision conversion after writing.

Value

The normalized output directory path.

Examples

output <- tempfile("carwatch-study-")
generate_synthetic_study_data(
  output,
  study_config = list(study_days = 1, saliva_distances = c(0, 30)),
  n_participants = 1,
  non_compliant_sample_ratio = 0,
  missing_awakening_time_ratio = 0,
  missing_sampling_time_ratio = 0,
  validate = FALSE
)
#> /tmp/RtmpA0mKCB/carwatch-study-1fa46f1ba32a
unlink(output, recursive = TRUE)