Estimate Non-wear from Raw Accelerometry
Source:R/acti_calculate_wear_raw.R
acti_calculate_wear_raw.RdDetects non-wear from raw tri-axial acceleration. Unlike
acti_calculate_wear(), which works on 60-second activity counts, this
function takes the raw X, Y, Z signal (in g) as input. It calls
acti_calculate_wear_raw_ggir() or acti_calculate_wear_raw_actipy();
see those functions for the algorithms and their arguments. Neither GGIR
nor actipy is required.
Usage
acti_calculate_wear_raw(data, method = c("ggir", "actipy"), ...)Arguments
- data
A
data.frameof raw accelerometer data with a time column andX,Y,Zcolumns, or anAccDataobject. Data should be calibrated (e.g. withacti_calibrate()).- method
Method for detecting non-wear, either
"ggir"or"actipy", corresponding toacti_calculate_wear_raw_ggir()oracti_calculate_wear_raw_actipy().- ...
additional arguments to pass to the method function, such as
sample_rate,approach, orsd_thresholdfor"ggir", orwindow,patience, orsd_thresholdfor"actipy".
Value
A tibble with one row per epoch, containing at least time
(start of the epoch), nonwear, and wear. The epoch length and the
other columns depend on method.
Examples
n = 3 * 3600 * 10
time = as.POSIXct("2020-01-01 00:00:00", tz = "UTC") + (seq_len(n) - 1) / 10
moving = rep(c(TRUE, FALSE, TRUE), each = n / 3)
set.seed(1)
data = data.frame(
time = time,
X = ifelse(moving, stats::rnorm(n, sd = 0.3), 0),
Y = ifelse(moving, stats::rnorm(n, sd = 0.3), 0),
Z = ifelse(moving, stats::rnorm(n, sd = 0.3), 1)
)
ggir = acti_calculate_wear_raw(data, sample_rate = 10)
actipy = acti_calculate_wear_raw(data, method = "actipy", patience = 3000)