Description Usage Arguments Value Examples
View source: R/nnp_estimation.R
This function implements the Normal No-Pooling model from AA.
1 | nnp_estimation(data, ln, stratum, data_stratum, n_stratum, ..., n_sims = 1000)
|
data |
|
ln |
Unquoted variable indicating the nominal list (number of potential voters) at each polling station. |
stratum |
Unquoted variable indicating the stratum for each polling station. |
data_stratum |
Data frame with stratum variable (named exactly as in
|
n_stratum |
Unquoted variable indicating the number of polling stations in each stratum. |
... |
Unquoted variables indicating the number of votes in each polling station for each candidate. |
std_errors |
Logical value indicating whether to compute standard errors (using bootstrap), defaults to TRUE. |
B |
Number of bootstrap replicates used to compute standard errors, defaults to 50. |
seed |
integer value used to set the state of the random number generator (optional). It will only be used when computing standard errors. |
A list with two entries:
lambdas_summary data.frame
including posterior mean, median,
standard error, and quantiles (0.025 and 0.975) for each party.
lamdas_sim data.frame
with simulations for each party.
1 2 3 4 5 6 7 8 9 | # count number of polling stations per stratum
gto_stratum_sizes <- gto_2012 %>%
dplyr::group_by(distrito_loc_17) %>%
dplyr::summarise(n_stratum = n())
gto_sample <- select_sample_prop(gto_2012, stratum = distrito_loc_17, 0.06)
gto_nnp <- nnp_estimation(data = gto_sample, ln = ln_total,
stratum = distrito_loc_17,
data_stratum = gto_stratum_sizes, n_stratum = n_stratum,
pri_pvem:otros, n_sims = 100)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.