You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Stan's unit simplex inverse transform may be understood using the following
666
-
stick-breaking metaphor.[^transforms-1]
667
665
668
-
[^transforms-1]: For an alternative derivation of the same transform using
669
-
hyperspherical coordinates, see [@Betancourt:2010].
670
666
671
-
1. Take a stick of unit length (i.e., length 1).
672
-
2. Break a piece off and label it as $x_1$, and set it aside, keeping what's
673
-
left.
674
-
3. Next, break a piece off what's left, label it $x_2$, and set it aside,
675
-
keeping what's left.
676
-
4. Continue breaking off pieces of what's left, labeling them, and setting them
677
-
aside for pieces $x_3,\ldots,x_{K-1}$.
678
-
5. Label what's left $x_K$.
679
-
680
-
The resulting vector $x = [x_1,\ldots,x_{K}]^{\top}$ is a unit simplex because
681
-
each piece has non-negative length and the sum of the stick lengths is one by
682
-
construction.
683
-
684
-
This full inverse mapping requires the breaks to be represented as the fraction
685
-
in $(0,1)$ of the original stick that is broken off. These break ratios are
686
-
themselves derived from unconstrained values in $(-\infty,\infty)$ using the
687
-
inverse logit transform as described above for unidimensional variables with
688
-
lower and upper bounds.
689
-
690
-
More formally, an intermediate vector $z \in \mathbb{R}^{K-1}$, whose
691
-
coordinates $z_k$ represent the proportion of the stick broken off in step $k$,
692
-
is defined elementwise for $1 \leq k < K$ by
667
+
The length-$K$ unit simplex inverse transform is given by the softmax of a sum-to-zero vector of length $K$.
693
668
669
+
Let $y$ represent the unconstrained $K - 1$ values in $(-\infty, \infty)$. The intermediate sum-to-zero vector $z = \text{sum\_to\_zero\_transform}(y)$ is length $K$. The unit simplex is then given by
in the above definition adjusts the transform so that a zero vector $y$ is
704
-
mapped to the simplex $x = (1/K,\ldots,1/K)$. For instance, if $y_1 = 0$, then
705
-
$z_1 = 1/K$; if $y_2 = 0$, then $z_2 = 1/(K-1)$; and if $y_{K-1} = 0$, then
706
-
$z_{K-1} = 1/2$.
674
+
The sum-to-zero vector transform is described in further detail at the [sum-to-zero vector section of the *Reference Manual*](#sum-to-zero-vector-transform).
707
675
708
-
The break proportions $z$ are applied to determine the stick sizes and resulting
709
-
value of $x_k$ for $1 \leq k < K$ by
676
+
::: {.callout-note}
677
+
All versions of Stan pre-2.37 used the stick-breaking transform.
678
+
This is documented at [Stan 2.36 *Reference Manual: Simplex Transform*](https://mc-stan.org/docs/2_36/reference-manual/transforms.html#simplex-transform.section).
679
+
:::
710
680
711
-
$$
712
-
x_k =
713
-
\left( 1 - \sum_{k'=1}^{k-1} x_{k'} \right) z_k.
714
-
$$
681
+
#### Absolute Jacobian determinant of the unit-simplex inverse transform {-}
715
682
716
-
The summation term represents the length of the original stick left at stage
717
-
$k$. This is multiplied by the break proportion $z_k$ to yield $x_k$. Only $K-1$
718
-
unconstrained parameters are required, with the last dimension's value $x_K$ set
719
-
to the length of the remaining piece of the original stick,
683
+
The Jacobian $J$ of the inverse unit-simplex transform is found by
684
+
restricting $J$ to the subspace spanned by the sum-to-zero vector $z$.
685
+
The Jacobian is given as the $(K - 1) \times (K - 1)$ matrix $J$ where
0 commit comments