mrp_onestep | R Documentation |
Fits and tidies MRP outputs in one step
mrp_onestep(
.formula,
.data,
poststrat_tgt,
area_var = "cd",
count_var = "count",
weight_var = NULL,
add_on = NULL,
dtplyr = TRUE,
new_levels = FALSE,
allow_NA = FALSE,
...
)
.formula |
Formula in |
.data |
Individual-level dataset |
poststrat_tgt |
The poststratification target. It must contain the column
|
area_var |
Character for the variable(s) that corresponds to the area to aggregate to. |
count_var |
A character string for the variable name for the population
count in the |
weight_var |
Character for the variable that corresponds to weights. |
add_on |
Any area-level data to be merged with the output, for example validation data |
dtplyr |
Whether to use a data.table/dtplyr backend for processing for slightly faster dataframe wrangling. Currently does not apply to anything within the function. |
new_levels |
If there are new levels in the poststrat table that do not have coefficients in the survey data, should there be an extrapolation or assignment to 0s? The answer should almost always be No in MRP. |
allow_NA |
A logical (TRUE or FALSE) indicating whether
the |
... |
Arguments passed on to
|
Combines fit_brms
, poststrat_draws
, and direct_est
. See scatter_45
for options on visualization
## Not run:
library(ccesMRPviz)
mrp_fit <- mrp_onestep(response ~ (1|educ) + (1|cd),
.data = cces_GA,
poststrat_tgt = acs_GA,
area_var = "cd",
count_var = "count",
weight_var = "weight_post",
add_on = elec_GA)
scatter_45(mrp_fit, clinton_vote, p_mrp_est,
xlab = "Clinton Vote", ylab = "MRP Estimate")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.