Next Bayes Club: Playing with Priors

During tomorrow’s Bayes Club, we want to 1) get some more practice reading and interpreting JAGS models, and 2) get a feel for how your priors influence your results.

So, having already gone through the model for estimating the difference between two groups (i.e. the “BEST” model), we’ll check out the code for exploring the relationship between two continuous predictors (conceptually similar to a simple regression). For the sake of consistency in style, etc., we’re using another of Kruschke’s models for this. Download it here: http://www.indiana.edu/~kruschke/DoingBayesianDataAnalysis/Programs/ProgramsDoingBayesianDataAnalysis.zip (The model we’ll be looking at is called “SimpleLinearRegressionJags-Original.r”)

The mechanics for running this model are almost exactly the same as what we saw in the BEST example, it’s mostly just the JAGS model itself that’s different. We’ll walk through it, and link it up to a graphical representation of the model, like we did for BEST.

Then, we’ll ask you to play around changing the priors on this model (and/or the BEST model, if you like). We’re hoping that you’ll come away with 1) a better understanding of what distributions are available in JAGS and what they look like, and 2) a better sense of how changes to your priors affect your posterior. To encourage maximum self-directed hands-on-ness, we’d like you all to play around with this yourselves on your own machine for the second half of the meeting. Here are some ideas to get you started:

  • To begin with, the prior for the residuals is a normal distribution. Change it to a t distribution, and, for extra points, infer the degree of normalness (i.e. the nu parameter, that operates as df in the t dist to determine how chunky the tails are).
  • Strongly assume that the null hypothesis is true (i.e. that these two variables do NOT have a relationship, so the slope should be 0). Try this one several ways.
  • Standardize your variables, and then set a uniform prior on the slope, such that it ranges from -1 to 1, with all possible values equally likely. 
  • Assume that the slope can only be positive (like a one-directional test).
  • Tweak the values for the parameters on the priors Kruschke provides (for example, play around with the parameters for the gamma distribution that defines the prior for precision).
  • Choose your own adventure!

Each time you change a prior, try plotting it first so you can see what it looks like. Typically, the easiest way to do this is plot(function(x)dfunc(x, parameters)) where “dfunc” is the name of the distribution and “parameters” is whatever parameters you need to set for that distribution. For example, you can plot a normal curve with mean=0 and SD=1 with plot(function(x)dnorm(x, mean=0, sd=1)).

Spoiler alert: Most changes you make to your priors won’t have that much of an effect on the posterior if you have enough data. When you have a smaller N and/or messier data (weaker relationships), the priors have more sway. Try changing your sample size as well as changing the priors, and see where the balance is. 

Post a comment

You may use the following HTML:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>