Formats a post-strat table from ACS and district-level data

get_poststrat(cleaned_acs, dist_data = NULL, formula)

Arguments

cleaned_acs

An output of get_acs_cces. The count of people in each cell must be under the variable count

dist_data

District-level (in this case congressional district-level) information to merge in

formula

the model formula used to fit the multilevel regression model, with one term on the LHS: e.g. y ~ x1 + x2 + (1|x3). Only the RHS will be used but the LHS is necessary for now.

See also

Examples

if (FALSE) { fm_brm <- response ~ age + gender + educ + pct_trump + (1|cd) acs_tab <- get_acs_cces( varlist = acscodes_age_sex_educ, varlab_df = acscodes_df, year = 2018) poststrat <- get_poststrat(acs_tab, cd_info_2018, fm_brm) head(poststrat) # age gender educ pct_trump cd count # <fct> <fct> <fct> <dbl> <chr> <dbl> # 1 18 to 24 years Male HS or Less 0.049 NY-15 24216 # 2 18 to 24 years Male HS or Less 0.054 NY-13 18014 # 3 18 to 24 years Male HS or Less 0.068 CA-13 14153 # 4 18 to 24 years Male HS or Less 0.07 PA-03 15750 # 5 18 to 24 years Male HS or Less 0.087 CA-12 6270 # 6 18 to 24 years Male HS or Less 0.092 IL-07 18734 }