Skip to main content

Welcome to a Grasp lesson

Create a free account to keep studying and create your own study path.

Lesson 7

Understanding Maximum Likelihood Estimation

Recommended resources

Welcome to the final lesson of our foundational module. So far, we've covered the building blocks of epidemiology and biostatistics, from hypothesis testing and basic regression to calculating measures of disease frequency and association. In the last few lessons, you learned how to interpret coefficients from a logistic regression model as odds ratios and how to calculate those odds ratios directly from a 2x2 table. This naturally leads to a crucial question: how does a computer "fit" a model like logistic regression to the data? How does it find the specific coefficients that best describe the relationship between an exposure and an outcome?

Today, we will answer that question by exploring the principle of Maximum Likelihood Estimation (MLE). This is one of the most important and foundational concepts in modern statistics and machine learning. Your goal is to understand the intuition and the process behind MLE, as it's the engine that powers most of the statistical models we will encounter throughout this course, including the advanced survival models we'll study later.

The Core Idea: What is "Most Likely"?

Imagine you have a set of data points, for instance, the heights of a sample of people. You might hypothesize that height in the population follows a normal distribution (a "bell curve"). But a normal distribution is defined by two parameters: its mean (, the center of the curve) and its standard deviation (, the spread of the curve). Which values of and create the specific bell curve that best represents your data?

Maximum Likelihood Estimation provides a formal way to answer this. The core idea is to "try out" many different possible parameter values and, for each set, ask: "Given this specific bell curve, how likely is it that we would have observed the exact data points that we did?" We then choose the parameters that make our observed data most likely.

The following video from StatQuest provides an excellent and intuitive visual explanation of this process using an example of mouse weights.

Maximum Likelihood, clearly explained!!!

This video from the StatQuest channel clearly explains the core logic of Maximum Likelihood Estimation without getting bogged down in complex mathematics.

Watch the video from the beginning until the end. Pay close attention to the animations that show: How different normal distributions are "tested" against the data (shifting the distribution). How a "likelihood" score is calculated for each distribution. How MLE finds the parameter values (mean and standard deviation) that maximize this likelihood. The specific statistical meaning of the term "likelihood" (terminology alert).

As the video demonstrates, MLE is essentially a search for the peak of a "likelihood mountain." The location of that peak gives us our best estimates for the model parameters.

Let's visualize this with a slightly different view. Look at the graph below. The blue dots are our observed data points. We are considering four different possible probability distributions, represented by the curves f₁, f₂, f₃, and f₄, that might have generated this data.

This graph shows four possible probability density functions (f₁, f₂, f₃, f₄) and a set of observed data points (blue circles). MLE aims to identify which function provides the best explanation for the observed data.

By just looking, which curve seems most plausible? Most people would choose f₃ (the pink curve). Why? Because our data points cluster near its center, where the curve is highest. This means that under the distribution f₃, observing these data points is relatively likely. In contrast, under f₄ (the teal curve), some of our data points fall in the tails of the distribution, where they are very unlikely to occur. MLE is the mathematical formalization of this intuition.


From "Magic" to Models

It's important to clarify why we need to assume a model (like a normal distribution or a binomial process) in the first place. Without a model, the "most likely" explanation for our data is always a trivial one. For example, if we flip a coin and get "Heads", the MLE without any restrictions would be a "magic coin" that always lands on Heads. If we observed the sequence H, T, H, the MLE would be a magic coin that always produces that exact sequence. This isn't useful because it doesn't generalize.

The power of MLE comes from introducing realistic constraints through a probability model. We assume our data comes from a known type of distribution (e.g., a normal distribution for heights, a binomial distribution for coin flips) but with unknown parameters. MLE then finds the best parameters within the rules of that model.

The next video explains this crucial point very clearly, using a coin-flipping example and then extending it to the normal distribution for height.

Maximum Likelihood Estimation ... MADE EASY!!!

This video from "Stats with Brian" excellently distinguishes between an unrestricted, "magic" solution and a practical, model-based MLE solution.

Watch from "That would be a very crazy magic coin" to the end. The key concepts to focus on are: Why we need to add restrictions by proposing a probability model (adding restrictions). How the likelihood for a sequence of independent events (coin flips) is calculated by multiplying probabilities (calculating the likelihood). How MLE finds a balance to maximize the joint probability of all data points (balancing probabilities).


The Likelihood Function and the Log-Likelihood Trick

Now, let's formalize this a bit, connecting it to concepts from your CIS background. As you've just seen, for a set of independent data points (), the total likelihood of observing all of them is the product of their individual likelihoods:

