Affine transformation in Stan

To be a bit more concrete, the offset and multiplier code:

parameters {
  real<offset=mu,multiplier=sigma> x;
}
model {
  x ~ normal(mu, sigma);
}

Is equivalent to:

parameters {
  real x_raw;
}
transformed parameters {
  real x = mu + x_raw * sigma;
}
model {
  x_raw ~ std_normal();
}

It makes for a bit more of a concise way to specify a non-centered distribution, and also reduces the number of parameters to be saved (i.e. only need to save x, not x and x_raw) which can be very handy for large models/samples

2 Likes