pool_brfss_weights | R Documentation |
Creates a dtsurvey
/data.table object with properly adjusted
survey weights for analyzing Behavioral Risk Factor
Surveillance System (BRFSS) data across multiple years. The built-in BRFSS
survey weight (finalwt1
for King County data and x_llcpwt
for WA
State data) is designed for single-year analyses. When
analyzing BRFSS data across multiple years, the survey weights must be
proportionately down scaled. This function provides three weight adjustment
methods.
pool_brfss_weights(
ph.data,
years,
year_var = "chi_year",
old_wt_var = "finalwt1",
new_wt_var,
wt_method = "obs",
strata = "x_ststr"
)
ph.data |
A |
years |
An integer vector specifying which years to include in the weight calculation |
year_var |
Character string specifying the name of the column containing
year values. Defaults to ' |
old_wt_var |
Character string specifying the name of the column
containing the single year survey weights. Defaults to ' |
new_wt_var |
Character string specifying the name for the new weight variable to be created |
wt_method |
Character string specifying the name of the method used
to rescale
Defaults to ' |
strata |
Character string specifying the name for the strata to be used
when survey setting the data. Defaults to ' |
When analyzing multiple years of BRFSS data together, using the original weights would lead to overestimation of population totals, as each year's weights sum to that year's total survey population. This function down scales the weights proportionately within the specified time period(s), ensuring that estimates approximate an average year's population.
Note that while get_data_brfss
automatically creates multi-year
weights during the initial data download, you may need to use this function
to create new weights when analyzing specific subsets of years. For example,
some BRFSS questions are only asked in specific years, requiring custom weights
to be calculated for those specific time periods. The original weight
will always be saved in order to allow this function to be
used repeatedly on the same data set.
When aggregating BRFSS data across years, WA DOH recommends including the
survey year as an additional stratifying variable. However, the ETL process
includes the survey year in 'x_ststr
' (
d1$x_ststr <- d1$year * 1000000 + d1$x_ststr
) so there is no need to
include the survey year on its own.
For data.frame/data.table input: Returns a survey-weighted
dtsurvey
/data.table with
an additional column containing the new adjusted weights.
For imputationList
input: Returns a new imputationList
where each dtsurvey
/data.table is
survey-weighted using the new weights.
In both cases, the new weight column will be specified by the value of
new_wt_var
.
## Not run:
# Create weights for analyzing 2017-2022 BRFSS data
brfss_data <- pool_brfss_weights(
ph.data = my_brfss_data,
years = 2017:2022,
new_wt_var = "wt_2017_2022"
)
# Create weights for specific years when a question was asked
brfss_data <- pool_brfss_weights(
ph.data = my_brfss_data,
years = c(2017, 2019, 2021),
new_wt_var = "wt_odd_years"
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.