nvaricp {Bolstad}R Documentation

Bayesian inference for a normal standard deviation with a scaled inverse chi-squared distribution

Description

Evaluates and plots the posterior density for σ\sigma, the standard deviation of a Normal distribution where the mean μ\mu is known

Usage

nvaricp(y, mu, S0, kappa, ...)

Arguments

y

a random sample from a normal(μ,σ2)normal(\mu,\sigma^2) distribution.

mu

the known population mean of the random sample.

S0

the prior scaling factor.

kappa

the degrees of freedom of the prior.

...

additional arguments that are passed to Bolstad.control

Value

A list will be returned with the following components:

sigma

the vaules of σ\sigma for which the prior, likelihood and posterior have been calculated

prior

the prior density for σ\sigma

likelihood

the likelihood function for σ\sigma given yy

posterior

the posterior density of μ\mu given yy

S1

the posterior scaling constant

kappa1

the posterior degrees of freedom

Examples


## Suppose we have five observations from a normal(mu, sigma^2)
## distribution mu = 200 which are 206.4, 197.4, 212.7, 208.5.
y = c(206.4, 197.4, 212.7, 208.5, 203.4)

## We wish to choose a prior that has a median of 8. This happens when
## S0 = 29.11 and kappa = 1
nvaricp(y,200,29.11,1)

##  Same as the previous example but a calculate a 95% credible
## interval for sigma. NOTE this method has changed
results = nvaricp(y,200,29.11,1)
quantile(results, probs = c(0.025, 0.975))

[Package Bolstad version 0.2-41 Index]