# Plotting a “posterior median surface”

As part of reproducing a model I described partially in this question on Stack Overflow, I want to obtain a plot of a posterior distribution. The (spatial) model describes the selling price of some properties as a Bernoulli distribution depending on whether the property is expensive (1) or cheap (0). In equations:

$$y_{i} \sim \text{Bernoulli}(p_{i})$$ $$p_{i} \sim \text{logit}^{-1}(b_{0} + b_{1}\text{LivingArea}/1000 + b_{2}\text{Age} + w({\bf{s}}))$$ $$w({\bf{s}}) \sim \text{MVN}({\bf{0}}, {\bf{\Sigma}})$$

where $y_{i}$ is the binary result 1 or 0, $p_{i}$ is the probability of being cheap or expensive, $w({\bf{s}})$ is a spatial random variable where $\bf{s}$ represents its position. All of this for each $i = \{1, ..., 70\}$ because there are 70 properties in the dataset. $\bf{\Sigma}$ is a covariance matrix based on the geographical position of the data points. If you're curious about this model, the dataset can be found here.

The plot I want to obtain is the following contour plot:

The figure is described as "Image plot of the posterior median surface of the latent process $w({\bf{s}})$, binary spatial model". The book also says this:

Figure 5.8 shows the image plot with overlaid contour lines for the posterior mean surface of the latent $w({\bf{s}})$ process.

However, there are only 70 pairs of points in the dataset. I suppose that, in order to produce a contour plot, I need to estimate $w({\bf{s}})$ in 70*70 points. So, my question is: How do I produce this posterior median surface? So far I have samples of posterior distributions for all the parameters involved (using PyMC) and I know that I can predict $y^*$ at a new point using the posterior predictive distribution. However, I don't know how to predict values $w({\bf{s}})$ at a new point $s^*$. Maybe I'm wrong and the plot wasn't constructed by prediction but by interpolation.

UPDATE:

First, this is the median of the posterior distribution of $w({\bf{s}})$ at each location where there is a property. This is based on the MCMC trace for $w$.

And this is the interpolation (with a contour plot) using a radial basis function:

(If you're interested in the code, let me know)

As you can see, there are significant differences in the plots. A couple of questions:

1. How can I know if these differences are explained by the interpolation procedure?

2. Maybe, there are important variations in the posterior distribution of $w({\bf{s}})$ that I calculated and the one showed in the book. How much variation is acceptable between MCMC simulations? Even my own parameters change a bit depending on the sampling I use (Metropolis, Metropolis Adaptive.)

3. Is there some Bayesian procedure to predict points $w(s)$ in order to generate a contour plot as I did using radial basis function?

• Interpolation is prediction! (Because $w$ is a process, coming up with a value of $w$ at any unobserved location amounts to guessing the value of a random variable. Prediction, by definition, is guessing the value of a random variable.) – whuber Sep 5 '14 at 17:08
• Sure. I meant to say interpolation as opposed to Bayesian prediction. By the way, I tried to use interpolation with nearest neighbor and I got awful results. – Robert Smith Sep 5 '14 at 17:21
• You probably should get terrible results if you use the raw data in an interpolation program, because it was solving a different problem. You want a contour plot only of the $w$ term but the program was (I presume) using the $y_i$. – whuber Sep 5 '14 at 17:25
• No, I was using the median of the posterior distribution for each $w(s)$. – Robert Smith Sep 5 '14 at 17:31
• At which spatial locations $s$ did you compute the median of the posterior distribution? I believe the principal motivation behind running a model of this sort is to track the distribution of $w(s)$ at all points where you are interested in predicting its values, which--in the case of this contour map--would be all 4900 grid nodes. – whuber Sep 5 '14 at 17:38

I tried it and I think the resulting plot shares features with the posterior median surface of the original question. This is the median of the posterior distribution of $w(s)$ as above (it is slightly different because I ran another MCMC simulation):