Description Usage Arguments Value Examples
View source: R/reweight_nhanes.R
Calculates adjusted Mobile Exam Center (MEC) weights for the subsample of
NHANES 2003-2004 and 2005-2006 participants with valid accelerometer data,
making the subsample nationally representative. This function is used
internally by process_nhanes
, but could also be used
independently.
1 2 3 4 5 6 | reweight_nhanes(
accel_data,
wave,
seqn_column = "seqn",
include_column = "include"
)
|
accel_data |
Numeric matrix or data frame with one row per participant. It can have any number of columns but one must have respondent sequence numbers (NHANES ID variable "seqn") and another must indicate whether each participant has valid data (1 if valid, 0 if not valid). |
wave |
Integer value specifying NHANES wave. Choices are 1 for NHANES 2003-2004 and 2 for NHANES 2005-2006. |
seqn_column |
Column number (or name) for respondent sequence numbers (NHANES ID variable "SEQN"). |
include_column |
Column number (or name) for 0/1 indicator for which participants to include. |
Numeric matrix identical to accel_data
, but with extra
wtmec2yr_adj
column.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | # Process NHANES 2003-2004 data using default settings
nhanes0304 <- process_nhanes(waves = 1)
# Create new 'include' variable: 1 if >= 4 valid days, otherwise 0
nhanes0304$include2 <- ifelse(nhanes0304$valid_days >= 4, 1, 0)
# Rename previous 2-year weight variable so new one doesn't overwrite it
names(nhanes0304)[10] = "wtmec2yr_adj_old"
# Calculate new 2-year weights for subset with >= 4 valid days
nhanes0304 <- reweight_nhanes(accel_data = nhanes0304, wave = 1)
# Notice that 'wtmec2yr_adj' differ from 'wtmec2yr_adj_old', and that
# participants with 1-3 valid days are now assigned zero weight
nhanes0304[1: 10, ]
# This is just an example. In practice, it would be easier to just add
# `valid.days = 4' to the initial process_nhanes function call above.
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.