R/process_accel.R
process_flags.Rd
This function creates wear/non-wear flag matrices for processed NHANES 2003-2004 and 2005-2006 accelerometry data.
The underlying algorithm for estimating wear/non-wear flags is implemented in the weartime
function from the accelerometry package.
process_flags( x, days_distinct = FALSE, window = 90L, tol = 2L, tol_upper = 99L, ... )
x | A list with each element corresponding to a data matrix of activity counts in the 1440+ format with 7 rows per individual. Each element of x should be named, and each
name should correspond to the naming convention used by the output of |
---|---|
days_distinct | Logical value indicating whether days should be treated as distinct time series within participants. If TRUE, then subjects' wear status at 11:59PM does not affect their wear status at 00:01AM the next morning. Defaults to FALSE, this is generally recommended. |
window | Numeric value indicated the size of the moving window used to assess non-wear in minutes. Defaults to 90 minutes.
See |
tol | maximum number of minutes with counts greater than 0 within the a non-wear interval.
See |
tol_upper | maximium activity count for any minute within the window
Defaults to 99. That is, for a given minute, if the window contains any minutes with
activity counts greater than tol.upper, this minute is considered "wear".
See |
... | aditional arguments to be passed to |
The function process_flags returns a list with number of elemnts equal to the number of elements in the object supplied to the "x" argument.
Each element of the list returned is a dataframe that mirrors the format of dataframes returned from the process_accel
function, but instead
with the columns conveying activity count data replaced with 0/1 indicators for estimated periods of non-wear.
More specifically, each element is a data frame with the following columns
SEQN: Unique subject identifier
PAXCAL: Device calibration. Was the device calibrated when it was returned by the participant? 1 = Yes, 2 = No, 9 = Don't Know. Any individuals with either 2 or 9 in this variable should be examined carefully before being included in any analysis.
PAXSTAT: Data reliability status flag. 1 = Data deemed reliable, 2 = Data reliability is questioable. Any individuals with 2 in this variable should be examined carefully before being included in any analysis.
SDDSRVYR: Variable indicating which wave of the NHANES study this data is associated with. For example, SDDSRVYR = 3 corresponds to the 2003-2004 wave and SDDSRVYR = 4 corresponds to the 2005-2006 wave.
WEEKDAY: Day of the week: 1 = Sunday, 2 = Monday, 3 = Tuesday, 4 = Wednesday, 5 = Thursday, 6 = Friday, 7 = Saturday.
MIN1-MIN1440: Wear/Non-wear flag corresponding to each minute of the day. These columns can take on the following 3 values
0: A value of 0 indicates that a particular minute is determined to be "non-wear"
1: A value of 1 indicated that a particular minute is determined to be "wear"
NA: A value of NA indicates that a particular minute was missing data in the activity count data matrix used to create this set of wear/non-wear flags
There are many way to estimate non-wear periods in accelerometry data. Fundamentally, they all involve finding extended periods of implausibly low activity.
However, there is no one perfect algorithm, and what qualifies as "implausible" is device-, placement-, and population-dependent. Here, we use the algorithm
implemented by default in the accelerometry
package via the weartime
function. This algorithm is
similar to the algorithm used in Troiano et. al (2008).
There are a number of parameters the algirothm implemented in weartime
uses to control how aggressive non-wear time identification is.
By making the algorithm more agressive (decreasing window size, increasing tolerance for non-zero activity counts), one increases the likelihood of false positives.
Conversely, making the algorithm less agressive increases the likelihood of false negatives. By default we use a fairly conservative window size of 90 minutes.
Choi, Leena et al. “Validation of Accelerometer Wear and Nonwear Time Classification Algorithm.” Medicine and science in sports and exercise 43.2 (2011): 357–364. PMC. Web. 10 Oct. 2018.
National Cancer Institute. Risk factor monitoring and methods: SAS programs for analyzing NHANES 2003-2004 accelerometer data. Available at: http://riskfactor.cancer.gov/tools/nhanes_pam. Accessed Oct. 10, 2018.
Troiano RP, Berrigan D, Dodd KW, Masse LC, Tilert T, Mcdowell M: Physical activity in the United States measured by accelerometer. Med Sci Sports Exerc 2008; 40: 181-188.
if (FALSE) { library("rnhanesdata") ## In the interest of reducing computation time for this example, ## we use the already processed accelerometry data accel_ls <- list("PAXINTEN_C" = PAXINTEN_C, "PAXINTEN_D" = PAXINTEN_D) flags_ls <- process_flags(x=accel_ls) ## Check to see that these processed flags are identical to ## those provided in the package identical(flags_ls$Flags_C, Flags_C) identical(flags_ls$Flags_D, Flags_D) }