collapse_epochs: Re-integrate epochs

View source: R/collapse_epochs.R

collapse_epochsR Documentation

Re-integrate epochs

Description

Collapse post-filtered activity counts into larger epoch "buckets".

Usage

collapse_epochs(agdb, epoch_len_out, use_incomplete = TRUE)

Arguments

agdb

A tibble of activity data with an epochlength attribute.

epoch_len_out

Output (longer) epoch length in seconds, must be exact multiple of the input epoch length. Currently only epoch_len_out = 60 is supported.

use_incomplete

logical. Set to TRUE to follow ActiLife convention, which collapses all observed epochs even if they are incomplete.

Details

Activity counts cannot be reintegrated into shorter epochs, e.g., 60s -> 10s. Currently, collapse_epochs() integrates into 60s epochs only. This is not general but is sufficient for sleep analysis because the standard Sadeh and Cole-Kripke sleep algorithms were developed for 60s epoch data.

Suppose we want to collapse from 15 to 60 seconds. A complete 60s epoch consists of four 15s epochs: 00, 15, 45 and 60. However, the first and last epochs would be incomplete if the device started/stopped collecting data mid-minute. ActiLife 6 uses these epochs anyway. For example, if only 45 and 60 are available for the first minute, then ActiLife will aggregate across these two epochs only. This is a reasonable approach to sleep analysis with the Sadeh and the Cole-Kripke algorithms which pad the beginning and the end of the time series with zeros anyway.

Value

A tibble of activity data collapsed into one-minute epochs.

References

ActiLife 6 User's Manual by the ActiGraph Software Department. 04/03/2012.

Examples

library("dplyr")
data("gtxplus1day")

gtxplus1day %>%
  collapse_epochs(60)

dipetkov/actigraph.sleepr documentation built on March 25, 2022, 2:33 a.m.