15.3 Bernoulli-logit generalized linear model (Logistic Regression)
Stan also supplies a single function for a generalized linear model with Bernoulli likelihood and logit link function, i.e. a function for a logistic regression. This provides a more efficient implementation of logistic regression than a manually written regression in terms of a Bernoulli likelihood and matrix multiplication.
15.3.1 Probability mass function
If x∈Rn⋅m,α∈Rn,β∈Rm, then for y∈{0,1}n, BernoulliLogitGLM(y | x,α,β)=∏1≤i≤nBernoulli(yi | logit−1(αi+xi⋅β))=∏1≤i≤n{logit−1(αi+∑1≤j≤mxij⋅βj)if yi=1, and1−logit−1(αi+∑1≤j≤mxij⋅βj)if yi=0.
15.3.2 Sampling statement
y ~
bernoulli_logit_glm
(x, alpha, beta)
Increment target log probability density with bernoulli_logit_glm_lupmf(y | x, alpha, beta)
.
Available since 2.25
15.3.3 Stan Functions
real
bernoulli_logit_glm_lpmf
(int y | matrix x, real alpha, vector beta)
The log Bernoulli probability mass of y given chance of success
inv_logit(alpha + x * beta)
.
Available since 2.23
real
bernoulli_logit_glm_lupmf
(int y | matrix x, real alpha, vector beta)
The log Bernoulli probability mass of y given chance of success
inv_logit(alpha + x * beta)
dropping constant additive terms.
Available since 2.25
real
bernoulli_logit_glm_lpmf
(int y | matrix x, vector alpha, vector beta)
The log Bernoulli probability mass of y given chance of success
inv_logit(alpha + x * beta)
.
Available since 2.23
real
bernoulli_logit_glm_lupmf
(int y | matrix x, vector alpha, vector beta)
The log Bernoulli probability mass of y given chance of success
inv_logit(alpha + x * beta)
dropping constant additive terms.
Available since 2.25
real
bernoulli_logit_glm_lpmf
(array[] int y | row_vector x, real alpha, vector beta)
The log Bernoulli probability mass of y given chance of success
inv_logit(alpha + x * beta)
.
Available since 2.23
real
bernoulli_logit_glm_lupmf
(array[] int y | row_vector x, real alpha, vector beta)
The log Bernoulli probability mass of y given chance of success
inv_logit(alpha + x * beta)
dropping constant additive terms.
Available since 2.25
real
bernoulli_logit_glm_lpmf
(array[] int y | row_vector x, vector alpha, vector beta)
The log Bernoulli probability mass of y given chance of success
inv_logit(alpha + x * beta)
.
Available since 2.23
real
bernoulli_logit_glm_lupmf
(array[] int y | row_vector x, vector alpha, vector beta)
The log Bernoulli probability mass of y given chance of success
inv_logit(alpha + x * beta)
dropping constant additive terms.
Available since 2.25
real
bernoulli_logit_glm_lpmf
(array[] int y | matrix x, real alpha, vector beta)
The log Bernoulli probability mass of y given chance of success
inv_logit(alpha + x * beta)
.
Available since 2.18
real
bernoulli_logit_glm_lupmf
(array[] int y | matrix x, real alpha, vector beta)
The log Bernoulli probability mass of y given chance of success
inv_logit(alpha + x * beta)
dropping constant additive terms.
Available since 2.25
real
bernoulli_logit_glm_lpmf
(array[] int y | matrix x, vector alpha, vector beta)
The log Bernoulli probability mass of y given chance of success
inv_logit(alpha + x * beta)
.
Available since 2.18
real
bernoulli_logit_glm_lupmf
(array[] int y | matrix x, vector alpha, vector beta)
The log Bernoulli probability mass of y given chance of success
inv_logit(alpha + x * beta)
dropping constant additive terms.
Available since 2.25
array[] int
bernoulli_logit_glm_rng
(matrix x, vector alpha, vector beta)
Generate an array of Bernoulli variates with chances of success
inv_logit(alpha + x * beta)
; may only be used in transformed data and generated
quantities blocks.
Available since 2.29
array[] int
bernoulli_logit_glm_rng
(row_vector x, vector alpha, vector beta)
Generate an array of Bernoulli variates with chances of success
inv_logit(alpha + x * beta)
; may only be used in transformed data and generated
quantities blocks.
Available since 2.29