The repository includes a set of functions based on the R environment that implement the analytical steps described in the article:
Menghini, L., Cellini, N., Goldstone, A., Baker, F. C., & de Zambotti, M. (2021). A standardized framework for testing the performance of sleep-tracking technology: step-by-step guidelines and open-source code. Sleep, 44(2), zsaa170. https://dx.doi.org/10.1093%2Fsleep%2Fzsaa170
The analytical pipeline for applying the functions to a dataset is depicted at this page.
To use the functions, it is required to (1) download and install R, (2) prepare a dataset of epoch-by-epoch data (as described in the article, and (3) load both the dataset and the functions in R.
- To read a dataset, functions such as
read.csv()
can be used depending on the file format (type?read.csv()
in R for details). The commandread.csv(file.choose())
allows to open a dialog box presented to the user to browse the file in the computer. - To read the functions, the files should be downloaded from the
Functions
folder in this repository, and pasted in the directory folder used by R (the commandgetwd()
in R allows to visualize the current directory). The commandsource("function_name.R")
allows to read the function file. The commandsource(file.choose())
allows to open a dialog box presented to the user to browse the file in the computer. - The first time that a function is used, it automatically installs all the required packages (might take a while). Alternatively, R packages can be installed using the command
install.packages("package_name")
.
The following functions are included:
ebe2sleep.R
uses the epoch-by-epoch dataset to generate a dataset of sleep measuresindDiscr.R
uses the dataset generated byebe2sleep.R
to generate a dataset individual-level discrepanciesgroupDiscr.R
uses the dataset generated withebe2sleep.R
to compute gorup-level discrepancy metricsBAplot.R
uses the dataset generated withebe2sleep.R
to generate a Bland-Altman plot for a specific measureerrorMatrix.R
uses the epoch-by-epoch dataset to compute an error matrixindEBE.R
uses the epoch-by-epoch dataset to compute epoch-by-epoch performance metrics for each subjectgroupEBE.R
uses the epoch-by-epoch dataset to compute epoch-by-epoch performance metrics for the whole sample
- Sept 8th 2023: Spotted and corrected errors in the computation of prevalence, PPV, and NPV within the
groupEBE
function. We thank @selectwait and Dr. Satomi Okabe for spotting the errors.