Skip to content

codoom1/wristsed

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

wristsed

wristsed provides analysis-ready NHANES 2011--2014 wrist accelerometer sedentary-time datasets. The package contains derived epoch-level and participant-level Parquet data products based on CHAP Wrist posture predictions combined with either SWaN sleep/wake/non-wear classifications or aligned NHANES minute-level sleep states.

The package is intended for researchers who want to analyze derived sedentary behavior summaries without rebuilding the full raw accelerometer processing pipeline.

Installation

Install the package from GitHub:

# install.packages("remotes")
remotes::install_github("codoom1/wristsed")

Load the package:

library(wristsed)

The package depends on arrow, dplyr, and utils. These dependencies are declared in the package DESCRIPTION file and are installed by standard R package installation tools.

Packaged data

wristsed includes epoch-level and participant-level sedentary-time datasets.

Level Sleep/wake method Epoch resolutions
Epoch swan 10m, 30m, 1h
Epoch nhanes 10m, 30m, 1h
Participant swan 1h
Participant nhanes 1h

The primary analysis dataset uses:

sleep_method = "swan"
epoch = "1h"

The sensitivity dataset uses:

sleep_method = "nhanes"

Sleep/wake methods:

  • swan: primary analysis dataset using CHAP Wrist posture predictions combined with SWaN sleep/wake/non-wear states.
  • nhanes: sensitivity dataset using CHAP Wrist posture summaries combined with aligned NHANES 1-minute sleep states.

Quick start

List packaged data products:

available_datasets()

Read the default 1-hour SWaN epoch-level dataset:

epoch_1h <- get_epoch_data()
head(epoch_1h)

Read participant-level summaries:

participant <- get_participant_data()
head(participant)

List participants available across both sleep/wake methods:

participants <- available_participants(sleep_method = "all")
head(participants)

Main functions

Function Purpose
available_datasets() Lists packaged data products.
available_participants() Lists participant IDs, NHANES cycle, sleep method, epoch level, and valid-day counts.
get_epoch_data() Reads repeated participant-day epoch summaries.
get_participant_data() Reads one-row-per-participant summaries.
data_dictionary() Returns packaged data dictionaries as R objects.
view_data_dictionary() Displays a packaged data dictionary in the console.

Reading data

Read the primary 1-hour epoch-level dataset:

epoch_1h <- get_epoch_data(
  epoch = "1h",
  sleep_method = "swan"
)

Read the primary participant-level dataset:

participant <- get_participant_data(
  sleep_method = "swan",
  epoch = "1h"
)

Read the NHANES sleep-state sensitivity dataset:

epoch_nhanes <- get_epoch_data(
  epoch = "1h",
  sleep_method = "nhanes"
)

Working with Arrow datasets

By default, the data accessors collect data into memory as a data frame. For larger workflows, set collect = FALSE to return an Arrow Dataset. This allows users to filter or select before collecting rows into memory.

library(dplyr)

epoch_ds <- get_epoch_data(
  epoch = "10m",
  sleep_method = "swan",
  collect = FALSE
)

morning_weekdays <- epoch_ds |>
  filter(DayType == "Weekday", epoch_start_minute < 12 * 60) |>
  select(ID, Dataset, Day, Epoch, percent_waking_sedentary) |>
  collect()

Key columns

Epoch-level datasets include:

  • ID, Dataset, Day, DayType, and Epoch
  • epoch_level, epoch_start_minute, and epoch_duration_minutes
  • sleep_method
  • percent_sedentary
  • percent_waking_sedentary
  • percent_sleep_nonwear
  • percent_wake
  • percent_missing_sleep
  • source_coverage

Participant-level datasets include:

  • ID, Dataset, sleep_method, and epoch_level
  • sleep_nonwear_cutoff
  • no_of_valid_days
  • est_sedentary_hours
  • est_waking_hours
  • est_sleep_nonwear_hours
  • within-participant SD and SE columns for daily estimates
  • NHANES survey variables: Exam_weight_recal, PSU, and Stratum

Use participant-level datasets for nationally representative participant-level analyses because NHANES survey weights are assigned to participants, not epochs.

Data dictionaries

Detailed data dictionaries are included with the package and can be accessed directly from R.

View the epoch-level dictionary in the console:

view_data_dictionary("epoch")

View the participant-level dictionary:

view_data_dictionary("participant")

Return both dictionaries as R objects:

dict <- data_dictionary("all")

Participant-level construction

Participant summaries are derived from the packaged 1-hour epoch data. For each sleep/wake method, a sleep/non-wear cutoff is selected from 50% to 100% in 0.01-point increments by matching estimated sleep/non-wear hours to weighted self-reported sleep. The selected cutoff is applied at the 1-hour epoch, and daily sedentary, waking, and sleep/non-wear hours are averaged across each participant's valid days.

Within-participant SD and SE columns are missing for participants with only one valid day because day-to-day variability cannot be estimated from a single observed day.

Citation

If you use wristsed, please cite the package, the accompanying manuscript, and the source methods for posture and sleep/non-wear classification.

In R, run:

citation("wristsed")

The package data product accompanies the manuscript:

Odoom C. Sedentary Behavior in the United States Measured by Accelerometer, NHANES 2011--2014. Manuscript in preparation. 2026.

The derived datasets build on NHANES wrist accelerometer data, CHAP posture classification methods, and SWaN sleep/wake/non-wear classification. Full citation details are available through citation("wristsed").

Relevant method DOIs:

License

This package is licensed under the Apache License 2.0. See the LICENSE file for details.

About

Epoch Level and Participant level datasets of estimates of daily sedentary time in the U.S

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages