hb_estimation_parallel: Bayesian hierarchical model to estimate proportion of votes...

View source: R/hb_estimation.R

hb_estimation_parallelR Documentation

Bayesian hierarchical model to estimate proportion of votes allocated to each party

Description

Compute point estimate and credible intervals for each candidate, parallized over split_var.

Usage

hb_estimation_parallel(
  data_tbl,
  sampling_frame,
  split_var = NULL,
  nominal_list_var = NULL,
  num_cores = 5,
  inv_metric_list = NULL,
  nominal_max = 1000,
  sig_figs = 7,
  ...
)

Arguments

data_tbl

tibble of sample data.

sampling_frame

tibble of sampling frame with stratum variable (named exactly as in data_tbl) and covariates.

split_var

unquoted name of variable that splits sampling frame and data

nominal_list_var

Unquoted name of variable with nominal list of voters

num_cores

Number of cores to use for parallel computation

inv_metric_list

List of inv_metric diagonals guesses for each split

nominal_max

Maximum number of nominal count for stations. Used for stations without fixed nominal list.

sig_figs

Number of significant figures for Stan output

...

Other parameters passed to hb_estimation.

Details

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. Splits are modelled independently

Value

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


cotecora-team-2/quickcountmx documentation built on July 17, 2025, 5:14 a.m.