mrp_estimation: Compute all postratified estimates

Description Usage Arguments Value See Also Examples

View source: R/mrp_estimation.R

Description

This function calls mrp_party_estimation using all the parties specified in '...', once there is an estimation of the number of votes for each party/candidate it computes the proportion of votes for each one.

Usage

1
2
3
mrp_estimation(data, ..., stratum, frac = 1, n_iter = 2000,
  n_burnin = 500, n_chains = 3, seed = NA, parallel = FALSE,
  n_cores = 6, model_string = NULL, set_strata_na = integer(0))

Arguments

data

A data.frame with variables: ln_total, region, distrito_loc_17, tamano_md, tamano_gd, casilla_ex and the column with number of votes for the party.

...

One or more unquoted expressions separated by commas, indicating the column names with the votes for each candidate.

stratum

If sampling the data, unquoted variable indicating the column from the data.frame to be used as strata. The strata will also be used in the hierarchical structure of the model.

frac

If sampling the data, numeric value indicating the fraction of the data to sample, the sample is selected using stratified sampling with probability proportional to size.

n_iter

Number of iterations, burnin size and chains. to be used in jags.

n_burnin

Number of iterations, burnin size and chains. to be used in jags.

n_chains

Number of iterations, burnin size and chains. to be used in jags.

seed

Integer value used to set the state of the random number generator.

parallel

Logical value indicating whether to parallelize the models, if TRUE package parallel must be installed (uses mclapply and can not be used in Windows).

n_cores

If parallelizing, the number of cores to use, parameter is used in mclapply, mclapply

model_string

String indicating the model to be used, if NULL defaults to "model_bern_t", also available "model_t".

set_strata_na

Option to exclude strata when fitting the model, used for model evaluation and calibration.

Value

A list with the object fitted using R2jags::jags and a data.frame with the estimation summary (posterior means, medians, standard deviations and probability intervals per party).

See Also

mrp_party_estimation

Examples

1
2
3
4
data("gto_2012")
est_gto <- mrp_estimation(gto_2012, party = pri_pvem:otros, stratum = distrito_loc_17,
  frac = 0.01, seed = 2212)
est_gto$post_summary

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