One attractive feature of Bayesian thinking is that one can consider alternative specifications for the sampling density and prior and these alternatives makes one think more carefully about the typical modeling assumptions.

Generally we observe a sample distributed from a sampling density depending on a parameter . If we assign a prior density , then the posterior density is given (up to a proportionality constant) by

Consider the following Cauchy/Cauchy model as an alternative to the usual Normal/Normal model. We let be distributed from a Cauchy density with location and known scale parameter , and we assign a Cauchy prior with location and scale .

Of course, this is not going to be a conjugate analysis — the posterior density has a complicated form. But it is easy to use R to plot and summarize the posterior density.

First we define the posterior density for . The arguments to the function are theta (which could be a vector), the vector of data values, the known scale parameter , and the prior parameters andn . The output is a vector of values of the (unnormalized) posterior density.

posterior=function(theta,data,scale,mu0,tau)

{

f=function(theta) prod(dcauchy(data,theta,scale))

likelihood=sapply(theta,f)

prior=dcauchy(theta, mu0, tau)

return(prior*likelihood)

}

posterior=function(theta,data,scale,mu0,tau)

{

f=function(theta) prod(dcauchy(data,theta,scale))

likelihood=sapply(theta,f)

prior=dcauchy(theta, mu0, tau)

return(prior*likelihood)

}

(This function is a little tricky to program since both theta and data are vectors.)

We can plot the posterior density using the curve function. We first give the data vector, assume

and assign a Cauchy(0, 1) prior for

.

data=c(2,5,4,3,10,11,10,9)

We then use the curve function to plot the posterior. After some preliminary work, we know that the probability mass falls between 0 and 15, so we use from = 0, to = 15 in the function.

curve(posterior(x,data,1,0,1),from=0,to=15,xlab=”THETA”,ylab=”DENSITY”)

Here is the plot that is produced. Note the interesting bimodal shape. One can obtain different posterior shapes when we model using Cauchy densities. (Question: Why does the posterior have this particular shape?)