Tutorials › Econometrics (Graduate) › Spike-And-Slab Priors For Bayesian Variable Selection

Bayesian Econometrics · Tutorial 888 of 952

Spike-And-Slab Priors For Bayesian Variable Selection

Specify spike-and-slab regression priors, calculate posterior inclusion probabilities, and interpret uncertainty about whether each coefficient belongs in the model.

Advanced 11 min read

What You'll Learn

  • Define binary inclusion indicators and spike-and-slab priors for regression coefficients.
  • Distinguish a coefficient’s posterior inclusion probability from its estimate conditional on inclusion.
  • Derive a one-coefficient Bayes factor for a Gaussian regression with a normal slab.
  • Calculate posterior inclusion probabilities from prior model weights and marginal likelihoods.
  • Represent coefficient uncertainty as a mixture of a point mass at zero and a continuous posterior.
  • Recognize how prior inclusion probabilities and dependence among predictors affect selection.

Why Put a Probability on Inclusion?

In a regression with many candidate predictors, it is often unclear which coefficients should be exactly zero and which should be estimated as nonzero. Selecting one specification and then reporting only its coefficient estimates hides uncertainty about that choice. A spike-and-slab prior makes inclusion itself part of the probability model: each coefficient has a point mass at zero, alongside a continuous distribution for values when it is included.

This construction gives a posterior probability for each inclusion indicator, as well as a posterior distribution for the coefficient. These answer different questions. The inclusion probability summarizes uncertainty about whether the coefficient is in the model; the conditional coefficient distribution describes its size and sign given inclusion.

Definition: For candidate regression coefficient \(\beta_j\), let \(\gamma_j\in\{0,1\}\) be its inclusion indicator. The spike-and-slab prior sets \(\beta_j=0\) when \(\gamma_j=0\), and assigns \(\beta_j\) a continuous prior distribution when \(\gamma_j=1\). The value \(\gamma_j=0\) is the spike; the continuous distribution is the slab.

Model and Prior Specification

Consider the Gaussian regression model \(y=\alpha\mathbf{1}+X\beta+\varepsilon\), where \(y\) is an \(n\)-vector of outcomes, \(X\) contains \(p\) candidate predictors, and \(\varepsilon\sim N(0,\sigma^2 I_n)\). The intercept \(\alpha\) is included in every specification here. For simplicity, first suppose \(\sigma^2\) is known. The same indicator construction applies when variance is unknown; then the model evidence integrates over its prior as well.

A common specification assigns each indicator an independent Bernoulli prior, \(\gamma_j\sim\mathrm{Bernoulli}(\pi_j)\), and uses a zero-centered normal slab. Conditional on the indicators, coefficients with \(\gamma_j=0\) are fixed at zero, while included coefficients receive the slab distribution. For example, \(\beta_j\mid\gamma_j=1\sim N(0,\tau_j^2)\). The slab variance controls the prior scale of included effects; it does not determine whether a coefficient is included.

$$ \beta_j\mid\gamma_j = \begin{cases} 0, & \gamma_j=0,\\ N(0,\tau_j^2), & \gamma_j=1, \end{cases} \qquad P(\gamma_j=1)=\pi_j. $$

Equivalently, the prior for \(\beta_j\) is a mixture with probability \(1-\pi_j\) concentrated exactly at zero and probability \(\pi_j\) distributed over the slab. Write \(\delta_0\) for a point mass at zero. Then the marginal prior is \((1-\pi_j)\delta_0+\pi_jN(0,\tau_j^2)\). With \(p\) indicators there are \(2^p\) possible inclusion configurations, often called models or specifications.

Posterior Inclusion Probabilities

For an indicator configuration \(\gamma=(\gamma_1,\ldots,\gamma_p)\), its marginal likelihood is the probability density of the observed data after integrating out the included coefficients and any other parameters given their priors. Denote it by \(m_\gamma(y)\). Bayes’ rule updates the prior probability of each configuration using this evidence.

