What is the purpose of "transformed variables" in Stan? 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? 
 A: Objects declared in the transformed parameters block of a Stan program are:


*

*Unknown but are known given the values of the objects in the parameters block

*Saved in the output and hence should be of interest to the researcher

*Are usually the arguments to the log-likelihood function that is evaluated in the model block, although in hierarchical models the line between the prior and the likelihood can be drawn in multiple ways


(if the third point is not the case, the object should usually be declared in the generated quantities block of a Stan program)
The purpose of declaring such things in the transformed parameters block rather than the parameters block is often to obtain more efficient sampling from the posterior distribution. If there is a posterior PDF $f\left(\left.\boldsymbol{\theta}\right|\mbox{data}\right)$, then for any bijective transformation from $\boldsymbol{\alpha}$ to $\boldsymbol{\theta}$, the posterior PDF of $\boldsymbol{\alpha}$ is simply $f\left(\left.\boldsymbol{\theta}\left(\boldsymbol{\alpha}\right)\right|\mbox{data}\right)\mathrm{abs}\left|\mathbf{J}\right|$, where $\left|\mathbf{J}\right|$ is the determinant of the Jacobian matrix of the transformation from $\boldsymbol{\alpha}$ to $\boldsymbol{\theta}$. Thus, you can make the same inferences about (functions of) $\boldsymbol{\theta}$ either by drawing from the posterior whose PDF is $f\left(\left.\boldsymbol{\theta}\right|\mbox{data}\right)$ where $\boldsymbol{\theta}$ are the parameters or the posterior whose PDF is $f\left(\left.\boldsymbol{\theta}\left(\boldsymbol{\alpha}\right)\right|\mbox{data}\right)\mathrm{abs}\left|\mathbf{J}\right|$ where $\boldsymbol{\alpha}$ are parameters and $\boldsymbol{\theta}$ are transformed parameters. Since the posterior inferences about (functions of) $\boldsymbol{\theta}$ are the same, you are free to choose a transformation that enhances the efficiency of the sampling by making $\boldsymbol{\alpha}$ less correlated, unit scaled, more Gaussian, etc. than is $\boldsymbol{\theta}$.
