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,
...
)
Formula in binary y ~ (1|x1) + (1|x2)
form.
Individual-level dataset
The poststratification target. It must contain the column
count
, which is treated as the number of trials
in the binomial model.
Character for the variable(s) that corresponds to the area to aggregate to.
A character string for the variable name for the population
count in the poststrat_tgt
dataframe. This will be renamed as if it is
a trial count in the model. Defaults to "count"
.
Character for the variable that corresponds to weights.
Any area-level data to be merged with the output, for example validation data
Whether to use a data.table/dtplyr backend for processing for slightly faster dataframe wrangling. Currently does not apply to anything within the function.
Additional arguments to pass to the model fitting function, fit_brms()
Combines fit_brms
, poststrat_draws
, and direct_est
. See scatter_45
for options on visualization
if (FALSE) {
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")
}