17.4 Negative-binomial-2-log generalized linear model (negative binomial regression)
Stan also supplies a single function for a generalized linear model with negative binomial likelihood and log link function, i.e. a function for a negative binomial regression. This provides a more efficient implementation of negative binomial regression than a manually written regression in terms of a negative binomial likelihood and matrix multiplication.
17.4.1 Probability mass function
If \(x\in \mathbb{R}^{n\cdot m}, \alpha \in \mathbb{R}^n, \beta\in \mathbb{R}^m, \phi\in \mathbb{R}^+\), then for \(y \in \mathbb{N}^n\), \[ \text{NegBinomial2LogGLM}(y~|~x, \alpha, \beta, \phi) = \prod_{1\leq i \leq n}\text{NegBinomial2}(y_i~|~\exp(\alpha_i + x_i\cdot \beta), \phi). \]
17.4.2 Sampling statement
y ~
neg_binomial_2_log_glm
(x, alpha, beta, phi)
Increment target log probability density with neg_binomial_2_log_glm_lupmf(y | x, alpha, beta, phi)
.
Available since 2.19
17.4.3 Stan functions
real
neg_binomial_2_log_glm_lpmf
(int y | matrix x, real alpha, vector beta, real phi)
The log negative binomial probability mass of y
given log-location
alpha + x * beta
and inverse overdispersion parameter phi
.
Available since 2.23
real
neg_binomial_2_log_glm_lupmf
(int y | matrix x, real alpha, vector beta, real phi)
The log negative binomial probability mass of y
given log-location
alpha + x * beta
and inverse overdispersion parameter phi
dropping constant additive terms.
Available since 2.25
real
neg_binomial_2_log_glm_lpmf
(int y | matrix x, vector alpha, vector beta, real phi)
The log negative binomial probability mass of y
given log-location
alpha + x * beta
and inverse overdispersion parameter phi
.
Available since 2.23
real
neg_binomial_2_log_glm_lupmf
(int y | matrix x, vector alpha, vector beta, real phi)
The log negative binomial probability mass of y
given log-location
alpha + x * beta
and inverse overdispersion parameter phi
dropping constant additive terms.
Available since 2.25
real
neg_binomial_2_log_glm_lpmf
(array[] int y | row_vector x, real alpha, vector beta, real phi)
The log negative binomial probability mass of y
given log-location
alpha + x * beta
and inverse overdispersion parameter phi
.
Available since 2.23
real
neg_binomial_2_log_glm_lupmf
(array[] int y | row_vector x, real alpha, vector beta, real phi)
The log negative binomial probability mass of y
given log-location
alpha + x * beta
and inverse overdispersion parameter phi
dropping constant additive terms.
Available since 2.25
real
neg_binomial_2_log_glm_lpmf
(array[] int y | row_vector x, vector alpha, vector beta, real phi)
The log negative binomial probability mass of y
given log-location
alpha + x * beta
and inverse overdispersion parameter phi
.
Available since 2.23
real
neg_binomial_2_log_glm_lupmf
(array[] int y | row_vector x, vector alpha, vector beta, real phi)
The log negative binomial probability mass of y
given log-location
alpha + x * beta
and inverse overdispersion parameter phi
dropping constant additive terms.
Available since 2.25
real
neg_binomial_2_log_glm_lpmf
(array[] int y | matrix x, real alpha, vector beta, real phi)
The log negative binomial probability mass of y
given log-location
alpha + x * beta
and inverse overdispersion parameter phi
.
Available since 2.18
real
neg_binomial_2_log_glm_lupmf
(array[] int y | matrix x, real alpha, vector beta, real phi)
The log negative binomial probability mass of y
given log-location
alpha + x * beta
and inverse overdispersion parameter phi
dropping constant additive terms.
Available since 2.25
real
neg_binomial_2_log_glm_lpmf
(array[] int y | matrix x, vector alpha, vector beta, real phi)
The log negative binomial probability mass of y
given log-location
alpha + x * beta
and inverse overdispersion parameter phi
.
Available since 2.18
real
neg_binomial_2_log_glm_lupmf
(array[] int y | matrix x, vector alpha, vector beta, real phi)
The log negative binomial probability mass of y
given log-location
alpha + x * beta
and inverse overdispersion parameter phi
dropping constant additive terms.
Available since 2.25