nnp_estimation: Normal No-Pooling model

Description Usage Arguments Value Examples

View source: R/nnp_estimation.R

Description

This function implements the Normal No-Pooling model from AA.

Usage

1
nnp_estimation(data, ln, stratum, data_stratum, n_stratum, ..., n_sims = 1000)

Arguments

data

data.frame

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 data) and number of polling stations per strata.

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.

Value

A list with two entries:

  1. lambdas_summary data.frame including posterior mean, median, standard error, and quantiles (0.025 and 0.975) for each party.

  2. lamdas_sim data.frame with simulations for each party.

Examples

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)

tereom/quickcountmx documentation built on Dec. 2, 2019, 9:58 p.m.