| Title: | Map Quantiles for Physical Activity from 'NHANES' |
|---|---|
| Description: | Maps physical activity from the National Health and Nutrition Examination Survey ('NHANES') study into population-based quantiles. |
| Authors: | John Muschelli [aut, cre] (ORCID: <https://orcid.org/0000-0001-6469-1750>) |
| Maintainer: | John Muschelli <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0 |
| Built: | 2026-06-02 19:00:48 UTC |
| Source: | https://github.com/cran/mapnhanespa |
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.
map_nhanes_pa_quantiles( data, id = NULL, age = "age", sex = "sex", measure = "measure", value = "value", wave = NULL, age_category = NULL, quantile_col = "nhanes_quantile" )map_nhanes_pa_quantiles( data, id = NULL, age = "age", sex = "sex", measure = "measure", value = "value", wave = NULL, age_category = NULL, quantile_col = "nhanes_quantile" )
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. |
data with an added quantile column.
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)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
nhanes_measure_datanhanes_measure_data
A data frame with 87619 rows and 9 variables:
ID variable
wave/data release cycle
age category
sex/gender designation
normalized weight for surveys
PSU - sampling unit
sampling stratum
number of valid days of wear >= 1396 minutes
measure that was calculated
value for the measure
NHANES 2011-2012 and 2013-2014 accelerometer data.
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.
nhanes_pa_age_category(age, warn = TRUE)nhanes_pa_age_category(age, warn = TRUE)
age |
Numeric age in years. |
warn |
Logical. If |
A character vector of NHANES age category labels.
nhanes_pa_age_category(c(8, 25, 84, 90))nhanes_pa_age_category(c(8, 25, 84, 90))
Evaluate a single NHANES physical activity quantile
nhanes_pa_quantile( value, age = NULL, sex = NULL, measure, wave = NULL, age_category = NULL )nhanes_pa_quantile( value, age = NULL, sex = NULL, measure, wave = NULL, age_category = NULL )
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 |
A numeric quantile in [0, 1], or NA_real_ when no matching CDF is
available.
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" )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" )
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.
precompute_nhanes_pa_cdfs()precompute_nhanes_pa_cdfs()
Invisibly returns a list with the cached combined and by-wave tables.