Here, (theta) represents the set of all parameters for our model (e.g., for a normal distribution). The expression is the likelihood function.

Multiplying many small probabilities together can cause a problem known as numerical underflow, where the result becomes too small for a computer to store accurately. To get around this, we use a clever mathematical trick: we work with the natural logarithm of the likelihood.

The following reading explains this transformation and connects MLE directly to the field of machine learning.

A Gentle Introduction to Maximum Likelihood Estimation for ...

This article from Machine Learning Mastery provides a clear, formal definition of the MLE process and its relationship to optimization problems you might be familiar with.

Please read the section titled Maximum Likelihood Estimation. Focus on these key parts: The definition of the likelihood function, L(\theta; X). The explanation for why the product of probabilities is transformed into a sum using the log-likelihood function. The concept of minimizing the Negative Log-Likelihood, which frames MLE as a minimization problem, just like finding the minimum of a "loss function" in machine learning.

Because the logarithm is a monotonically increasing function, the value of that maximizes the likelihood function is the exact same value that maximizes the log-likelihood function . This trick converts a large product into a more manageable sum:

This log-likelihood is what is actually maximized in practice. The image below illustrates this point. The top plots (A, B) show a likelihood function, and the bottom plots (C, D) show the corresponding log-likelihood function. Notice that while their shapes are different, the peak—the maximum value—occurs at the exact same parameter value (in this case, ).

These plots show a likelihood function (A, B) and its corresponding log-likelihood function (C, D). Although the y-axis values and curve shapes differ, the maximum for both functions is achieved at the same parameter value, \(\lambda\). Panels B and D are zoomed-in views.

Finding the Maximum and Why We Care

So how do we find this maximum point? The traditional method involves calculus—taking the derivative of the log-likelihood function with respect to the parameters, setting it to zero, and solving. However, as your preference is to avoid deep calculus, the more relevant answer for modern applications is that we use computers. For all but the simplest models, the maximum is found using numerical optimization algorithms. The computer iteratively searches the "parameter space" to find the values that maximize the log-likelihood function.

This brings us to why MLE is so important.

Maximum Likelihood Estimation

This document provides a concise overview of the theoretical importance and properties of MLE.

Please read the following three parts of the document: Under Likelihood Theory -- What Good Is It?, review the list of applications. This shows how central MLE is to statistical inference. Read the section on the Properties of Maximum Likelihood Estimators. Focus on the three main properties (normal distribution, minimum variance, unbiased). These are the theoretical guarantees that make MLE so reliable. Finally, read the conceptual explanation of the shape of the log-likelihood function, starting from the raffle ticket analogy and continuing to the end of that section. This provides a great intuition for how the "peakedness" of the likelihood function relates to our certainty about the parameter estimates.

As you read, MLE is the backbone of statistical estimation for several reasons:

  • Universality: It provides a consistent method for fitting a vast range of models, from the linear and logistic regression models we've mentioned to the complex survival models we will study later.
  • Optimality: The parameter estimates found via MLE have excellent statistical properties, especially with large sample sizes. They are generally the most precise estimates possible.
  • Inference: The theory behind MLE also gives us a way to calculate standard errors and confidence intervals for our parameter estimates, which is crucial for hypothesis testing. The shape of the log-likelihood function itself tells us about our uncertainty: a sharp peak means we are very certain about our estimate, while a flat peak means we are uncertain.

Conclusion

In this lesson, you've learned the principle behind how we fit statistical models to data. Maximum Likelihood Estimation is a powerful and intuitive framework that sits at the heart of both classical statistics and modern machine learning.

Here are the key takeaways:

  • The Goal of MLE: To find the values for a model's parameters that make the observed data most probable.
  • The Process: We define a probability model for our data, which in turn defines a likelihood function. We then find the parameter values that maximize this function.
  • The Log-Likelihood Trick: In practice, we maximize the log-likelihood because it's computationally more stable (turning products into sums) and mathematically easier to handle, while giving the exact same result for the parameter estimates.
  • The Connection: MLE provides the theoretical foundation for fitting many important models, including logistic regression. The process of minimizing the negative log-likelihood is conceptually identical to minimizing a loss function in machine learning.

This lesson marks the end of our first module on the foundations of biostatistics and epidemiology. You now have a conceptual toolkit that includes measures of disease, measures of association, and the fundamental principle for fitting statistical models.

In the next lesson, we will begin Module 2, where we will apply these concepts to real-world scenarios. We'll start by examining the design, strengths, and weaknesses of cross-sectional studies, one of the most common types of study in epidemiology.