NormalNormalPosterior: Normal-Normal Posterior in conjugate normal model, for known...

Description Usage Arguments Value Author(s) References Examples

View source: R/NormalNormalPosterior.r

Description

Compute the posterior distribution in a conjugate normal model for known variance: Let X_1, …, X_n be a sample from a N(μ, σ^2) distribution, with σ assumed known. We assume a prior distribution on μ, namely N(ν, τ^2). The posterior distribution is then μ|x \sim N(μ_p, σ_p^2) with

μ_p = (1 / (σ^2 / n) + τ^{-2})^{-1} (\bar{x} / (σ^2/n) + ν / τ^2)

and

σ_p = (1 / (σ^2/n) + τ^{-2})^{-1}.

These formulas are available e.g. in Held (2014, p. 182).

Usage

1
NormalNormalPosterior(datamean, sigma, n, nu, tau)

Arguments

datamean

Mean of the data.

sigma

(Known) standard deviation of the data.

n

Number of observations.

nu

Prior mean.

tau

Prior standard deviation.

Value

A list with the entries:

postmean

Posterior mean.

postsigma

Posterior standard deviation.

Author(s)

Kaspar Rufibach (maintainer)
kaspar.rufibach@roche.com

References

Held, L., Sabanes-Bove, D. (2014). Applied Statistical Inference. Springer.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## data:
n <- 25
sd0 <- 3
x <- rnorm(n, mean = 2, sd = sd0)

## prior:
nu <- 0
tau <- 2

## posterior:
NormalNormalPosterior(datamean = mean(x), sigma = sd0, 
                      n = n, nu = nu, tau = tau)

bpp documentation built on Jan. 13, 2022, 5:09 p.m.