update_prior {truelies}R Documentation

Calculate posterior distribution of the proportion of liars

Description

update_prior uses the equation for the posterior:

\phi(\lambda | R; N,P) = Pr(R|\lambda; N,P) \phi(\lambda) / \int Pr(R | \lambda'; N,P) \phi(\lambda') d \lambda'

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

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

Usage

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

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

[Package truelies version 0.2.0 Index]