# How do I correctly produce a prior/posterior plot from MCMC chains in Bayesian hierarchical models?

I'm a beginner at hierarchical modeling and statistics in general and this is confusing me.

Question: If I draw a histogram of a posterior distribution from an MCMC chain, do I draw the prior as a histogram, too, or do I just paste the distribution into the posterior plot (and make sure it has the same scale)?

Background: I'm using WinBUGS/OpenBUGS to do parameter estimation of a memory decay model. This is my first try at hierarchical models and my first serious attempt at using statistics. Whenever, I want to plot the prior of one of my parameters, I usually use a function in R to get data e.g. dnorm(0:10,mean=5,sd=1) (if the prior is a normal distribution). I then use a histogram or a function like densityplot() to create a plot from the data. What I'm basically wondering is this: The output of dnorm(0:10,mean=5,sd=1) are ten values. Are these density values? Or are these probabilities? Which one should I use?

Your prior is a full distribution, not just 10 values. If I were using a $N(5,1)$ prior, I would probably plot it by evaluating the density function at a large number of values over small increments in the neighborhood of its mode, like this:

xv = seq(0,10,.01)
plot(xv, dnorm(xv, 5, 1), type='l')


Generally, I'd be more likely to plot the posterior using a kernel density estimate than as a histogram, but the histogram certainly has its place (especially if you aren't able to sample a lot of values from the posterior). In any event, there's very little excuse to plot a simple prior like yours using a histogram since we know its shape exactly.

Regarding this question:

The output of dnorm(0:10,mean=5,sd=1) are ten values. Are these density values? Or are these probabilities?

I refer you to this answer that does a good job explaining how to interpret a pdf: https://stats.stackexchange.com/a/4223/8451