This repository contains the code for the publication “Power analysis for personal light exposure measurements and interventions” by Zauner, Udovicic, and Spitschan (2024). The code is written in the R software and uses Quarto for rendering.
In the script, we use light exposure data from shift workers during day shifts to calculate statistical power of changes in light exposure metrics between seasons.
To reproduce the anaylsis, R and Quarto have to be installed. The code
is found in PowerCalc.qmd. The rendered version of the code can also
be found in the file PowerCalc.html.
The folder Data contains the raw data files used in the analysis, as
well as an Overview.xls file that contains the shift schedule of the
participants.
The folder Figures contains the figures generated by the code. They
are named after the figures in the manuscript.
The folder Results contains a csv file with the results of the power
analysis depending on sample size and metric. Running the script with
1000 resamples for sample sizes between 3 and 50 for 12 metrics takes
about 2-3 hours on an M1 Max MacbookPro (adding up to 576,000
resamples/tests). To reduce computation time, you can:
-
Uncomment line
717in the code, and comment out the rest of thestatisticschunk as well as thebootstrappingchunk -
reduce the number of bootstraps, e.g., by reducing
n_samplesfrom 1000 to 10. Or by reducing the range of sample sizes, e.g.,sample_size_maxfrom 50 to 25.
Most important parameters are found in the YAML:
---
#other YAML parts
...
params:
Power_level: 0.8
sign_level: 0.05
valid_data_threshold: 0.8
n_samples: 1000
sample_size_min: 3
sample_size_max: 50
seed: 20231212
---
These parameters control threshold values, the range of sample sizes,
the number of resources, and the seed for the random number generator.
Of further interest might be the Metrics chunk and section, where the
metrics are chosen and calculated.