So far, we have mostly focused on continuous and unconstrained dependent variables, i.e. \(Y \in \mathbb{R}\). However, many interesting variables are limited in some form.
Probabilities range from 0 to 1
GDP is a positive variable
Political orientation is a categorical variable
Until now, we have treated these variables as approximately continuous, but this may cause severe issues.
A solution is to use specialised limited dependent variable (LDV) models.
Example of LDVs
We can distinguish between classification and regression.
Classification: we speak of a classification model when the outcome is
Binary: pass vs. fail, good vs. bad, sick vs. not, employed vs. unemployed
Categorical: nationality, dog breeds, means of transport; or ordinal: good – okay – bad
Regression: we speak of a regression model when the outcome is
Censored, truncated, or positive: wages, wealth, time
Count data: number of votes, days since an accident
Regression is generally used in a broader sense and may encompass classification.
The Linear Probability Model is an OLS regression applied to a binary dependent variable \(\boldsymbol{y} \in \{0,1\}\) as in:
\[
Y =
\begin{cases}
1 & \text{with probability } p,\\[6pt]
0 & \text{with probability } 1 - p.
\end{cases}
\]
The model: \[
\boldsymbol{y} = \boldsymbol{X}\beta + \boldsymbol{u}
\]
The expected value of the dependent variable is equal to the probability \(p\) that \(\boldsymbol{y} = 1\).
Conditional on the regressor \(\boldsymbol{X}\), we have: \[
\mathbb{E}[y \mid \boldsymbol{X}] = \mathbb{P}(y = 1 \mid \boldsymbol{X}) = \boldsymbol{X}\beta .
\]
Understanding the LPM
The LPM implies that \(\beta_j\) gives us the expected absolute change in probability when \(\boldsymbol{x}_j\) increases by 1. This linearity assumption can be a major limitation, as probabilities are naturally nonlinear.
When dealing with probabilities, the linearity assumption for \(f\) may be too strong. We need another approach.
We consider a function \(G\) that satisfies \(0 < G(z) < 1\).
We can use \(G\) to adapt our model to \[
P(\boldsymbol{y} \mid \boldsymbol{X}) = G(\boldsymbol{X}\beta).
\]
In this way, we model a latent variable \(\boldsymbol{z} = \boldsymbol{X}\beta\) using a linear model and link it to the dependent variable \(\boldsymbol{y}\) via the non-linear function \(G\), giving us \(\boldsymbol{y} = G(\boldsymbol{z})\).
The inverse function \(G^{-1}(z)\) is called the link function.
We can use different functional forms for \(G\).
Cumulative Distribution Function
The probability function \(G(\boldsymbol{X}\beta)\) comes directly from the CDF of the error term in the latent variable model.
Start from \(\boldsymbol{y}^* = \boldsymbol{X}\beta + u\), where:
\(\boldsymbol{y}^*\) is an unobserved continuous propensity
\(u\) is a random error term
We only observe: \[
y =
\begin{cases}
1 & \text{if } y^* > 0,\\[6pt]
0 & \text{otherwise}.
\end{cases}
\]
It follows that the expected value of \(y\) depends on the distribution of \(u\):
For the logit model, we use the cumulative distribution function (CDF) of a logistic variable — the logistic function — for \(G\).
The link function is the log-odds: \(\log \frac{p}{1-p}\).
\[
G(\boldsymbol{z}=\frac{e^z}{e^z+1})
\]
The Probit Model
For the probit model, we use the CDF of a standard normal distribution, which gives us the probability that the standard normal variable \(Z\) is smaller than \(z\).
The interpretation of non-linear models such as logit and probit is not as straightforward as in linear models due to their non‐linearity.We can intrepret:
sign of the coefficients, the direction of the expected change
significance of coefficients
If \(\beta_j >0\) we expect the probability to increase with \(\boldsymbol{x_j}\).
However, we cannot interpret the magnitude of coefficients as magnitude of the effect of \(\boldsymbol{X}\) on \(\boldsymbol{y}\). Instead it captures the effects of \(\boldsymbol{X}\) on the latent \(\boldsymbol{z}\), which we rarely care about.
Partial effects
The problem with interpreting coefficients is that the partial effects of \(x_j\) are affected by all
other variables. Assume \(x_1\) is a dummy. Then:
We compare the likelihood of the unrestricted (\(\mathcal{L}_u\)) and restricted (\(\mathcal{L}_r\)) models, where the models are required to be nested (the complex model nests the simpler one).
Likelihood: The likelihood function is the joint probability of the observed data, viewed as a function of the parameters.
Comparing Models
We can compare model specifications using
\(R^2\), the proportion of explained variance, for non-linear models there are various pseudo \(R^2\) measures,
the likelihood, \(\mathcal{L}\), of a given model,
information criteria (IC), which rewards model fit but penalizes model complexity
Many measures of model fit always increase with complexity — IC prefer parsimony.
Count data take non-negative integer values\((0,1,2,\ldots)\) and often include a substantial number of zero outcomes (“zero-inflated”).
To build a model for this kind of data, we could:
think of a latent normal variable behind \(Y\), or
use a discrete probability distribution.
The Poisson distribution is one example; we can use it to express the probability that a given number of events occurs in a fixed interval.
Poisson Distribution
The probability mass function (PMF) of the Poisson distribution is
\[
\mathbb{P}(Y = y_i \mid \lambda) = \frac{\lambda^{y_i} \exp(-\lambda)}{y_i!},
\qquad y_i = 0,1,2,\ldots
\] where the parameter \(\lambda\) is also the expectation \(\mathbb{E}[Y]\) and the variance \(\mathbb{V}(Y)\).
Poisson Distribution(2)
We generally expect that the expectation, i.e. the mean \(\lambda = \mathbb{E}[y]\), depends on other variables. Consider a Poisson model with a dependent mean; let
If we apply the OLS method, we should minimise ( ’ ).
This will be problematic because we need to consider ( K ) (( ^K )) partial derivatives, and there is no closed-form solution.
Non-linear least squares estimation is a conceptually straightforward approach. First, we approximate with a linear model, and then refine the estimates iteratively. However, estimates are generally not unique and inefficient — OLS is not BLUE.
Intuitively, we set \(\boldsymbol{\beta}_{ML}\) such that the observed data is most probable within our model
The resulting estimator is consistent, asymptotically normal, and asymptotically efficient in most cases
The likelihood \(\mathcal{L}(\theta \mid X)\) itself is not a probability - \(\theta\) can vary, not \(X\)
Maximum Likelihood Estimation (2)
To make the computation easier we usually work with log-likelihood\[
\ell(\boldsymbol{\beta}) = \log \mathcal{L}(\boldsymbol{\beta}) = \sum_{i=1}^{N} \log \mathbb{P}\!\left( \boldsymbol{y} \mid \boldsymbol{X} , \boldsymbol{\beta} \right)
\]
\(\boldsymbol{\beta}_{ML}\) is then the estimate that maximises the log-likelihood function
The equation \(\frac{\partial\ell(\boldsymbol{\beta})}{\partial\beta}=0\) generally has no closed form solution, and iterative optimization algorithms are used such as Gradient Descent and Newton’s method
Maximum Likelihood for binary outcomes
A distributional assumption lies at the center of Maximum Likelihood estimation.
For binary outcomes, where \(Y \in (0,1)\), we can use the Bernoulli distribution with proability mass function:
\[
f(y_i \mid p) = p^{y_i}(1-p)^{1-y_i}
\]
Given the independence of observations, the joint probability is
We can obtain the likelihood function from the PDF:
\[
\mathcal{L}(\beta, \sigma^2)
=
\frac{1}{(2\pi)^{\frac{N}{2}} \sigma^N}
\exp\!\left\{
-\frac{1}{2\sigma^2}
(y - X\beta)'(y - X\beta)
\right\}.
\] To obtain estimates, we work with the log-likelihood:
\(\lambda\) sets the strength of the penalty: \(\lambda = 0\) gives OLS, \(\lambda \to \infty\) pushes all \(\beta_j \to 0\)
We accept some bias in exchange for a lower variance
Regressors should be standardised first, and the intercept is not penalised
Why LASSO sets coefficients to zero
The solution is where the RSS contours first touch the constraint region. The LASSO diamond has corners on the axes, so some \(\beta_j\) become exactly zero.
Coefficient paths
As \(\lambda\) grows, Ridge shrinks all coefficients, while LASSO drops them one by one. This is variable selection.
Ridge vs. LASSO
Ridge
LASSO
Penalty
\(\lambda\sum\beta_j^2\)
\(\lambda\sum\lvert\beta_j\rvert\)
Coefficients exactly 0?
no
yes
Correlated regressors
shares the weight
picks one
Works well with
many small effects
few large effects
We choose \(\lambda\) by cross-validation: the value with the lowest out-of-sample error
The elastic net combines both penalties
Ridge and LASSO in R
library(glmnet)X <-model.matrix(mpg ~ ., data = mtcars)[, -1]y <- mtcars$mpgridge <-cv.glmnet(X, y, alpha =0) # alpha = 0: Ridgelasso <-cv.glmnet(X, y, alpha =1) # alpha = 1: LASSOcoef(lasso, s ="lambda.min") # some coefficients are exactly 0plot(glmnet(X, y, alpha =1), xvar ="lambda")
glmnet standardises the regressors by default and chooses \(\lambda\) by 10-fold cross-validation.
ML estimators are based on the probability distribution of \(Y\).
We learn about the:
parameters of this underlying distribution,
conditional on the data we observe and the chosen distribution.
To find an ML estimator, we:
Model the probability of each observation.
Derive the joint probability of all observations.
Consider the joint probability as a function of its parameters \(\theta\), conditional on the data \(\mathcal{D}\). This gives us the likelihood function\(\mathcal{L}(\theta \mid \mathcal{D})\).
Maximise the log-likelihood\(\ell(\theta \mid \mathcal{D})\) with respect to \(\theta\).