Description Usage Arguments Value Examples
View source: R/mrp_party_estimation_stan.R
The function fits a model using the rstan
package and
predicts number of votes for a given candidate in unobserved polling
stations. Optionally the model can be fit with a stratified random sample
of the data, and predict for the population.
1 2 3 |
data |
A |
party |
Unquoted variable indicating the column from the data.frame to be modeled. |
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, warmup, n_chains |
Number of iterations, number of warmup
iterations and number of chains.
to be used in |
seed |
Integer value used to set the state of the random number generator. |
model_string |
String indicating the model to be used, defaults to
|
set_strata_na |
Option to exclude strata when fitting the model, used for model evaluation and calibration. |
A list containing fit object and vector the simulated counts for the candidate.
1 2 3 4 | mrp_party_pri <- mrp_party_estimation_stan(nal_2012, pri_pvem, frac = 0.02,
stratum = estrato, n_iter = 300, warmup = 150,
n_chains = 2, seed = 19291)
quantile(mrp_party$y)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.