update_prior: Calculate posterior distribution of the proportion of liars

Description Usage Arguments Value Examples

View source: R/functions.R

Description

update_prior uses the equation for the posterior:

φ(λ | R; N,P) = Pr(R|λ; N,P) φ(λ) / \int Pr(R | λ'; N,P) φ(λ') d λ'

where φ is the prior and Pr(R | λ; N, P) is the probability of R reports of heads given that people lie with probability λ:

Pr(R | λ; N, P) = binom(N, (1-P) + λ P)

Usage

1
update_prior(heads, N, P, prior = stats::dunif, npoints = 1000)

Arguments

heads

Number of good outcomes reported

N

Total number in sample

P

Probability of bad outcome

prior

Prior over lambda. A function which takes a vector of values between 0 and 1, and returns the probability density. The default is the uniform distribution.

npoints

How many points to integrate on?

Value

The probability density of the posterior distribution, as a one-argument function.

Examples

1
2
posterior <- update_prior(heads = 30, N = 50, P = 0.5, prior = stats::dunif)
plot(posterior)

truelies documentation built on Aug. 27, 2019, 1:02 a.m.