Friday, March 14, 2014

Bayesian estimation and precision as the goal for data collection (expanded)

Precision as the goal for data collection, talk at U.C. Irvine, March 14, 2014.

Part 1: Rejecting null is not enough, also need estimate and precision. Bayesian estimation supersedes confidence intervals and "the new statistics".


Part 2: Two Bayesian ways to assess a null value. Highest density interval with region of practical equivalence. Bayesian model comparison and Bayes factor.


Part 3: Biased estimation in sequential testing and optional stopping.


Part 4: Monte Carlo study of biased estimation in sequential testing and optional stopping.


Parts 3 and 4 are elaborations of this previous blog post.

Saturday, March 8, 2014

Recent Advances in Bayesian Inference at U.C. Irvine, March 14



Recent Advances in Bayesian Inference

Venue:
University of California at Irvine,
1517 Social and Behavioral Sciences Gateway building

Date:
Friday, March 14, 2014

Speakers:
  • 9:30 John Kruschke (Indiana University). Precision as the goal for data collection.
  • 10:30 Hal Stern (UC Irvine). A statistical approach to detecting patterns in behavioral event sequences.
  • 11:30 Jeff Rouder (University of Missouri). The p < .05 rule and the hidden costs of the free lunch in inference.
  • 2:00 Wes Johnson (UC Irvine). Introduction to Bayesian Nonparametrics.
  • 3:00 Mario Peruggia (Ohio State University). Introduction to Bayesian model averaging.
Registration:
Please contact Dr. Joachim Vandekerckhove, joachim@uci.edu


Saturday, February 22, 2014

Bayesian Tests to Quantify the Result of a Replication Attempt

This manuscript looks like a nice use of Bayes factors to assess replication results. I have not read it yet in detail, but the idea sounds right on target. From the abstract:
To quantify replication outcomes we propose a novel Bayesian replication test that compares the adequacy of two competing hypotheses. The first hypothesis is that of the skeptic and holds that the effect is spurious; this is the null hypothesis that postulates a zero effect size, H0: δ = 0. The second hypothesis is that of the proponent and holds that the effect is consistent with the one found in the original study, an effect that can be quantified by a posterior distribution. Hence, the second hypothesis --the replication hypothesis-- is given by Hr : δ ~ "posterior distribution from original study".
Here is the link: Bayesian Tests to Quantify the Result of a Replication Attempt; Josine Verhagen and Eric-Jan Wagenmakers, University of Amsterdam.

Friday, February 14, 2014

Improved icons for Bayesian and frequentist analysis


This post presents icons that attempt to capture the essence of Bayesian and frequentist analysis. There are four icons: Bayesian and frequentist approaches to decisions about null values, and Bayesian and frequentist approaches to parameter estimation. This post is an update of a previous post, motivated by many helpful comments from readers. For an explanation of what I mean by the "essence" of the approaches, and what I hope to achieve from this exercise, please see the previous post. Without further ado, the icons are presented below, first in a 2x2 grid, then one at a time with explanations in the captions.

Bayesian Frequentist
Null value
assessment
Estimation

Bayesian null value assessment: The light-blue lines indicate the posterior distribution of credible lines. The dark-pink line marks the null value (zero slope). The null value falls far outside any credible value. [Added Feb 16, 2014: Of course, the full decision rule involves a ROPE around the null value. The ROPE is not displayed here, just to keep the icon uncluttered.]

Frequentist null value assessment: The dark-blue line marks the best fit. The dark-pink line marks the null hypothesis.The light-pink lines show the sampling distribution from the null hypothesis. The best fit falls far outside any null-sampled line.

Bayesian estimation: The light-blue lines indicate the posterior distribution of credible lines. There is an explicit distribution of credibilities (i.e., posterior probabilities) across possibilities (possible slopes etc.).

Frequentist estimation: The dark-blue line marks the best fit. The two dark-pink lines mark the limits of the confidence interval. The light-pink lines show the sampling distributions around each of the confidence-interval limits; notice that the best-fit line falls at the extreme of each sampling distribution. There is no distribution of probabilities across possibilities; there are only three point values: the best fit and the two CI limits.
Creative Commons license appended Feb 18, 2014, as suggested by reader comment:
Creative Commons License The four iconic images for Bayesian and frequentist data analysis by John K. Kruschke are licensed under a Creative Commons Attribution 4.0 International License. Based on a work at http://doingbayesiandataanalysis.blogspot.com/2014/02/improved-icons-for-bayesian-and.html.

Wednesday, January 8, 2014

Bayesian variable selection in multiple regression: Sensitivity to prior

