Skip to content

discuss pinning parameters in workflow in User's Guide #942

@bob-carpenter

Description

@bob-carpenter

This is a request from "Somebody" on @andrewgelman's blog:

https://statmodeling.stat.columbia.edu/2026/05/04/expanding-the-stan-users-guide/#comment-2414300.

I'll summarize the first request here.

We should discuss the process of pinning parameters when doing development. This can make the models much faster to fit and also give us some hints at relevant hyper priors. For example, suppose we have a hierarchical model

data {
  int<lower=0> N;
}
parameters {
  vector[N] alpha;
  real<lower=0> sigma;
}
model {
  alpha ~ normal(0, sigma);
  sigma ~ ???
}

This is going to try to fit alpha and sigma and create a pure funnel posterior which has varying geometry and is not log concave.

We can replace this with a model with a fixed value, say sigma = 1.7. But this requires a new Stan model:

data {
  int<lower=0> N;
}
parameters {
  vector[N] alpha;
}
model {
  alpha ~ normal(0, 1.7);
}

If we fit this second model, we will get a posterior distribution over alpha. I have added a generated quantities block that shows how we can recover the actual scale of the parameter variation per draw, and hence get a posterior over it which can help inform our hyper prior on sigma.

generated quantities {
  real<lower=0> sigma_alpha = sd(alpha);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions