Learn R Programming

arctools (version 1.1.4)

activity_stats: Compute physical activity summaries of minute level activity data

Description

Process minute level actigraphy-measured activity counts data and extract commonly used physical activity volume and fragmentation metrics.

Usage

activity_stats(
  acc,
  acc_ts,
  impute_missing = TRUE,
  sedentary_thresh = 1853,
  nonwear_0s_minimum_window = 90,
  validday_nonwear_maximum_window = 144,
  subset_minutes = NULL,
  exclude_minutes = NULL,
  subset_weekdays = NULL,
  in_bed_time = NULL,
  out_bed_time = NULL,
  adjust_out_colnames = TRUE
)

Arguments

acc

A numeric vector. A minute-level activity counts data vector.

acc_ts

A POSIXct vector. A minute-level time of acc data collection. We strongly recommended to use lubridate::ymd_hms() function to create acc_ts (see Examples below).

impute_missing

A logical scalar. Whether or not to perform missing data imputation (see Details). Default is TRUE.

sedentary_thresh

A numeric scalar. If an activity count value falls below it then a corresponding minute is characterized as sedentary; otherwise, a corresponding minute is characterized as active. Default is 1853.

nonwear_0s_minimum_window

A numeric scalar. A minimum number of consecutive minutes with 0 activity count to be considered non-wear.

validday_nonwear_maximum_window

In integer scalar. Maximum number of minutes of non-wear/not collecting data so as the day is still considered valid. Default is 144 (10% of 1440 minutes of a full day).

subset_minutes

Integer vector. Contains subset of a day's minutes within which activity summaries are to be computed. May take values from 1 (day's minute from 00:00 to 00:01) to 1440 (day's minute from 23:59 to 00:00). Default is NULL, i.e. no subset used (all day's minutes are used).

exclude_minutes

Integer vector. Contains subset of a day's minutes to be excluded from activity summaries computation. May take values from 1 (day's minute from 00:00 to 00:01) to 1440 (day's minute from 23:59 to 00:00). Default is NULL, i.e. no minutes excluded (all day's minutes are used).

subset_weekdays

Integer vector. Specfies days of a week within which activity summaries are to be computed. Takes values between 1 (Sunday) to 7 (Saturday). Default is NULL, i.e.no subset used (all days of a week are used).

in_bed_time

A POSIXct vector. An estimated in-bed time start. Together with a corresponding entry from out_bed_time vector, it defines a day-specific subset of "in bed time" minutes to be excluded from activity summaries computation. Default is NULL, i.e. no minutes excluded.

out_bed_time

A POSIXct vector. An estimated in-bed time end. Together with a corresponding entry from in_bed_time vector, it defines a day-specific subset of "in bed time" minutes to be excluded from activity summaries computation. Default is NULL, i.e. no minutes excluded.

adjust_out_colnames

A logical scalar. Whether or not to add an informative suffix to column names in the output data frame. This may happen in case any of the arguments: subset_minutes, or exclude_minutes, or in_bed_time and out_bed_time are set other than NULL. Default is TRUE.

Value

A data frame with physical activity summaries of minute level activity data. See README or vignette for summaries description.

Details

Physical activity statistics are aggregated from "valid" days, i.e. days with no more than 10 wear/non-wear detection algorithm closely following that of Choi et al. (2011). See arctools::get_wear_flag() for details.

Data imputation is recommended for valid days for non-wear time periods and is a default setting (see impute_missing arg). Count values are imputed from an "average day profile" -- a minute-specific activity counts average computed across valid days within wear time.

References

Varma, V. R., Dey, D., Leroux, A., Di, J., Urbanek, J., Xiao, L., Zipunnikov, V. (2018). Total volume of physical activity: TAC, TLAC or TAC(lambda). Preventive medicine, 106, 233<U+2013>235. https://doi.org/10.1016/j.ypmed.2017.10.028

Di, J., Leroux, A., Urbanek, J., Varadhan, R., Spira, A., Schrack, J., Zipunnikov, V. Patterns of sedentary and active time accumulation are associated with mortality in US adults: The NHANES study. https://doi.org/10.1101/182337

Choi, L., Liu, Z., Matthews, C. E., & Buchowski, M. S. (2011). Validation of accelerometer wear and nonwear time classification algorithm. Medicine and Science in Sports and Exercise. https://doi.org/10.1249/MSS.0b013e3181ed61a3

Koster, A., Shiroma, E. J., Caserotti, P., Matthews, C. E., Chen, K. Y., Glynn, N. W., & Harris, T. B. (2016). Comparison of Sedentary Estimates between activPAL and Hip- and Wrist-Worn ActiGraph. Medicine and science in sports and exercise, 48(8), 1514<U+2013>1522. https://doi.org/10.1249/MSS.0000000000000924

Examples

Run this code
# NOT RUN {
fpath_i <- system.file("extdata", extdata_fnames[1], package = "arctools")
dat_i   <- as.data.frame(data.table::fread(fpath_i))
acc     <- dat_i$vectormagnitude
acc_ts  <- lubridate::ymd_hms(dat_i$timestamp)

## Example 1
## Summarize PA
activity_stats(acc, acc_ts)

## Example 2
## Summarize PA within minutes range corresponding to 12:00 AM - 6:00 AM
subset_12am_6am <- 1 : (6 * 1440/24)
activity_stats(acc, acc_ts, subset_minutes = subset_12am_6am)

## Example 3
## Summarize PA without (i.e., excluding) minutes range corresponding to 11:00 PM - 5:00 AM.
subset_11pm_5am <- c(
  (23 * 1440/24 + 1) : 1440,   ## 11:00 PM - midnight
  1 : (5 * 1440/24)            ## midnight - 5:00 AM
)
activity_stats(acc, acc_ts, exclude_minutes = subset_11pm_5am)

# }

Run the code above in your browser using DataLab