Modeled and Unmodeled Data

Summary

A short but load-bearing section: a five-way taxonomy of the variables in a Stan program, and the strict order in which they must be fixed or simulated to produce a prior predictive draw. The key observation is that Stan itself does not distinguish among these categories — it only separates data from parameters — so the ordering is knowledge the analyst must supply, and every prior-predictive or SBC procedure in the book depends on getting it right.

Overview

“For a fully generative model, simulation from the joint distribution is direct: simulate parameters from their prior and simulate data from the data model.” But as established in A Data Model Is Not Just a Likelihood, the data distribution is not just the likelihood.

The complication

“Almost all the models we fit include numbers that must be externally supplied and cannot be simulated. These include unmodeled data, unmodeled parameters, and parameters with improper prior distributions.”

Main Content

The worked example

data {
  int N;
  vector[N] x, y;
  real mu_a, mu_b;
  real<lower=0> sigma_a, sigma_b;
}
parameters {
  real a, b;
  real<lower=0> sigma_y;
}
model {
  a ~ normal(mu_a, sigma_a);
  b ~ normal(mu_b, sigma_b);
  y ~ normal(a + b*x, sigma_y);
}

Five categories of variable (Ch. 5.8, p. 89)

#CategoryIn this programCharacter
1Unmodeled dataN, xmust be externally supplied; no generative model
2Unmodeled parametersmu_a, mu_b, sigma_a, sigma_bhyperprior constants passed in as data
3Parameters with improper priorssigma_ydeclared but never given a ~ statement, so implicitly uniform
4Modeled parametersa, bdrawn from their prior
5Modeled dataydrawn from the data model given the parameters

“The Stan program does not distinguish among all these categories, except for separately declaring data and parameters.”

Note that categories 1-2 both live in the data block though they are conceptually different (one is observed data, the other is prior specification), and categories 3-4 both live in parameters though only category 4 can be simulated.

The required order of simulation

Prior predictive simulation must proceed in category order (Ch. 5.8, p. 89)

“The generative model requires more structure than is contained in the posterior distribution. In prior predictive simulation, the variables should be specified in the above order:

  1. Choose values for the unmodeled data (N, x)
  2. Choose values for the unmodeled parameters (mu_a, mu_b, sigma_a, sigma_b)
  3. Choose values for the parameters with improper priors (sigma_y)
  4. Simulate the modeled parameters from their prior distribution (a, b)
  5. Simulate the modeled data given the simulated parameters (y)”

The loop structure that follows: “By keeping steps 1-3 fixed and repeating steps 4 and 5 many times, you obtain a set of draws from the prior predictive distribution — the joint distribution of parameters and data — that represent a range of possibilities of the generative model conditional on the values specified in the first three steps.”

Two things to look at, not one: “The prior predictive simulations can be compared to observed data, and the simulations of the modeled parameters can also be examined to get a better understanding of how the model works.”

Why this ordering is a practical constraint, not a formality

Steps 1-3 being fixed across draws is what makes the prior predictive distribution conditional. Every prior predictive check in the book therefore answers the question “what does this model imply given this design?” — not “what data could this model produce in general.”

Concretely: in Prior Predictive Checking the logistic-regression check reuses the observed values for the 32 students from Chapter 4 rather than simulating new ones, because there is no generative model for . If you do want new predictors, “you might need to simulate the values using some model, even if it is just ” — which is a decision to move from category 1 to category 5, i.e. a step up the ladder in The ladder of generativity.

The same constraint governs SBC: see The SBC Algorithm, where and the design must be held fixed across all replications for the rank statistics to be comparable.

Connections

See Also