13.7 Poisson-Log Generalised Linear Model (Poisson Regression)
Stan also supplies a single primitive for a Generalised Linear Model with poisson likelihood and log link function, i.e. a primitive for a poisson regression. This should provide a more efficient implementation of poisson regression than a manually written regression in terms of a poisson likelihood and matrix multiplication.
13.7.1 Probability Mass Function
If x∈Rn⋅m,α∈Rn,β∈Rm, then for y∈Nn, PoisonLogGLM(y|x,α,β)=∏1≤i≤nPoisson(yi|exp(αi+xi⋅β)).
13.7.2 Sampling Statement
y ~
poisson_log_glm
(x, alpha, beta)
Increment target log probability density with poisson_log_glm_lpmf( y | x, alpha, beta)
dropping constant additive terms.
13.7.3 Stan Functions
real
poisson_log_glm_lpmf
(int[] y | matrix x, real alpha, vector beta)
The log poisson probability mass of y given log-rate alpha+x*beta
,
where a constant intercept alpha
is used for all observations. The
number of rows of the independent variable matrix x
needs to match
the length of the dependent variable vector y
and the number of
columns of x
needs to match the length of the weight vector beta
.
real
poisson_log_glm_lpmf
(int[] y | matrix x, vector alpha, vector beta)
The log poisson probability mass of y given log-rate alpha+x*beta
,
where an intercept alpha
is used that is allowed to vary with the
different observations. The number of rows of the independent variable
matrix x
needs to match the length of the dependent variable vector
y
and the number of columns of x
needs to match the length of the
weight vector beta
.