I find references to transformed values in the Stan Reference and User Guides, and example code but no clear tutorial explanation. I'd be grateful for a link.
Michael Betancourt, in his Stan Modeling Language lecture, says this:
"The transformed parameters block allows for parameter processing before the posterior is computed"
And he offers this example:
transformed parameters {
real<lower=0> lambda;
lambda <- lambda1 + lambda2;
}
Andrew Gelman in his Intro to Bayesian Data Analysis and Stan, offers this example:
parameters {
real b;
real<lower=0> sigma_a;
real<lower=0> sigma_y;
vector[nteams] eta_a;
}
transformed parameters {
vector[nteams] eta_a;
a = b*prior_scores + sigma_a*eta_a;
}
model {
eta_a ~ normal(0,1);
sqrt_dif ~ student_t(df, a[team1] - a[team2], sigma_y);
}
At times, lecturers talk of the transformed parameters block as though it were nothing but initialization code run at the beginning of the fitting process, but at other times, they talk of it in ways more appropriate for its hi-falutin title of "transformed" parameters, as if this were some kind of kernel or other transformation that makes the calculations more tractable or that maps them into, say, a linear space, or that constrains them to manageable intervals in ways similar to a logit()
or exp()
.
What's the theoretical vision or purpose behind a special section for "transformed" parameters?