hrr | R Documentation |
hrr
returns a list containing a Stan fit, a tidy data frame
of coefficients, and pre-calculated tables showing the popularity
of different options amongst different groups defined by the
categorical predictors in the model.
hrr(
f,
data,
ps,
aux,
res,
areavar,
weightvar,
testing = FALSE,
adjust = FALSE,
overdispersed = FALSE,
threading = FALSE,
probs = c(0.025, 0.5, 0.975),
mrp_only = FALSE,
stan_control = list(adapt_delta = 0.99, max_treedepth = 12),
...
)
f |
a two-part formula, with categorical predictors found in the post-stratification frame followed by a vertical bar and (continuous or categorical) predictors found in the auxiliary area-level data. |
data |
a data frame containing the outcome variable and the
categorical predictors specified in the first part of formula
|
ps |
a data frame containing the categorical predictors
specified in the first part of formula |
aux |
a data frame containing the continuous or categorical
predictors specified in the second part of formula
|
res |
a data frame containing the aggregate-level outcomes for
each area. The data frame must include the area identifier
named in |
areavar |
a character string giving the name of an area
identifier found in the different input data frames ( |
weightvar |
a character string giving the name of the variable
in data frame |
testing |
a logical value. If |
adjust |
a logical value. If |
overdispersed |
a logical value. If |
threading |
an integer. If |
probs |
a vector of probabilities. This parameter affects the summary statistics returned. |
mrp_only |
a logical value. If |
stan_control |
a list of arguments passed to RStan or cmdstanr's control argument. |
... |
other arguments passed on RStan or (if threading > 0) to cmdstanr. |
A list with entries area_smry
, grp_smry
, and fit
.
data("toydat")
data("toypsf")
f <- cat_y ~ k_1 + k_2 + k_3 | x_1 + x_2
aux <- unique(toydat[,c("area", "x_1", "x_2")])
res <- unique(toydat[,c("area", "red", "green", "blue")])
## Generate Stan code and data for later use
mod <- hrr(f, data = toydat, ps = toypsf, aux = aux,
res = res, areavar = "area", weightvar = "count",
testing = TRUE, adjust = FALSE, overdispersed = TRUE)
## Computationally intensive bit
## Not run:
mod <- hrr(f, data = toydat, ps = toypsf, aux = aux,
res = res, areavar = "area", weightvar = "count",
testing = FALSE, adjust = FALSE, overdispersed = TRUE,
iter = 320, chains = 4, cores = 4)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.