14.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.
14.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). \]
14.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)
.
14.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
.
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.
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
.
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.
real
neg_binomial_2_log_glm_lpmf
(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
.
real
neg_binomial_2_log_glm_lupmf
(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.
real
neg_binomial_2_log_glm_lpmf
(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
.
real
neg_binomial_2_log_glm_lupmf
(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.
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
.
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.
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
.
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.