Skip to contents

When estimating the count of US adults using a subset of NHANES participants, it may be helpful to re-calibrate the survey weights in the subset so that the sum of the calibrated weights match the sum of the weights in the full NHANES data

Usage

nhanes_calibrate(
  nhanes_sub,
  nhanes_full,
  calib_by = c("svy_year", "demo_age_cat", "demo_gender", "demo_race_black")
)

Arguments

nhanes_sub

[data.table]

The subsetted NHANES data.

nhanes_full

[data.table]

The full NHANES data

calib_by

[character(1+)]

The variables that are used to create groups wherein calibration occurs. For example, the default calib_by = c('svy_year', 'demo_age_cat', 'demo_gender', 'demo_race_black') means that weights within subgroups defined by NHANES cycle, age, sex, and race categories will be calibrated in the subsetted data to match the corresponding group's sum in the full data.

Value

a data.table

Details

the default for calib_by uses a race variable with fewer categories than demo_race (the variable used in analyses). This is done because some of the groups formed when demo_race is used are too small to ensure that the sum of the calirbated weights matches (or is very close to matching) the sum of the weights in the original NHANES data.

Examples


# here we calibrate the hypertension sub-population

nhanes_sub <- nhanes_data[svy_subpop_htn == 1]
nhanes_htn <- nhanes_calibrate(nhanes_full = nhanes_data,
                               nhanes_sub = nhanes_sub)

# the un-calibrated weights do not match the size of the NHANES population
sum(nhanes_sub$svy_weight_mec)
#> [1] 2129039733
# but the calibrated weights do
sum(nhanes_htn$svy_weight_cal)
#> [1] 2244544303
sum(nhanes_data$svy_weight_mec)
#> [1] 2244544303