Maximum Likelihood Estimation – A Comprehensive Guide
Maximum likelihood estimation (MLE) is a powerful and widely used statistical method for estimating the parameters of probability distributions. It is a versatile tool in the toolkit of data scientists, machine learning researchers and statisticians for a broad range of applications. Whether you are doing regression modeling, classification, clustering, or fitting complex probabilistic models to data, understanding MLE is essential.
In this guide, we‘ll dive deep into the concepts, mathematics and practical aspects of maximum likelihood estimation. By the end, you‘ll have a solid grasp of what MLE is, how it works, when to use it, and considerations to keep in mind. Let‘s get started!
What is Maximum Likelihood Estimation?
Imagine you have some data that you believe follows a certain probability distribution, but you don‘t know the true parameters of that distribution. MLE provides a principled way to estimate those parameters by finding the values that maximize the likelihood of the observed data under the assumed model.
Let‘s make this concrete with a simple example. Suppose you flip a coin 10 times and observe 7 heads. You believe the coin flips follow a Bernoulli distribution with some unknown probability p of getting heads on each flip. The likelihood L(p) of observing 7 heads in 10 flips for a given value of p is:
L(p) = (10 choose 7) p^7 (1-p)^3
The maximum likelihood estimate of p is the value p that maximizes this likelihood function. Intuitively, it‘s the value of p that makes the observed data most probable under the Bernoulli model. With a bit of calculus, we can show that p = 7/10 = 0.7, which is simply the proportion of heads observed.
This is the essence of MLE – finding model parameters that maximize the probability of the observed data. More generally, for a set of independent and identically distributed data points X = {x1, …, xn} and a parametric family of probability density or mass functions {f(x; θ)}, the likelihood function is:
L(θ; X) = Πi f(xi; θ)
The maximum likelihood estimator θ* of the true parameters θ is:
θ* = argmax L(θ; X)
Maximizing the likelihood is equivalent to maximizing the log-likelihood ℓ(θ; X) = log L(θ; X), which is often more convenient to work with.
Mathematical Details and Derivations
To derive the MLE for a given distribution, we typically start by writing out the likelihood function based on the assumed density or mass function. For independent and identically distributed data, the likelihood will be a product of terms. Any constant factors not involving the parameters can be dropped, as they don‘t affect the argmax.
Taking the log gives the log-likelihood, and maximizing it involves finding the parameter values where the derivative or gradient is zero (and checking second-order conditions to ensure it‘s a maximum). In some cases, there are closed-form solutions for the MLEs. Otherwise, we resort to numerical optimization methods.
Let‘s derive the MLE for the mean μ of a normal distribution with known variance σ^2. The likelihood function is:
L(μ) = (2πσ^2)^(-n/2) exp(-Σi (xi – μ)^2 / 2σ^2)
The log-likelihood is:
ℓ(μ) = -n/2 log(2πσ^2) -1/(2σ^2) Σi (xi – μ)^2
Differentiating with respect to μ and setting to zero:
dℓ/dμ = 1/σ^2 Σi (xi – μ) = 0
⇒ Σi xi = nμ
⇒ μ* = x̄ = 1/n Σi xi
So the MLE for the mean is just the sample mean, a quite intuitive result. We can derive MLEs for parameters of other well-known distributions like the binomial, Poisson, exponential, gamma, etc. in a similar fashion. The MLEs may be in closed-form or require numerical solution.
An important property of MLEs is invariance – if θ is the MLE for θ, then for any function τ(θ), the MLE for τ(θ) is simply τ(θ). This allows us to easily obtain MLEs for transformed parameters of interest.
Finding MLEs: Computational Considerations
For many models and datasets, finding MLEs boils down to an optimization problem. There are two key aspects: formulating the objective function (log-likelihood) and the optimization algorithm.
Ideally, we can obtain closed-form expressions for the MLEs by solving the likelihood equations analytically. This is possible for many standard distributions like we saw for the Gaussian mean. However, for more complex models with many parameters, the likelihood equations may be intractable and not admit closed-form solutions.
In these cases, we resort to numerical optimization techniques to maximize the likelihood function. The most common methods are gradient ascent, Newton‘s method, and variants thereof. These are iterative algorithms that, given a starting point, compute the gradient and/or Hessian of the log-likelihood at each step and update the parameters accordingly until convergence.
For gradient ascent, the update rule is:
θ^(t+1) ← θ^(t) + η ∇ℓ(θ; X)
where η is a step size. Newton‘s method uses the Hessian matrix of second derivatives:
θ^(t+1) ← θ^(t) – [∇²ℓ(θ; X)]^(-1) ∇ℓ(θ; X)
Quasi-Newton methods like BFGS build up approximations to the Hessian. In all cases, the goal is to find a stationary point of the likelihood function corresponding to a local maximum. Multiple initializations can help find a global optimum.
For latent variable models and missing data, a powerful iterative algorithm is Expectation-Maximization (EM). EM alternates between computing the expected log-likelihood given current parameters and the latent variables (E-step) and maximizing the expected log-likelihood to update the parameters (M-step).
Nowadays, there are many mature software implementations for optimization and MLE in popular languages like R, Python and Julia. Libraries like scipy.optimize, statsmodels and scikit-learn in Python or optim() in R allow users to solve MLE problems with a few lines of code.
Statistical Properties & Relationship to Other Approaches
Maximum likelihood estimators have many desirable statistical properties under fairly general conditions. They are consistent, meaning they converge to the true parameter values as the amount of data goes to infinity. They are asymptotically efficient, achieving the lowest possible variance among unbiased estimators in the limit of large samples (Cramér-Rao lower bound).
Furthermore, MLEs are asymptotically normal, meaning their distribution approaches a normal distribution centered at the true parameters. This allows the construction of confidence intervals and hypothesis tests. All of these are important reasons for the ubiquity of MLE.
MLE is a parametric approach, relying on a specified model family. This has advantages in terms of efficiency when the model is correct, but can be sensitive to model misspecification. Other estimators like method of moments and minimum distance estimators can be more robust.
From a Bayesian perspective, MLE can be seen as a special case of maximum a posteriori (MAP) estimation with a uniform prior. Bayesian approaches further incorporate prior information for regularization and can quantify uncertainty more fully through posterior distributions over parameters.
Considerations, Limitations and Extensions
While a powerful tool, MLE is not without limitations, and there are several important considerations to keep in mind:
-
MLE can be sensitive to model misspecification. If the assumed model family doesn‘t contain the true model, the MLE may be biased and not very meaningful. It‘s important to assess goodness of fit and consider more robust estimation methods if needed.
-
MLE can exhibit bias in small samples due to the nonlinearity of the log transformation. There are analytic and resampling techniques (e.g. jackknife) for bias correction.
-
In settings with missing or censored data, the likelihood function needs to be modified accordingly. Techniques like data augmentation and EM can be used.
-
For high-dimensional and complex models, regularization techniques are often used to constrain the parameter space and prevent overfitting. This leads to penalized likelihood approaches like Ridge/Lasso.
-
For non-i.i.d. data like time series and spatial data, the likelihood needs to account for dependencies. Methods like conditional and marginal likelihood handle this.
-
Semiparametric and nonparametric MLE relax some of the strong parametric assumptions. These include methods like empirical likelihood and nonparametric mixtures.
MLE also has close connections to other inference approaches. Maximizing likelihood is equivalent to minimizing Kullback-Leibler (KL) divergence between the empirical and model distributions. MLE is also a special case of M-estimation, a broad class of inference techniques based on optimizing objective functions.
Applications in Data Science & Machine Learning
MLE finds wide application for fitting models in statistics and machine learning:
-
In regression problems, MLE can fit linear regression, generalized linear models, survival models, mixed models and more. The specific likelihood function depends on the assumed data distribution (Gaussian, Poisson, Bernoulli, etc.).
-
For classification, logistic regression and Gaussian discriminant analysis are based on MLE. For clustering, Gaussian mixture models are commonly fit by MLE.
-
Beyond prediction, MLE is used for hypothesis testing (likelihood ratio tests) and constructing confidence intervals based on the asymptotic normality property.
-
MLE provides a basis for model selection and assessment. Information criteria like AIC and BIC, which balance goodness of fit against model complexity, are based on maximized likelihoods.
With the proliferation of big and complex data in many domains, MLE remains a fundamental paradigm in the data scientist‘s toolbox for drawing inferences and understanding the world.
Conclusion
Maximum likelihood estimation is a powerful and ubiquitous framework for estimating models from data. Its intuitive principle of choosing model parameters that maximize the probability of observed data, coupled with its excellent statistical properties, make it a mainstay in statistics and data science.
In this guide, we‘ve covered the key concepts and mathematics behind MLE, from the basic definitions to computational techniques and theoretical properties. Through examples and discussion of important considerations, I hope you‘ve gained a solid understanding that you can apply in your own data analysis endeavors.
Of course, MLE is a vast topic and we‘ve only scratched the surface. I encourage you to dive deeper with further reading on the references and advanced topics mentioned. The study of MLE is still an active area of research, with new refinements, generalizations and applications continuing to emerge.
At the end of the day, MLE exemplifies the fundamental principles of learning from data – letting the data speak for itself and updating our beliefs accordingly. With its rich history and ongoing developments, MLE will no doubt continue to light the way in drawing insights from the ever-expanding world of data.