This is an old version, view current version.

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 xRnm,αRn,βRm,ϕR+, then for yNn, NegBinomial2LogGLM(y | x,α,β,ϕ)=1inNegBinomial2(yi | exp(αi+xiβ),ϕ).

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.