[Notice updates appended January 10, 2014.]

In multiple regression, analysts are often concerned with variable selection: Of the many predictor variables, which ones should be selected for inclusion in the model? Bayesian model comparison seems to be a great way to formulate the question: For p predictors, each of which can be included or not included, what are the posterior probabilities of the 2p models? In practice, however, the posterior probability of including a variable can be very sensitive to the vagueness (i.e., variance, precision) of the prior distribution on that variable's regression coefficient. When the priors on the regression coefficients are very vague, then there is small probability of including more variables. Although I have seen this routinely acknowledged in the theoretical literature, it seems to be underemphasized as a practical issue and I am wondering how practitioners deal with it in applied work. In this post I present a simple example of the issue, and I invite practitioners to reply with their experiences and pointers to literature.

Consider the example presented in DBDA (Figure 17.1, p. 455), in which average SAT scores in each state of the United States are predicted from average spending per pupil in each state and percentage of students taking the exam. Here is a depiction of the data:
Figure 17.2, p. 455, of Doing Bayesian Data Analysis.
The four panels show different perspectives on the same data. In this case, there are only two predictor variables. In most applications of variable selection there are many predictors, not merely two, but this case provides a simple demonstration of the issue. The issue is, which of the two predictors should be included in a good model of SAT scores? (There are many possible criteria for inclusion. One pre-analysis consideration is the purpose of the model: Is the purpose explanation or prediction? But here I'll simply leap-frog those considerations and pretend that we want to do Bayesian variable selection.)

The model is linear regression on the standardized data, with an inclusion indicator denoted delta for each predictor. The inclusion indicator can be 0 or 1. Here is an excerpt from the JAGS model specification:
  # Data block, not shown here, creates standardized data
  # denoted zy[i] and zx[i,1:p]. Below, Nx denotes the 
  # number of predictors p.
  model {
    for ( i in 1:Ntotal ) {
      zy[i] ~ dt( zbeta0                  # t dist. for robust

                  + sum( delta[1:Nx]      # delta is inclusion indicator
                         * zbeta[1:Nx]    # regression coefficient
                         * zx[i,1:Nx] ) , # standardized predictor
                  1/zsigma^2 , nu )
    }
    # Priors vague on standardized scale:
    zbeta0 ~ dnorm( 0 , 1/2^2 )           # prior SD=2  <== THE ISSUE!
    for ( j in 1:Nx ) {
      zbeta[j] ~ dnorm( 0 , 1/2^2 )       # prior SD=2  <== THE ISSUE!
      delta[j] ~ dbern( 0.5 )             # prior on inclusion indicator
    }
    zsigma ~ dunif( 1.0E-5 , 1.0E+1 )
    nu <- nuMinusOne+1
    nuMinusOne ~ dexp(1/29.0)

I have highlighted in yellow the line that specifies the prior on the the regression coefficients. It is a generic normal centered at zero with a standard deviation (SD) that is intended to be reasonably large relative to standardized data. In the example above, the SD is set to 2 because regression coefficients for standardized data will be restricted to the range +/-1 in least-squares regression, hence won't be much bigger than that, and an SD of 2 is reasonably flat in the +/-1 range.

Here are the results for two runs with different choices of the prior on the regression coefficients (and the intercept). When I set SD=10, the results look like this:

The posterior probability of the single-predictor model that includes only percentage-taking-the-exam is about 64%. The only other model with non-zero probability includes both predictors, as shown in the second row above.

Here are the results when I set SD=1:


Now the posterior probability of the single-predictor model is only about 17%, and far lower than the two-predictor model.

(Note that I did not change the prior on the inclusion indicator, delta. The prior probabilities on the models remain fixed at 25%.)

Notice that within the models, the explicit estimates of the regression coefficients are only slightly affected by the change on their priors. In both cases, the marginal posterior distribution on beta[1] is pretty clearly above zero (even taking into account a tacit ROPE and MCMC slop), which suggests that beta[1] is useful to include in the model, regardless of what its inclusion parameter might indicate.

How do practitioners "in the wild" deal with this issue? Is it all about making an argument for a particular prior? In the wild, do different reasonable priors yield noticeably different inclusion probabilities, and when they do, what is concluded in practice? Comment below and let us know! (I realize there are all sorts of other considerations in multiple regression -- explanation vs prediction, correlated predictors, etc. And I am not assuming that a single model must be selected; the problem persists for Bayesian model averaging. I am trying here to focus on the issue that posterior inclusion probability is sensitive to the prior on the regression coefficients.)

APPENDED 9:00am January 10, 2013: 

A little (more!) web searching and reading shows that some people combine variable selection with hierarchical shrinkage of regression coefficients. I was trying to be conceptually "pure" and use only variable selection (i.e., inclusion indicators) without hierarchical shrinkage (i.e., estimating the variance of the prior on regression coefficients), because the literature sometimes pits the two approaches (discrete variable selection versus continuous coefficient shrinkage) as competing. But of course there is nothing prohibiting their combination, of course, and a good Bayesian could argue that  it is appropriate: Whenever there is uncertainty, it should be expressed in the prior. Because we have uncertainty in the setting of the prior variance (i.e., we have uncertainty in the value of SD in zbeta[j] ~ dnorm( 0 , 1/SD^2 )) we should put a prior on it. Well, to express lack of knowledge, we could put a broad uniform on SD, or we could put a generic gamma on 1/SD^2, as follows.

   model {
    for ( i in 1:Ntotal ) {
      zy[i] ~ dt( zbeta0 + sum( delta[1:Nx] * zbeta[1:Nx] * zx[i,1:Nx] ) ,
                  1/zsigma^2 , nu )
    }
    # Priors vague on standardized scale:
    zbeta0 ~ dnorm( 0 , 1/2^2 )  #
    for ( j in 1:Nx ) {
      # zbeta[j] ~ dnorm( 0 , 1/2^2 )          # SD of prior on beta is fixed.
      zbeta[j] ~ dnorm( 0 , 1/sigmaOfBeta^2 )  # SD of prior on beta is estim.
      delta[j] ~ dbern( 0.5 )
    }
    zsigma ~ dunif( 1.0E-5 , 1.0E+1 )
    sigmaOfBeta ~ dunif( 1.0E-5 , 1.0E+2 )  # broad uniform
    nu <- nuMinusOne+1
    nuMinusOne ~ dexp(1/29.0)


yields this:

And

  model {
    for ( i in 1:Ntotal ) {
      zy[i] ~ dt( zbeta0 + sum( delta[1:Nx] * zbeta[1:Nx] * zx[i,1:Nx] ) ,
                  1/zsigma^2 , nu )
    }
    # Priors vague on standardized scale:
    zbeta0 ~ dnorm( 0 , 1/2^2 )  #
    for ( j in 1:Nx ) {
      # zbeta[j] ~ dnorm( 0 , 1/2^2 )          # SD of prior on beta is fixed.
      zbeta[j] ~ dnorm( 0 , 1/sigmaOfBeta^2 )  # SD of prior on beta is estim.
      delta[j] ~ dbern( 0.5 )
    }
    zsigma ~ dunif( 1.0E-5 , 1.0E+1 )
    sigmaOfBeta <- 1/sqrt(tauOfBeta)
    tauOfBeta ~ dgamma(0.001,0.001) # generic
    nu <- nuMinusOne+1
    nuMinusOne ~ dexp(1/29.0)


yields this:

So there is still a notable difference in posterior inclusion probabilities even when using hierarchical shrinkage priors, and it still comes down to an argument about the appropriate prior. I realize that the difference in outcomes would be reduced in applications that have more predictors/regressors/explanatory variables. That is, the prior has its strongest influence when the data are few, as in this example with only two predictors.

I am led to this tentative conclusion: Bayesian variable selection (i.e., using inclusion indicators) is best done with informed priors on the regression coefficients. The information can come from previous data and be explicitly expressed in constants in the prior on the regression coefficients. Or, the information can come from hierarchical sharing of information from other predictors in the current data set, via estimating the variance of the prior on the regression coefficients.

Appended more, 11:00am January 10, 2014:

The conclusion expressed above is just a special case of a general principle I have advocated in any Bayesian model comparison: To put the models on an equal playing field, their priors must be equivalently informed, even if it's merely mildly informed. That is, generic diffuse priors in the models can inadvertently lead to very different marginal likelihoods than what the models would have gotten with reasonably informed priors, even very mildly informed priors. So, what was a "tentative conclusion" above is rapidly turning into a prescriptive admonition!

Saturday, December 28, 2013

Icons for the essence of Bayesian and frequentist data analysis

Goal: Simple graphical icons that capture the essence of Bayesian data analysis and frequentist data analysis. Why? Visual icons serve as mnemonic cognitive packaging that facilitate initial understanding and subsequent remembering. In this post, I propose simple icons that attempt to portray the essence of Bayesian data analysis and frequentist data analysis.

[Feb. 14, 2014: See follow-up post, with new icons, HERE.]

(The prod that got me thinking about this was a light-hearted blog post by Rasmus Baath regarding a "mascot" for Bayesian data analysis. My comment on that post is the beginning of this post. Please note that the icons presented here are not intended as advocacy or cheer leading or as mascots. Instead, I would like the icons to capture succinctly key ideas.)

What is "the essence" of Bayesian data analysis? And what is "the essence" of frequentist data analysis? Any answer will surely provoke disagreement, but that is not my goal. The questions are earnest and often asked by beginners and by experienced practitioners alike. As an educator, I think that the questions deserve earnest answers, with the explicit caveat that they will be incomplete and subject to discussion and improvement. So, here goes.

The essence of Bayesian data analysis is inferring the uncertainty (i.e., relative credibility) of parameters in a model space, given the data. Therefore, an icon should represent the data, the form of the model space, and the credible parameters.

The simplest example I can think of is linear regression: Many people are familiar with x-y scatter plots as diagrams of data, and many people are familiar with lines as a model form. The credible parameters can then be suggested by a smattering of lines sampled from the posterior distribution, like this (Fig. 1):
Figure 1. An icon for Bayesian data analysis.
The icon in Figure 1 represents the data as black dots. The icon represents the model form by the obvious linearity of every trend line. The icon represents uncertainty, or relative credibility, by the obvious range of slopes and intercepts, with greater density in the middle of the quiver of lines. I like Figure 1 as a succinct representation of Bayesian analysis because the figure makes it visually obvious that there is a particular model space being considered, and that there is a range of credible possibilities in that space, given the data.

Are there infelicities in Figure 1? Of course. For example, the shape and scale of the noise distribution are not represented. But many ancillary details must be suppressed in any icon.

Perhaps a more important infelicity in Figure 1 is that the prior distribution is not represented, other than the form of the model space. That is, the lines indicate that the prior distribution puts zero probability on quadratic or sinusoidal or other curved trends, but the lines do not indicate the form of the prior distribution on the allowed parameters.

Some people may feel that this lack of representing the prior is a failure to capture an essential part of Bayesian data analysis. Perhaps, therefore, a better icon would include a representation of the prior -- maybe as a smattering of grey lines set behind the data and the blue posterior lines. For the vague prior used in this example, the prior would be a background of randomly criss-crossing grey lines, which might be confusing (and ugly).

Now, an analogous icon for frequentist data analysis.

The essence of frequentist data analysis is inferring the extremity of a data property in the space of possibilities sampled a specified way from a given hypothesis. (That is, inferring a p value.) Note that the data property is often defined with respect to a model family, such as the best fitting slope and intercept in linear regression. Therefore, an icon should represent the data, the data property, and space of possibilities sampled from the hypothesis (with the extremity of the data property revealed by its visual relation to the space of possibilities).

Keeping with the linear regression scenario, an icon for frequentist analysis might look like this (Fig. 2):
Figure 2. An icon for frequentist data analysis.
As before, the data are represented by black dots. The data property is represented by the single blue line, which shows the least-squares fit to the data. The space of possibilities is represented by the smattering of red lines, which were created as least-squares fits to randomly resampled x and y values (with replacement, using fixed sample size equal to the data sample size). In other words, the hypothesis here is a "null" hypothesis that there is no systematic covariation between the x and y values. I like Figure 2 as a succinct representation of frequentist data analysis, especially when juxtaposed with Figure 1, because Figure 2 shows that there is a point estimate to describe the data (i.e., the single blue line) and a sample of hypothetical descriptions unrelated to the data.

Are there infelicities in Figure 2? Of course. Perhaps the most obvious is that there is no representation of a confidence interval. In my opinion, to properly represent a confidence interval in the format of Figure 2, there would need to be two additional figures, one for each limit of the confidence interval. One additional figure would show a quiver of red lines generated from the lower limit of the confidence interval, which would show the single blue line among the 2.5% steepest red lines. The second additional figure would show a quiver of red lines generated from the upper limit of confidence interval, which would show the single blue line among the 2.5% shallowest red lines. The key is that there would be a single unchanged blue line in all three figures; what changes across figures is the quiver of red lines sampled from the changing hypothesis.

Well, there you have it. I should have been spending this Saturday morning on a thousand other pressing obligations (my apologies to colleagues who know what I'm referring to!). Hopefully it will have taken you less time to have read this far than it took me to have written this far.

Appended 12:30pm, 28 Dec 2013: My wife suggested that the red lines of the frequentist sampling distribution ought to be more distinct from the data, and from the best fitting line. So here are modified versions that might be better:

Description of data is the single blue line. Red lines show the sampling distribution from the null hypothesis.

Blue lines show the distribution of credible descriptions from the posterior.