Age-adjusted estimates"

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

Age adjustment is useful when comparing estimates across groups whose age distributions differ. In surveytable, age adjustment is turned on when the survey is specified with set_survey(). The tabulation commands are otherwise the same commands used for crude estimates.

This example uses selected variables from the National Health Interview Survey (NHIS) 2024 Public Use File. The standard population is represented by uspop_example$age_group_std.

Crude estimates

First, calculate ordinary crude estimates. These estimates reflect the age distribution in the survey population.

library(surveytable)

set_survey(nhis2024a)
set_opts(mode = "nchs", adj = "nhis")

tab("dis3_indicator")
tab("alot_diff")

The same setup works for subgroups. For example, estimate each outcome by sex:

tab_subset("dis3_indicator", "sex_a")
tab_subset("alot_diff", "sex_a")

The age distribution itself can also be tabulated:

tab("age_group_std")

Age-adjusted estimates

To produce age-adjusted estimates, call set_survey() with two additional arguments:

The Level values in aa_pop must exactly match the levels of aa_vr.

uspop_example$age_group_std
set_survey(
  nhis2024a
  , aa_vr = "age_group_std"
  , aa_pop = uspop_example$age_group_std
)
set_opts(mode = "nchs", adj = "nhis")

Now use the same tabulation commands. The table titles indicate that the estimates are age-adjusted.

tab("dis3_indicator")
tab("alot_diff")
tab_subset("dis3_indicator", "sex_a")
tab_subset("alot_diff", "sex_a")

As a diagnostic, tabulating the age-adjustment variable should reproduce the standard age distribution. The percentage standard errors are expected to be zero, because the age distribution has been fixed to the standard population.

tab("age_group_std")

Counts or proportions

The Population column in aa_pop can contain population counts or proportions. Values are normalized internally, so counts and proportions that describe the same standard population produce the same age-adjusted estimates.

uspop_example$age_group_std_prop
set_survey(
  nhis2024a
  , aa_vr = "age_group_std"
  , aa_pop = uspop_example$age_group_std_prop
)
set_opts(mode = "nchs", adj = "nhis")

tab("dis3_indicator")


Try the surveytable package in your browser

Any scripts or data that you put into this service are public.

surveytable documentation built on Aug. 20, 2026, 1:08 a.m.