View source: R/apply-barreira-algo.R
| apply_barreira_algo | R Documentation |
This function uses the Barreira algorithm (pubmed.ncbi.nlm.nih.gov/25202840) to classify an accelerometer axis vector of 60-second epochs as sleep time or awake time. This function was validated against output from the official SAS version of the algorithm (www.pbrc.edu/pdf/PBRCSleepEpisodeTimeMacroCode.pdf).
apply_barreira_algo(
x,
time_stamp = "dataTimestamp",
axis1 = "axis1",
incline_off = "inclineOff",
incline_standing = "inclineStanding",
incline_sitting = "inclineSitting",
incline_lying = "inclineLying",
age,
return = "everything"
)
x |
Required: a data frame of accelerometer data in 60-second epochs. |
time_stamp |
Required (default " |
axis1 |
Required (default: " |
incline_off |
Required (default: " |
incline_standing |
Required (default: " |
incline_sitting |
Required (default: " |
incline_lying |
Required (default: " |
age |
Required: a length-one integer vector representing the participant's age in years. This parameter is used to determine when the first sleep bout can begin. Statistics Canada sets the time to 18:00 for participants under five years and younger, and 19:00 for all other ages. |
return |
Required (default: " |
Returns the data frame x along with all vectors that were derived
while applying the Barreira algorithm.
# Initialize agd_worker R6 class
agd_data <- agd_worker$new(
id = "jane-canuck",
age = 10,
agd_lfe = system.file("extdata", "jane-canuck-lfe.agd", package = "chms"),
agd_nml = system.file("extdata", "jane-canuck-nml.agd", package = "chms"),
epoch_length = 15,
day_max = 3,
sleep_algo = "barreira",
non_wear_algo = "barreira"
)
# Load and clean data
agd_data$load()$clean()
# Apply Barreira sleep algorithm
dt <- apply_barreira_algo(
x = agd_data$data$clean |>
dplyr::filter(
epoch_length == 60,
filter == "LowFrequencyExtension"
),
age = agd_data$args$age
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.