| Title: | Map Quantiles for Physical Activity from 'NHANES' |
| Version: | 0.1.0 |
| Description: | Maps physical activity from the National Health and Nutrition Examination Survey ('NHANES') study into population-based quantiles. |
| License: | MIT + file LICENSE |
| Encoding: | UTF-8 |
| Depends: | R (≥ 3.5) |
| LazyData: | true |
| LazyDataCompression: | xz |
| URL: | https://github.com/jhuwit/mapnhanespa |
| BugReports: | https://github.com/jhuwit/mapnhanespa/issues |
| Suggests: | knitr, rmarkdown, testthat (≥ 3.0.0) |
| Config/testthat/edition: | 3 |
| VignetteBuilder: | knitr |
| Imports: | dplyr, magrittr, purrr, survey |
| Config/roxygen2/version: | 8.0.0 |
| NeedsCompilation: | no |
| Packaged: | 2026-05-29 16:31:16 UTC; johnmuschelli |
| Author: | John Muschelli |
| Maintainer: | John Muschelli <muschellij2@gmail.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-06-02 11:10:08 UTC |
Pipe operator
Description
See magrittr::%>% for details.
Usage
lhs %>% rhs
Map physical activity values to NHANES population quantiles
Description
map_nhanes_pa_quantiles() adds a population-level quantile column to a
participant-level data frame. Quantiles are evaluated from NHANES
accelerometer cumulative distribution functions stratified by age category,
sex/gender, measure, and optionally survey wave.
Usage
map_nhanes_pa_quantiles(
data,
id = NULL,
age = "age",
sex = "sex",
measure = "measure",
value = "value",
wave = NULL,
age_category = NULL,
quantile_col = "nhanes_quantile"
)
Arguments
data |
A data frame with one row per participant-measure observation. |
id |
Optional participant identifier column name. The column is checked when supplied, but otherwise left unchanged. |
age, sex, measure, value |
Column names in |
wave |
Optional NHANES wave column name or scalar value. Supported values
are |
age_category |
Optional column name containing NHANES age categories
such as |
quantile_col |
Name of the output quantile column. |
Value
data with an added quantile column.
Examples
example_data <- data.frame(
id = 1:2,
age = c(25, 62),
sex = c("Female", "Male"),
measure = c("mims", "ssl_steps"),
value = c(15000, 7500)
)
map_nhanes_pa_quantiles(example_data)
map_nhanes_pa_quantiles(example_data, sex = NULL)
map_nhanes_pa_quantiles(example_data, age = NULL, wave = "2011-2012")
map_nhanes_pa_quantiles(example_data, age = NULL, sex = NULL)
NHANES PA data
Description
NHANES PA data
Usage
nhanes_measure_data
Format
A data frame with 87619 rows and 9 variables:
- SEQN
ID variable
- data_release_cycle
wave/data release cycle
- cat_age
age category
- gender
sex/gender designation
- wtmec4yr_adj_norm
normalized weight for surveys
- masked_variance_pseudo_psu
PSU - sampling unit
- masked_variance_pseudo_stratum
sampling stratum
- num_valid_days
number of valid days of wear >= 1396 minutes
- measure
measure that was calculated
- value
value for the measure
Source
NHANES 2011-2012 and 2013-2014 accelerometer data.
Convert ages to NHANES physical activity CDF age categories
Description
Ages are grouped into 10-year bins from [0,10) through [70,80). Ages
greater than or equal to 80 are assigned to the oldest available CDF
category, "[80,85)". Ages greater than 85 also map to "[80,85)", with a
warning by default.
Usage
nhanes_pa_age_category(age, warn = TRUE)
Arguments
age |
Numeric age in years. |
warn |
Logical. If |
Value
A character vector of NHANES age category labels.
Examples
nhanes_pa_age_category(c(8, 25, 84, 90))
Evaluate a single NHANES physical activity quantile
Description
Evaluate a single NHANES physical activity quantile
Usage
nhanes_pa_quantile(
value,
age = NULL,
sex = NULL,
measure,
wave = NULL,
age_category = NULL
)
Arguments
value |
Observed physical activity value. |
age |
Age in years. Set to |
sex |
Sex/gender. Common values such as |
measure |
Physical activity measure. Supported aliases include
|
wave |
Optional NHANES wave. Supported values are |
age_category |
Optional NHANES age category such as |
Value
A numeric quantile in [0, 1], or NA_real_ when no matching CDF is
available.
Examples
nhanes_pa_quantile(
value = 15000,
age = 25,
sex = "Female",
measure = "mims"
)
nhanes_pa_quantile(
value = 15000,
age = 25,
sex = NULL,
measure = "mims",
wave = "2013-2014"
)
Precompute and cache NHANES PA CDFs
Description
Builds every supported CDF combination and stores the result in the internal cache. This covers combined and by-wave CDFs, age-specific and age-overall strata, sex/gender-specific and sex/gender-overall strata, and the overall-overall combination for each supported measure.
Usage
precompute_nhanes_pa_cdfs()
Value
Invisibly returns a list with the cached combined and by-wave tables.