Associations between early-life mental health and abnormal sleep duration in midlife: findings from a prospective cohort study in Great Britain
This repository contains the supplementary data for the paper "Associations between early-life mental health and abnormal sleep duration in midlife: findings from a prospective cohort study in Great Britain" (preprint available at https://doi.org/10.1101/2023.12.13.23299897).
Please review the licensing information at LICENCE.md
and THIRDPARTY.md
before reusing any software in this repository.
There are a number of steps to the analysis. The underlying raw data are available free of charge as follows:
- Main survey data: via the UK Data Service.
- CLOSER harmonised variables: via the UK Data Service.
- Raw sleep diary, accelerometry data and derived sleep variables: by application to the Centre for Longitudinal Studies.
Check the code for the file structure used to store the raw data, or you can store the data elsewhere and change the filepaths present in the code.
These R markdown (.Rmd
) scripts were rendered separately and do not use the renv
environment present in the repository. Use R
version 4.2.0.
These steps use the targets
framework and renv
environment present in the repository. After producing or acquiring the derived sleep estimates, you can run these steps by running targets::tar_make()
in R
4.2.0 inside the repository. The mice_report
and models_report
Quarto files are rendered automatically as part of the {targets}
pipeline, and the output .html
files are also provided in the repository.
Because of technological limitations, the plots must be rendered separately after the completion of the cleaning and analysis steps by rendering the Quarto file 4_plots.Qmd
. Use R
version 4.2.0 and the renv
environment present in the repository. The output .html
file and the plot .svg
and .png
files are also provided in the repository.
The data tables listed in the supplementary information can be accessed by rendering the Quarto file 5_supplementary_info.Qmd
. Use R
version 4.2.0 and the renv
environment present in the repository. The output .html
file is also provided in the repository.
Once you have completed step 3, you can access all raw model outputs, intermediate datasets and summaries using the targets::tar_read()
function. For more details, see the {targets}
package documentation.