Generalized linear models (GLM)

Gist

When an ordinary Linear regression (LM) regression doesn't cut it - maybe your response variable are whole integers or proportions bounded by [0,1]. Who you gonna call? Generalized linear model (GLM)

Mathematics

For an outcome Y, it is assumed to be generated from a distribution in the Exponential Family. The conditional mean μ depends on the independent variable X. Here:

E(Y|X)=μ=g1(Xβ),

where the expected value of Y conditioned on X is equal to μ which is also equal to a link function of the linear predictor: XB.

Why isn't just using a transformation better?

An interesting thing I found online was the question of: Okay, why can't we just log-transform the response variable like:

log(Y)=Xβ+ϵ.

The answer is that it it has to do with Jensen's inequality. The transformed model is actually estimating E(log(Y)|X)

Fitting

Done through Maximum likelihood

Binomial

Poisson

The link function for Poisson is a natural log

glm(Y~X, family = "poisson")

Note

Interpretation

References