$$ P(\gamma\mid y) = \frac{m_\gamma(y)P(\gamma)} {\displaystyle\sum_{\gamma'}m_{\gamma'}(y)P(\gamma')}, \qquad P(\gamma)=\prod_{j=1}^p \pi_j^{\gamma_j}(1-\pi_j)^{1-\gamma_j}. $$

The posterior inclusion probability for predictor \(j\) sums the probabilities of all configurations that include it. It is not generally obtained by comparing just two specifications: when there are several predictors, uncertainty about the others must also be accounted for.

$$ P(\gamma_j=1\mid y) = \sum_{\gamma:\gamma_j=1}P(\gamma\mid y). $$

For a single indicator, the update has a particularly simple form. Define the Bayes factor \(BF_{10}\) as the marginal likelihood under inclusion divided by the marginal likelihood under exclusion. Posterior odds equal prior odds multiplied by this Bayes factor.

$$ \frac{P(\gamma_j=1\mid y)}{P(\gamma_j=0\mid y)} = \frac{\pi_j}{1-\pi_j}BF_{10}, \qquad P(\gamma_j=1\mid y) = \frac{\pi_j BF_{10}}{(1-\pi_j)+\pi_j BF_{10}}. $$

A One-Coefficient Bayes Factor

A closed-form Bayes factor illustrates how the data and slab scale interact. Suppose the response has been residualized with respect to the intercept and any other regressors, and consider one candidate predictor \(x\). Assume the resulting model is \(y=x\beta+\varepsilon\), with \(\varepsilon\sim N(0,\sigma^2 I_n)\), known \(\sigma^2\), and slab \(\beta\mid\gamma=1\sim N(0,\tau^2)\). Under exclusion, \(\beta=0\). Let \(z=x'y/\sqrt{x'x}\) and \(r=\tau^2x'x/\sigma^2\).

Under exclusion, \(z\sim N(0,\sigma^2)\). Under inclusion, the prior uncertainty in \(\beta\) adds variance to \(z\), giving \(z\sim N(0,\sigma^2+\tau^2x'x)\). Taking the ratio of these normal densities gives the Bayes factor. This derivation assumes the single candidate predictor is orthogonal to the other regression terms after residualization; without that condition, the relevant conditional or joint marginal likelihood must be used.

$$ BF_{10} = \frac{\phi(z;0,\sigma^2+\tau^2x'x)} {\phi(z;0,\sigma^2)} = \frac{1}{\sqrt{1+r}} \exp\left\{ \frac{1}{2}\left(\frac{z}{\sigma}\right)^2 \frac{r}{1+r} \right\}. $$

The first factor penalizes the more diffuse alternative: its probability density is spread over a wider range. The exponential factor rewards an observed \(z\) that is relatively large under the null. Consequently, a larger standardized signal can favor inclusion, while a very diffuse slab can reduce evidence by spreading prior probability over effects not supported by the data.

Worked Example: Updating Inclusion and Coefficient Uncertainty

Suppose a hypothetical one-predictor regression has known residual variance \(\sigma^2=1\), \(x'x=100\), and a normal slab with \(\tau^2=0.04\). The observed standardized statistic is \(z/\sigma=2.5\), and the prior inclusion probability is \(\pi=0.20\). Assume the predictor is orthogonal to the other regression terms after residualization, as required for the displayed one-predictor calculation.

First calculate \(r=\tau^2x'x/\sigma^2=0.04(100)/1=4\). Therefore

$$ BF_{10} = \frac{1}{\sqrt{5}} \exp\left\{\frac{1}{2}(2.5)^2\frac{4}{5}\right\} = \frac{\exp(2.5)}{\sqrt{5}} \approx 5.448. $$

The prior odds are \(0.20/0.80=0.25\). The posterior odds are \(0.25(5.448)=1.362\), so the posterior inclusion probability is \(1.362/(1+1.362)\approx0.5767\). The data increase the probability of inclusion from 0.20 to about 0.5767, but do not make inclusion certain.

Conditional on inclusion, normal updating gives posterior variance \(\tau^2\sigma^2/(\sigma^2+\tau^2x'x)=0.04/5=0.008\), and posterior mean \(\tau^2x'y/(\sigma^2+\tau^2x'x)\). Since \(x'y=z\sqrt{x'x}=2.5(10)=25\), that mean is \(0.04(25)/5=0.20\). Thus the posterior for \(\beta\) is a mixture: it puts probability \(1-0.5767=0.4233\) exactly at zero and, with probability 0.5767, follows \(N(0.20,0.008)\). The coefficient is measured in the response units per unit of \(x\).

Combining Evidence Across Specifications

With more than one candidate predictor, posterior inclusion probabilities are obtained by summing model probabilities, not by fitting each coefficient in isolation. Marginal likelihoods incorporate the fit and prior uncertainty of the entire specification. In particular, two correlated predictors may explain similar parts of the outcome, so the evidence for including one can depend on whether the other is present.

Worked Example: Inclusion Probabilities for Two Predictors

Consider hypothetical predictors \(A\) and \(B\), with independent prior inclusion probabilities \(\pi_A=0.30\) and \(\pi_B=0.40\). Suppose integrating the regression likelihood and coefficient priors for the observed data gives the following marginal likelihoods, expressed relative to the model excluding both predictors: \(m_{00}=1\), \(m_{10}=3\), \(m_{01}=0.5\), and \(m_{11}=2\). The first indicator in each subscript refers to \(A\). These are assumed model-evidence inputs for this calculation.

The prior probabilities of models \(00,10,01,11\) are respectively \(0.70(0.60)=0.42\), \(0.30(0.60)=0.18\), \(0.70(0.40)=0.28\), and \(0.30(0.40)=0.12\). Multiplying each prior probability by its relative marginal likelihood gives unnormalized posterior weights \(0.42\), \(0.54\), \(0.14\), and \(0.24\). Their sum is \(1.34\).

$$ P(\gamma_A=1\mid y) = \frac{0.54+0.24}{1.34} = 0.5821, \qquad P(\gamma_B=1\mid y) = \frac{0.14+0.24}{1.34} = 0.2836. $$

The posterior probability that both predictors are included is \(0.24/1.34=0.1791\). These probabilities are calculated from the same four model weights; they are not separate tests of \(A\) and \(B\). In particular, \(A\)'s inclusion probability includes evidence from both models containing \(A\), whether or not \(B\) is also included.

What the Inclusion Probability Does—and Does Not—Say

Under the spike-and-slab prior, \(P(\gamma_j=1\mid y)\) is the posterior probability that the model includes coefficient \(j\), under the stated likelihood and priors. Because the slab is continuous, conditional on inclusion the prior assigns probability zero to the exact value \(\beta_j=0\). The posterior for \(\beta_j\) therefore combines an atom at zero with a continuous component. This is a direct way to quantify both model uncertainty and coefficient uncertainty.

A high inclusion probability does not by itself establish that a predictor has a large effect, that its effect has a particular sign, or that a causal relationship exists. For magnitude and sign, inspect the coefficient posterior conditional on inclusion or the full mixture posterior. Causal interpretation requires a causal design and assumptions beyond this prior construction.

Worked Example: Interpreting a Rounded Posterior Probability

Suppose a hypothetical comparison yields prior odds of \(1/3\) for inclusion and a Bayes factor of \(1.5864\) in favor of inclusion. The posterior odds are \((1/3)(1.5864)=0.5288\). Converting odds to probability gives

$$ P(\gamma=1\mid y) = \frac{0.5288}{1+0.5288} = \frac{0.5288}{1.5288} \approx 0.3459. $$

Thus, under this model and prior, the posterior inclusion probability is about 0.3459. It is not the probability that the null hypothesis is true in a frequentist sense, nor does it mean there is a 34.59% probability that a fixed coefficient changes value. It is a probability over the indicator in the specified Bayesian model.

Practical Choices and Common Pitfalls

Prior inclusion probabilities affect selection, especially when many predictors are considered. A common choice is a shared \(\pi_j=\pi\), but this implies a prior expected number of included predictors equal to \(p\pi\). For a large candidate set, a seemingly modest \(\pi\) can still imply a substantial expected model size. Slab scales also matter: if the slab is implausibly diffuse, marginal likelihoods can favor simpler models because the alternative spreads probability over a broad range of coefficient values. Prior sensitivity analysis should therefore examine plausible inclusion probabilities and slab scales.

  • Mistake: treating the most probable model as certain. Selecting the model with the largest posterior probability discards probability assigned to every other model. Report inclusion probabilities or other summaries that retain this uncertainty.
  • Mistake: interpreting an inclusion probability as effect size. A coefficient can have high inclusion probability but a small conditional magnitude. Examine its conditional or mixture posterior to describe size and sign.
  • Mistake: using separate one-predictor evidence when predictors are dependent. Correlated regressors can compete to explain the same variation. Use joint model evidence and sum over configurations, rather than assuming each predictor’s evidence is independent.
Key takeaway: A spike-and-slab prior assigns each coefficient an exact-zero state and a continuous included state. Posterior inclusion probabilities follow from prior model weights and marginal likelihoods, and they quantify model uncertainty rather than coefficient magnitude or causal certainty.

Check Your Understanding

Work through these questions using the definitions and calculations above.

  1. In a spike-and-slab prior, what distinguishes the spike from the slab?
  2. If a coefficient has prior inclusion probability \(0.25\) and Bayes factor \(2\), calculate its posterior inclusion odds and probability.
  3. Why must the posterior inclusion probability for one predictor sum probabilities over all configurations that include it?
  4. In the first worked example, what probability does the posterior assign exactly to \(\beta=0\), and why?
  5. Explain why a posterior inclusion probability is not, by itself, a measure of coefficient magnitude or a causal effect.
Clinical Biostats