GLM Preface¶
Definition¶
Revisiting OLS (ordinary least squares):
We know that we have a dataset with \(n\) samples: \(D = \{ (\mathbf{x_{i}}, y_{i}) \}_{i=1}^n\), where we assumed \(D\) was drawn from the distribution:
We also assumed that the underlying relationship between the features and targets were linear:
We want to generalize this formulation; thus, we separate the underlying linear relationship between the features and targets from the fact that Y was normally distributed. So we can write:
1 corresponds the fact that Y is normally distributed with a mean dependent on the feature vector. 2 corresponds to the relationship between the features and target, formalized with \(\mathbf{x \omega}\).
By separating these two things, we can have Y be drawn from different distributions, and the underlying relationship between features and target need not be linear.
Example¶
Suppose we want to solve a problem, where it's more reasonable to say that the target variabe \(y\) was drawn from a Poisson distribution.
Then we can easily say:
where \(\lambda\) is the mean of the distribution: \(\mathbb{E}[Y|\mathbf{x}] = \lambda\).
\(\mathbb{E}[Y|\mathbf{x}] = \lambda\) formalizes the relationship between the features and target, but we need to rewrite in terms of the feature \(\mathbf{x}\). Since \(\lambda > 0\) we cannot model \(\lambda = \mathbf{xw} \in \mathbb{R}\), since it can go negative.
However, we can say: \(\lambda = \exp(\mathbf{xw})\). In our example \(g = \exp()\), where \(g\) is the exponential transfer.
Then our formulation will be:
Note that when using MLE, we can only use gradient descent since the MLE for this distribution does not have a closed form solution.
References¶
Ordinary Least Squares (OLS) Generalized Linear Models (GLM)