Monday, June 27, 2016

With the U.K. leaving the E.U., it's time for "Bayesian" to exit its titular role and be replaced by "Laplacian".

;-)

Various historians (e.g., Dale, 1999; McGrayne, 2011; as cited in DBDA2E) have argued that despite Bayes and Price having published the basic formula first, it was Laplace who did all the heavy lifting to develop the methods. Laplace was French, while Bayes and Price were English.

On the other hand, Bayes did attend the University of Edinburgh, and lived around London, so maybe he would have voted to stay!

This humorous implication of Brexit was suggested by a participant at a workshop I presented in St. Gallen, Switzerland, last week, after I briefly described the history above and showed the book photographed at Bayes' tomb and at Laplace's memorial. I have forgotten who it was that made the joke. If the originator of the joke is reading this, please put a comment below or send me an email!

Thursday, June 23, 2016

In DBDA2E and in workshops, I present an example of simple linear regression: predicting an adult's weight from his/her height. A participant at a recent workshop suggested that maybe the y-intercept should be fixed at zero, because a person of zero height should have zero weight. I replied that the linear trend is really only intended as a description over the range of reasonable adult heights, not to be extrapolated all the way to a height of zero. Nevertheless, in principle it would be easy to make the restriction in the JAGS model specification. But then it was pointed out to me that the JAGS model specification in DBDA2E standardizes the variables -- to make the MCMC more efficient -- and setting the y intercept of the standardized y to zero is (of course) not the same as setting the y intercept of the raw scale to zero. This blog post shows how to set the y intercept on the raw scale to zero.

For reference, here (below) is the original model specification that does not fix the y intercept at zero. (This is in file Jags-Ymet-Xmet-Mrobust.R.) Notice two lines below in bold font and yellow highlight, regarding the prior on the standardized intercept zbeta0 and the transformation back to the raw-scale intercept beta0:

Now how to fix beta0 to zero: Instead of putting a broad prior distribution on zbeta0, it is set to whatever value would make raw-scale beta0 equal zero. To determine that corresponding value of zbeta0, we use the transform-to-raw-scale formula for beta0, shown at the end of the model specification above. In that formula, set beta0 to 0, then solve for zbeta0. Replace the prior on zbeta0 as follows:

When run on the height/weight data (using script Jags-Ymet-Xmet-Mrobust-Example.R), a smattering of regression lines from the posterior distribution looks like this:
You can see that the y-intercept has indeed been fixed at zero for all the regression lines.

One crucial trick to getting the graphs to display: In the plotMCMC command of Jags-Ymet-Xmet-Mrobust-Example.R, set showCurve to TRUE: