@@ -307,12 +307,14 @@ implementation of softmax regression than a manually written
307307regression in terms of a Categorical likelihood and matrix
308308multiplication.
309309
310+ Note that the implementation does not put any restrictions on the coefficient matrix $\beta$. It is up to the user to use a reference category, a suitable prior or some other means of avoiding non-identifiability. See Multi-logit in the [ Stan User's Guide] ( https://mc-stan.org/docs/2_21/stan-users-guide/multi-logit-section.html ) .
311+
310312### Probability Mass Functions
311313
312314If $N,M,K \in \mathbb{N}$, $N,M,K > 0$, and if $x\in \mathbb{R}^{M\cdot K}, \alpha \in \mathbb{R}^N, \beta\in \mathbb{R}^{K\cdot N}$, then for $y \in \{ 1,\ldots,N\} ^M$,
313315\[ \text{CategoricalLogitGLM}(y~ |~ x,\alpha,\beta) = \\ [ 5pt]
314- \prod_ {1\leq i \leq M}\text{CategoricalLogit}(y_i~ |~ \alpha+\beta_i\ cdot x_i ) = \\ [ 15pt]
315- \prod_ {1\leq i \leq M}\text{Categorical}(y_i~ |~ softmax(\alpha+\beta_i\ cdot x_i )). \]
316+ \prod_ {1\leq i \leq M}\text{CategoricalLogit}(y_i~ |~ \alpha+x_i\ cdot\beta ) = \\ [ 15pt]
317+ \prod_ {1\leq i \leq M}\text{Categorical}(y_i~ |~ softmax(\alpha+x_i\ cdot\beta )). \]
316318See section [ softmax] ( #softmax ) for the definition of the softmax function.
317319
318320### Sampling Statement
@@ -333,7 +335,7 @@ dropping constant additive terms.
333335` real ` ** ` categorical_logit_glm_lpmf ` ** ` (int y | row_vector x, vector alpha, matrix beta) ` <br >\newline
334336The log categorical probability mass function with outcome ` y ` in
335337$1: N $ given $N$-vector of log-odds of outcomes ` alpha + x * beta ` .
336- The size of independant variable row vector ` x ` needs to match the number of rows of the
338+ The size of independent variable row vector ` x ` needs to match the number of rows of the
337339weight matrix ` beta ` . The size of intercept vector ` alpha ` must match number
338340of columns of the weight matrix ` beta ` .
339341
@@ -344,7 +346,7 @@ of columns of the weight matrix `beta`.
344346The log categorical probability mass function with outcomes ` y ` in
345347$1: N $ given $N$-vector of log-odds of outcomes ` alpha + x * beta ` .
346348Same vector of intercepts ` alpha ` and same dependant variable value ` y ` are used for all instances.
347- The number of columns of independant variable ` x ` needs to match the number of rows of the
349+ The number of columns of independent variable ` x ` needs to match the number of rows of the
348350weight matrix ` beta ` . The size of intercept vector ` alpha ` must match number
349351of columns of the weight matrix ` beta ` . If ` x ` and ` y ` are data (not parameters) this function can be executed on a GPU.
350352
@@ -354,8 +356,8 @@ of columns of the weight matrix `beta`. If `x` and `y` are data (not parameters)
354356` real ` ** ` categorical_logit_glm_lpmf ` ** ` (int[] y | row_vector x, vector alpha, matrix beta) ` <br >\newline
355357The log categorical probability mass function with outcomes ` y ` in
356358$1: N $ given $N$-vector of log-odds of outcomes ` alpha + x * beta ` .
357- Same vector of intercepts ` alpha ` and same row vector of independant variables ` x ` are used for all instances.
358- The size of independant variable matrix ` x ` needs to match the number of rows of the
359+ Same vector of intercepts ` alpha ` and same row vector of independent variables ` x ` are used for all instances.
360+ The size of independent variable matrix ` x ` needs to match the number of rows of the
359361weight vector ` beta ` . The size of intercept vector ` alpha ` must match number
360362of columns of the weight vector ` beta ` .
361363
@@ -368,7 +370,7 @@ $1:N$ given $N$-vector of log-odds of outcomes `alpha + x * beta`.
368370Same vector of intercepts ` alpha ` is used for all instances.
369371The number of rows of the independent variable
370372matrix ` x ` needs to match the length of the dependent variable vector
371- ` y ` . The number of columns of independant variable ` x ` needs to match the number of rows of the
373+ ` y ` . The number of columns of independnt variable ` x ` needs to match the number of rows of the
372374weight matrix ` beta ` . The size of intercept vector ` alpha ` must match number
373375of columns of the weight matrix ` beta ` . If ` x ` and ` y ` are data (not parameters) this function can be executed on a GPU.
374376
@@ -451,25 +453,25 @@ dropping constant additive terms.
451453
452454` real ` ** ` ordered_logistic_glm_lpmf ` ** ` (int y | row_vector x, vector beta, vector c) ` <br >\newline
453455The log ordered logistic probability mass of y, given linear predictors ` x * beta ` , and cutpoints c.
454- The size of independant variable row vector ` x ` needs to match the size of the weight vector ` beta ` .
456+ The size of independent variable row vector ` x ` needs to match the size of the weight vector ` beta ` .
455457Cutpoints ` c ` must be ordered.
456458
457459<!-- real; ordered_logistic_glm_lpmf; (int y | matrix x, vector beta, vector c); -->
458460\index{{\tt \bfseries ordered\_ logistic\_ glm\_ lpmf }!{\tt (int y \textbar\ matrix x, vector beta, vector c): real}|hyperpage}
459461
460462` real ` ** ` ordered_logistic_glm_lpmf ` ** ` (int y | matrix x, vector beta, vector c) ` <br >\newline
461463The log ordered logistic probability mass of y, given linear predictors ` x * beta ` , and cutpoints c.
462- Same value of independant variable ` y ` is used for all instances.
463- The number of columns of independant variable row vector ` x ` needs to match the size of the weight vector ` beta ` .
464+ Same value of independent variable ` y ` is used for all instances.
465+ The number of columns of independent variable row vector ` x ` needs to match the size of the weight vector ` beta ` .
464466Cutpoints ` c ` must be ordered. If ` x ` and ` y ` are data (not parameters) this function can be executed on a GPU.
465467
466468<!-- real; ordered_logistic_glm_lpmf; (int[] y | row_vector x, vector beta, vector c); -->
467469\index{{\tt \bfseries ordered\_ logistic\_ glm\_ lpmf }!{\tt (int[ ] y \textbar\ row\_ vector x, vector beta, vector c): real}|hyperpage}
468470
469471` real ` ** ` ordered_logistic_glm_lpmf ` ** ` (int[] y | row_vector x, vector beta, vector c) ` <br >\newline
470472The log ordered logistic probability mass of y, given linear predictors ` x * beta ` , and cutpoints c.
471- Same row vector of independant variables ` x ` is used for all instances.
472- The size of independant variable row vector ` x ` needs to match the size of the weight vector ` beta ` .
473+ Same row vector of independent variables ` x ` is used for all instances.
474+ The size of independent variable row vector ` x ` needs to match the size of the weight vector ` beta ` .
473475Cutpoints ` c ` must be ordered.
474476
475477<!-- real; ordered_logistic_glm_lpmf; (int[] y | matrix x, vector beta, vector c); -->
@@ -479,7 +481,7 @@ Cutpoints `c` must be ordered.
479481The log ordered logistic probability mass of y, given linear predictors
480482` x * beta ` , and cutpoints c.
481483The number of rows of the independent variable matrix ` x ` needs to match the length of the dependent variable vector ` y ` .
482- The number of columns of independant variable row vector ` x ` needs to match the size of the weight vector ` beta ` .
484+ The number of columns of independent variable row vector ` x ` needs to match the size of the weight vector ` beta ` .
483485Cutpoints ` c ` must be ordered. If ` x ` and ` y ` are data (not parameters) this function can be executed on a GPU.
484486
485487
0 commit comments