diff --git a/src/functions-reference/bounded_discrete_distributions.Rmd b/src/functions-reference/bounded_discrete_distributions.Rmd index a97d9bb39..152694ed0 100644 --- a/src/functions-reference/bounded_discrete_distributions.Rmd +++ b/src/functions-reference/bounded_discrete_distributions.Rmd @@ -158,7 +158,7 @@ logit-scaled chance of success alpha dropping constant additive terms ## Binomial-logit generalized linear model (Logistic Regression) {#binomial-logit-glm} Stan also supplies a single function for a generalized linear model -with Binomial likelihood and logit link function, i.e. a function +with binomial likelihood and logit link function, i.e., a function for logistic regression with aggregated outcomes. This provides a more efficient implementation of logistic regression than a manually written regression in terms of a Binomial likelihood and matrix @@ -167,10 +167,11 @@ multiplication. ### Probability mass function Suppose $N \in \mathbb{N}$, $x\in \mathbb{R}^{n\cdot m}, \alpha \in \mathbb{R}^n, \beta \in \mathbb{R}^m$, and $n \in -\{0,\ldots,N\}$. Then \begin{align*} -&\text{BinomialLogitGLM}(n~|~N, x, \alpha, \beta) = \text{Binomial}(n~|~N,\text{logit}^{-1}(\alpha_i + x_i\cdot -\beta)) \\ &= \binom{N}{n} \left( \text{logit}^{-1}(\alpha_i + \sum_{1\leq j\leq m}x_{ij}\cdot \beta_j) \right)^{n} \left( 1 - -\text{logit}^{-1}(\alpha_i + \sum_{1\leq j\leq m}x_{ij}\cdot \beta_j) \right)^{N - n}. \end{align*} +\{0,\ldots,N\}$. Then +\begin{align*} + &\text{BinomialLogitGLM}(n~|~N, x, \alpha, \beta) = \text{Binomial}(n~|~N,\text{logit}^{-1}(\alpha_i + x_i \cdot \beta)) \\ + &= \binom{N}{n} \left( \text{logit}^{-1}(\alpha_i + \sum_{1\leq j\leq m}x_{ij}\cdot \beta_j) \right)^{n} \left( 1 - \text{logit}^{-1}(\alpha_i + \sum_{1\leq j\leq m}x_{ij}\cdot \beta_j) \right)^{N - n}. +\end{align*} ### Sampling statement @@ -188,7 +189,7 @@ Increment target log probability density with `binomial_logit_glm_lupmf(n | N, x \index{{\tt \bfseries binomial\_logit\_glm\_lpmf }!{\tt (int n \textbar\ int N, matrix x, real alpha, vector beta): real}|hyperpage} `real` **`binomial_logit_glm_lpmf`**`(int n | int N, matrix x, real alpha, vector beta)`
\newline -The log Binomial probability mass of n given N trials and chance of success +The log binomial probability mass of n given N trials and chance of success `inv_logit(alpha + x * beta)`. `r since("2.34")` @@ -196,7 +197,7 @@ The log Binomial probability mass of n given N trials and chance of success \index{{\tt \bfseries binomial\_logit\_glm\_lupmf }!{\tt (int n \textbar\ int N, matrix x, real alpha, vector beta): real}|hyperpage} `real` **`binomial_logit_glm_lupmf`**`(int n | int N, matrix x, real alpha, vector beta)`
\newline -The log Binomial probability mass of n given N trials and chance of success +The log binomial probability mass of n given N trials and chance of success `inv_logit(alpha + x * beta)` dropping constant additive terms. `r since("2.34")` @@ -204,7 +205,7 @@ The log Binomial probability mass of n given N trials and chance of success \index{{\tt \bfseries binomial\_logit\_glm\_lpmf }!{\tt (int n \textbar\ int N, matrix x, vector alpha, vector beta): real}|hyperpage} `real` **`binomial_logit_glm_lpmf`**`(int n | int N, matrix x, vector alpha, vector beta)`
\newline -The log Binomial probability mass of n given N trials and chance of success +The log binomial probability mass of n given N trials and chance of success `inv_logit(alpha + x * beta)`. `r since("2.34")` @@ -212,7 +213,7 @@ The log Binomial probability mass of n given N trials and chance of success \index{{\tt \bfseries binomial\_logit\_glm\_lupmf }!{\tt (int n \textbar\ int N, matrix x, vector alpha, vector beta): real}|hyperpage} `real` **`binomial_logit_glm_lupmf`**`(int n | int N, matrix x, vector alpha, vector beta)`
\newline -The log Binomial probability mass of n given N trials and chance of success +The log binomial probability mass of n given N trials and chance of success `inv_logit(alpha + x * beta)` dropping constant additive terms. `r since("2.34")` @@ -220,7 +221,7 @@ The log Binomial probability mass of n given N trials and chance of success \index{{\tt \bfseries binomial\_logit\_glm\_lpmf }!{\tt (array[] int n \textbar\ array[] int N, row\_vector x, real alpha, vector beta): real}|hyperpage} `real` **`binomial_logit_glm_lpmf`**`(array[] int n | array[] int N, row_vector x, real alpha, vector beta)`
\newline -The log Binomial probability mass of n given N trials and chance of success +The log binomial probability mass of n given N trials and chance of success `inv_logit(alpha + x * beta)`. `r since("2.34")` @@ -228,7 +229,7 @@ The log Binomial probability mass of n given N trials and chance of success \index{{\tt \bfseries binomial\_logit\_glm\_lupmf }!{\tt (array[] int n \textbar\ array[] int N, row\_vector x, real alpha, vector beta): real}|hyperpage} `real` **`binomial_logit_glm_lupmf`**`(array[] int n | array[] int N, row_vector x, real alpha, vector beta)`
\newline -The log Binomial probability mass of n given N trials and chance of success +The log binomial probability mass of n given N trials and chance of success `inv_logit(alpha + x * beta)` dropping constant additive terms. `r since("2.34")` @@ -236,7 +237,7 @@ The log Binomial probability mass of n given N trials and chance of success \index{{\tt \bfseries binomial\_logit\_glm\_lpmf }!{\tt (array[] int n \textbar\ array[] int N, row\_vector x, vector alpha, vector beta): real}|hyperpage} `real` **`binomial_logit_glm_lpmf`**`(array[] int n | array[] int N, row_vector x, vector alpha, vector beta)`
\newline -The log Binomial probability mass of n given N trials and chance of success +The log binomial probability mass of n given N trials and chance of success `inv_logit(alpha + x * beta)`. `r since("2.34")` @@ -244,7 +245,7 @@ The log Binomial probability mass of n given N trials and chance of success \index{{\tt \bfseries binomial\_logit\_glm\_lupmf }!{\tt (array[] int n \textbar\ array[] int N, row\_vector x, vector alpha, vector beta): real}|hyperpage} `real` **`binomial_logit_glm_lupmf`**`(array[] int n | array[] int N, row_vector x, vector alpha, vector beta)`
\newline -The log Binomial probability mass of n given N trials and chance of success +The log binomial probability mass of n given N trials and chance of success `inv_logit(alpha + x * beta)` dropping constant additive terms. `r since("2.34")` @@ -253,7 +254,7 @@ The log Binomial probability mass of n given N trials and chance of success \index{{\tt \bfseries binomial\_logit\_glm\_lpmf }!{\tt (array[] int n \textbar\ array[] int N, matrix x, real alpha, vector beta): real}|hyperpage} `real` **`binomial_logit_glm_lpmf`**`(array[] int n | array[] int N, matrix x, real alpha, vector beta)`
\newline -The log Binomial probability mass of n given N trials and chance of success +The log binomial probability mass of n given N trials and chance of success `inv_logit(alpha + x * beta)`. `r since("2.34")` @@ -261,7 +262,7 @@ The log Binomial probability mass of n given N trials and chance of success \index{{\tt \bfseries binomial\_logit\_glm\_lupmf }!{\tt (array[] int n \textbar\ array[] int N, matrix x, real alpha, vector beta): real}|hyperpage} `real` **`binomial_logit_glm_lupmf`**`(array[] int n | array[] int N, matrix x, real alpha, vector beta)`
\newline -The log Binomial probability mass of n given N trials and chance of success +The log binomial probability mass of n given N trials and chance of success `inv_logit(alpha + x * beta)` dropping constant additive terms. `r since("2.34")` @@ -269,7 +270,7 @@ The log Binomial probability mass of n given N trials and chance of success \index{{\tt \bfseries binomial\_logit\_glm\_lpmf }!{\tt (array[] int n \textbar\ array[] int N, matrix x, vector alpha, vector beta): real}|hyperpage} `real` **`binomial_logit_glm_lpmf`**`(array[] int n | array[] int N, matrix x, vector alpha, vector beta)`
\newline -The log Binomial probability mass of n given N trials and chance of success +The log binomial probability mass of n given N trials and chance of success `inv_logit(alpha + x * beta)`. `r since("2.34")` @@ -277,7 +278,7 @@ The log Binomial probability mass of n given N trials and chance of success \index{{\tt \bfseries binomial\_logit\_glm\_lupmf }!{\tt (array[] int n \textbar\ array[] int N, matrix x, vector alpha, vector beta): real}|hyperpage} `real` **`binomial_logit_glm_lupmf`**`(array[] int n | array[] int N, matrix x, vector alpha, vector beta)`
\newline -The log Binomial probability mass of n given N trials and chance of success +The log binomial probability mass of n given N trials and chance of success `inv_logit(alpha + x * beta)` dropping constant additive terms. `r since("2.34")`