bayes: Probabilities in a brazilian electoral pool

Description Usage Arguments Examples

View source: R/bayes.R

Description

Calculates posterior probabilities via Monte Carlo.

Usage

1
bayes(p = vector(), n, p.nv = 0, p.und = 0, M = 10^4)

Arguments

p

A vector containing the proportions of votes.

n

Sample size.

p.nv

A number containing the proportion of non valid votes to be excluded. Default: 0.

p.und

A number containing the proportion of undecided votes to be proportionally distributed considering p and p.nv. Default: 0.

M

Number of replications. Default: 10^4.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
bayes(c(.4,.3,.3), 1000)
bayes(c(.3,.25,.2,.1,.05), 100)
bayes(rep(1/5,5), 500)
# Contando com não válidos (p.nv) e indecisos (p.und)
# https://www.cnnbrasil.com.br/politica/2021/03/10/pesquisa-exclusiva-cnn-mostra-bolsonaro-em-1-dez-pontos-a-frente-de-lula
bayes(p=c(.31,.21,.10,.09,.07,.04,.02,.01), n=1200, p.nv=0.12, 0.03)
bayes(c(.43,.39), 1200, 0.15, 0.03)
# A seguir estão cenários com empate técnico tríplice segundo os institutos de pesquisa.
bayes(c(.5813972562, .3158114522, .1027912917), 50)
bayes(c(.5144202347, .3246860305, .1608937348), 100)
bayes(c(.4160925601, .3316216347, .2522858052), 500)
bayes(c(.3919345050, .3324785813, .2755869137), 10^3)
bayes(c(.3518464606, .3332479566, .3149055828), 10^4)
bayes(c(.3391808234, .3333247966, .3274943799), 10^5)
bayes(c(.3333333335, .3333333333, .3333333331), 10^20)

filipezabala/desempateTecnico documentation built on Aug. 14, 2021, 2:04 p.m.