16.2 Normal-id generalized linear model (linear regression)
Stan also supplies a single function for a generalized linear lodel with normal likelihood and identity link function, i.e. a function for a linear regression. This provides a more efficient implementation of linear regression than a manually written regression in terms of a normal likelihood and matrix multiplication.
16.2.1 Probability distribution function
If \(x\in \mathbb{R}^{n\cdot m}, \alpha \in \mathbb{R}^n, \beta\in \mathbb{R}^m, \sigma\in \mathbb{R}^+\), then for \(y \in \mathbb{R}^n\), \[ \text{NormalIdGLM}(y|x, \alpha, \beta, \sigma) = \prod_{1\leq i \leq n}\text{Normal}(y_i|\alpha_i + x_i\cdot \beta, \sigma). \]
16.2.2 Sampling statement
y ~
normal_id_glm
(x, alpha, beta, sigma)
Increment target log probability density with normal_id_glm_lupdf(y | x, alpha, beta, sigma)
.
16.2.3 Stan functions
real
normal_id_glm_lpdf
(real y | matrix x, real alpha, vector beta, real sigma)
The log normal probability density of y
given location alpha + x * beta
and scale sigma
.
real
normal_id_glm_lupdf
(real y | matrix x, real alpha, vector beta, real sigma)
The log normal probability density of y
given location alpha + x * beta
and scale sigma
dropping constant additive terms.
real
normal_id_glm_lpdf
(real y | matrix x, vector alpha, vector beta, real sigma)
The log normal probability density of y
given location alpha + x * beta
and scale sigma
.
real
normal_id_glm_lupdf
(real y | matrix x, vector alpha, vector beta, real sigma)
The log normal probability density of y
given location alpha + x * beta
and scale sigma
dropping constant additive terms.
real
normal_id_glm_lpdf
(vector y | row_vector x, real alpha, vector beta, real sigma)
The log normal probability density of y
given location alpha + x * beta
and scale sigma
.
real
normal_id_glm_lupdf
(vector y | row_vector x, real alpha, vector beta, real sigma)
The log normal probability density of y
given location alpha + x * beta
and scale sigma
dropping constant additive terms.
real
normal_id_glm_lpdf
(vector y | row_vector x, vector alpha, vector beta, real sigma)
The log normal probability density of y
given location alpha + x * beta
and scale sigma
.
real
normal_id_glm_lupdf
(vector y | row_vector x, vector alpha, vector beta, real sigma)
The log normal probability density of y
given location alpha + x * beta
and scale sigma
dropping constant additive terms.
real
normal_id_glm_lpdf
(vector y | matrix x, real alpha, vector beta, real sigma)
The log normal probability density of y
given location alpha + x * beta
and scale sigma
.
real
normal_id_glm_lupdf
(vector y | matrix x, real alpha, vector beta, real sigma)
The log normal probability density of y
given location alpha + x * beta
and scale sigma
dropping constant additive terms.
real
normal_id_glm_lpdf
(vector y | matrix x, vector alpha, vector beta, real sigma)
The log normal probability density of y
given location alpha + x * beta
and scale sigma
.
real
normal_id_glm_lupdf
(vector y | matrix x, vector alpha, vector beta, real sigma)
The log normal probability density of y
given location alpha + x * beta
and scale sigma
dropping constant additive terms.