View source: R/apply-tudor-locke-algo.R
| apply_tudor_locke_algo | R Documentation |
This function uses the Tudor-Locke algorithm (https://pubmed.ncbi.nlm.nih.gov/24383507) to classify an accelerometer axis vector of 60-second epochs as sleep time or awake time. This function was validated indirectly against output from the official SAS version of the Barreira algorithm (www.pbrc.edu/pdf/PBRCSleepEpisodeTimeMacroCode.pdf).
apply_tudor_locke_algo(
x,
time_stamp = "dataTimestamp",
axis1 = "axis1",
incline_off = "inclineOff",
incline_standing = "inclineStanding",
incline_sitting = "inclineSitting",
incline_lying = "inclineLying",
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: |
return |
Required (default: |
Returns x along with all vectors that were derived while applying
the Tudor-Locke 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 Tudor-Locke sleep algorithm
dt <- apply_tudor_locke_algo(
x = agd_data$data$clean |>
dplyr::filter(
epoch_length == 60,
filter == "LowFrequencyExtension"
)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.