triplot.normal.knownvariance: Draw prior, data and posterior for a known variance normal...

Description Usage Arguments Author(s) References See Also Examples

View source: R/triplot.normal.knownvariance.R

Description

The function draws a normal prior distribution, the data and the posterior distribution in one plot. It serves as a tool to explore the influence of different prior on a hypotehtical set of normally distributed data

Usage

1
2
triplot.normal.knownvariance(theta.data, variance.known, n, prior.theta, prior.variance, 
legend = TRUE, ylim = c(0, max(yposterior)), legend.bty="n")

Arguments

theta.data

mean of the data

variance.known

known variance

n

sample size

prior.theta

mean of the prior distribution

prior.variance

variance of the prior distribution

legend

logical, if TRUE (default) a legend is drawn

ylim

ylim of the plot

legend.bty

box type of legend

Author(s)

Fraenzi Korner-Nievergelt

References

Gelman, A., J. B. Carlin, H. S. Stern and D. B. Rubin (2004). Bayesian Data Analysis. New York, Chapman & Hall/CRC.

See Also

dnorm

Examples

1
2
triplot.normal.knownvariance(theta.data=10, n=20, variance.known=5, 
   prior.theta=0, prior.variance=100) 

Example output

Loading required package: MASS
$posterior.mean
[1] 10.09056

$posterior.variance
[1] 0.2493766

$x
 [1] 11.675145 12.282391  5.546180  9.833044  8.890659 12.334810 10.554547
 [8]  8.587080 12.158208  9.184877 10.735868 12.354362  8.972543  8.560952
[15]  6.368376  9.012413 10.348796  9.813664  9.403156 15.698559

blmeco documentation built on Dec. 5, 2019, 5:09 p.m.