Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

normpostsim

Simulation from Bayesian normal sampling model


Description

Gives a simulated sample from the joint posterior distribution of the mean and variance for a normal sampling prior with a noninformative or informative prior. The prior assumes mu and sigma2 are independent with mu assigned a normal prior with mean mu0 and variance tau2, and sigma2 is assigned a inverse gamma prior with parameters a and b.

Usage

normpostsim(data,prior=NULL,m=1000)

Arguments

data

vector of observations

prior

list with components mu, a vector with the prior mean and variance, and sigma2, a vector of the inverse gamma parameters

m

number of simulations desired

Value

mu

vector of simulated draws of normal mean

sigma2

vector of simulated draws of normal variance

Author(s)

Jim Albert

Examples

data(darwin)
s=normpostsim(darwin$difference)

LearnBayes

Functions for Learning Bayesian Inference

v2.15.1
GPL (>= 2)
Authors
Jim Albert
Initial release
2018-03-18

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.