View source: R/hb_estimation.R
hb_estimation | R Documentation |
Compute point estimate and credible intervals for each candidate.
hb_estimation(
data_tbl,
stratum,
id_station,
sampling_frame,
parties,
covariates,
prop_obs = 0.995,
seed = NULL,
return_fit = FALSE,
num_iter = 200,
num_warmup = 200,
adapt_delta = 0.8,
max_treedepth = 10,
chains = 3,
sig_figs = 6,
model = "mlogit-corr",
nominal_max = 1000,
threads_per_chain = 1,
inv_metric = NULL,
erase_output_files = TRUE
)
data_tbl |
|
stratum |
Unquoted variable indicating the stratum for each polling station. |
id_station |
Unquoted variable indicating the id for each polling station. |
sampling_frame |
|
parties |
Unquoted variables indicating the number of votes in each polling station for each candidate. |
covariates |
Unquoted variables indicating the covariates in each polling station. |
prop_obs |
Proportion of size of observed sample to total designed sample. |
seed |
integer value used to set the state of the random number generator (optional). |
return_fit |
Returns summary if FALSE (default), otherwise return cmdstanr fit |
num_iter |
Number of post warmup iterations |
num_warmup |
Number of warmup iterations |
adapt_delta |
The adaptation target acceptance statistic (default 0.80. |
max_treedepth |
The maximum allowed tree depth for the NUTS engine (default 10) |
chains |
Number of chains (will be run in parallel) |
sig_figs |
Number of significant figures for Stan output |
model |
One of "mlogit" (the default) or "logit" |
nominal_max |
Maximum number of nominal count for stations. Used for stations without fixed nominal list. |
threads_per_chain |
Number of threads per chain to split calculation of log-posterior |
inv_metric |
vector of inverse metric diagonal for the model. Default is NULL |
erase_output_files |
If TRUE, output files are erased after fitting |
Posterior simulations of parameters are computed using stan, and each party's votes are simulated for every polling station (logit model) or with a softmax link for the default (mlogit model). There is one independent model for each party, and proportions are calculated from posterior simulations of total votes.
A list with model fit (if return_fit=TRUE), a tibble
estimates including point estimates for each party (median)
and limits of credible intervals, and a vector inv_metric for the model
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.