wearingMarking: Classify Wear and Nonwear Time for Accelerometer Data

Description Usage Arguments Details Value Note Author(s) References See Also Examples

View source: R/wearingMarking.R

Description

This function classifies wear and nonwear time status for accelerometer data by epoch-by-epoch basis.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
wearingMarking(
  dataset,
  frame = 90,
  perMinuteCts = 60,
  TS = getOption("pa.timeStamp"),
  cts = getOption("pa.cts"),
  streamFrame = NULL,
  allowanceFrame = 2,
  newcolname = "wearing",
  getMinuteMarking = FALSE,
  dayStart = "00:00:00",
  tz = "UTC",
  ...
)

Arguments

dataset

The source dataset, in dataframe format, which needs to be marked.

frame

The size of time interval to be considered; Window 1 described in Choi et al. (2011). The default is 90.

perMinuteCts

The number of data rows per minute. The default is 1-sec epoch (perMinuteCts = 60). For examples: for data with 10-sec epoch, set perMinuteCts = 6; for data with 1-min epoch, set perMinuteCts = 1.

TS

The column name for timestamp. The default is “TimeStamp”.

cts

The column name for counts. The default is “axis1”.

streamFrame

The size of time interval that the program will look back or forward if activity is detected; Window 2 described in Choi et al. (2011). The default is the half of the frame.

allowanceFrame

The size of time interval that zero counts are allowed; the artifactual movement interval described in Choi et al. (2011). The default is 2.

newcolname

The column name for classified wear and nonwear status. The default is “wearing”. After the data is processed, a new field will be added to the original dataframe. This new field is an indicator for the wearing (“w”) or nowwearing (“nw”).

getMinuteMarking

Return minute data with wear and nonwear classification. If the source is not a minute dataset, the function will collapse it into minute data. The default is FALSE.

dayStart

Define the starting time of day. The default is the midnight, "00:00:00". It must be in the format of "hh:mm:ss".

tz

Local time zone, defaults to UTC.

...

Parameter settings that will be used in dataCollapser function.

Details

A detailed description of the algorithm implemented in this function is described in Choi et al. (2011).

Value

A data frame with the column for wear and nonwear classification indicator by epoch-by-epoch basis.

Note

Warning: It will be very slow if accelerometer data with 1-sec epoch for many days are directly classified. We recommend to collapse a dataset with 1-sec epoch to 1-min epoch data using dataCollapser and then classify wear and nonwear status using a dataset with a larger epoch.

Author(s)

Leena Choi leena.choi@Vanderbilt.Edu, Cole Beck cole.beck@vumc.org, Zhouwen Liu zhouwen.liu@vumc.org, Charles E. Matthews Charles.Matthews2@nih.gov, and Maciej S. Buchowski maciej.buchowski@Vanderbilt.Edu

References

Choi L, Liu Z, Matthews CE, Buchowski MS. Validation of accelerometer wear and nonwear time classification algorithm. Med Sci Sports Exerc. 2011 Feb;43(2):357-64.

See Also

readCountsData, sumVct

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
data(dataSec)

## mark data with 1-min epoch
mydata1m = dataCollapser(dataSec, TS = "TimeStamp", col = "counts", by = 60)

data1m = wearingMarking(dataset = mydata1m,
                       frame = 90, 
                       perMinuteCts = 1,
                       TS = "TimeStamp",
                       cts = "counts", 
                       streamFrame = NULL, 
                       allowanceFrame= 2, 
                       newcolname = "wearing")

sumVct(data1m, id="dataid")

## mark data with 1-sec epoch
## Not run: 
data1s = wearingMarking(dataset = dataSec,
                       frame = 90, 
                       perMinuteCts = 60,
                       TS = "TimeStamp",
                       cts = "counts", 
                       streamFrame = NULL, 
                       allowanceFrame= 2, 
                       newcolname = "wearing",
                       getMinuteMarking = FALSE)

sumVct(data1s, id="dataid")
sumVct(data1s, id="dataid", markingString = "nw")

## End(Not run)

Example output

frame is  90 
streamFrame is  
allowanceFrame is  2 
      id      startTimeStamp        endTimeStamp days   weekday start  end
1 dataid 2007-08-01 07:01:00 2007-08-01 23:59:00    1 Wednesday     1 1019
2 dataid 2007-08-02 00:00:00 2007-08-02 23:59:00    2  Thursday  1020 2459
3 dataid 2007-08-03 00:00:00 2007-08-03 01:04:00    3    Friday  2460 2524
4 dataid 2007-08-03 05:52:00 2007-08-03 23:59:00    3    Friday  2812 3899
5 dataid 2007-08-04 00:00:00 2007-08-04 01:09:00    4  Saturday  3900 3969
  duration
1     1019
2     1440
3       65
4     1088
5       70
frame is  90 
streamFrame is  
allowanceFrame is  2 
      id      startTimeStamp        endTimeStamp days   weekday  start    end
1 dataid 2007-08-01 07:01:00 2007-08-01 23:59:59    1 Wednesday      1  61140
2 dataid 2007-08-02 00:00:00 2007-08-02 23:59:59    2  Thursday  61141 147540
3 dataid 2007-08-03 00:00:00 2007-08-03 01:04:59    3    Friday 147541 151440
4 dataid 2007-08-03 05:52:00 2007-08-03 23:59:59    3    Friday 168661 233940
5 dataid 2007-08-04 00:00:00 2007-08-04 01:09:59    4  Saturday 233941 238140
  duration
1    61140
2    86400
3     3900
4    65280
5     4200
      id      startTimeStamp        endTimeStamp days weekday  start    end
1 dataid 2007-08-03 01:05:00 2007-08-03 05:51:59    3  Friday 151441 168660
  duration
1    17220

PhysicalActivity documentation built on Jan. 23, 2021, 1:06 a.m.