draw_from_posterior {coalitions}R Documentation

Draw random numbers from posterior distribution

Description

Draw random numbers from posterior distribution

Usage

draw_from_posterior(
  survey,
  nsim = 10000,
  seed = as.numeric(now()),
  prior = NULL,
  correction = NULL
)

Arguments

survey

survey object as returned by as_survey or getSurveys

nsim

number of simulations

seed

sets seed

prior

optional prior information. Defaults to 1/2 (Jeffrey's prior).

correction

A positive number. If not NULL, each sample from the Dirichlet distribution will be additionally "corrected" by a random number from U(-1*correction, 1*correction). This can be used to introduce extra variation which might be useful due to rounding errors from reported survey results (or add an additional source of variation in general).

Value

data.frame containing random draws from Dirichlet distribution which can be interpreted as election results.

See Also

as_survey


[Package coalitions version 0.6.20 Index]