← Writing & notes

FROM THE NOTEBOOK

Statistics for Applications - MIT 18.650

MIT 18.650 Statistics for Applications, Fall 2016 - YouTube

MIT 18.650, taught by Professor Philippe Rigollet, provides a rigorous, mathematical introduction to the fundamental principles of statistics. The course is designed not as a guide to applied data analysis, but as a theoretical foundation that explains why statistical methods work, what their guarantees are, and under what assumptions they are valid. It rigorously distinguishes statistics as the "inverse problem"—inferring the properties of an unknown data-generating process from observed data—from probability, the "forward problem" of predicting data from a known process. The central theme is the development of a principled framework for estimation, decision-making, and modeling in the face of uncertainty.
Part I: The Foundations of Parametric Inference
The course begins by establishing the core concepts of statistical modeling, assuming data is drawn IID (Independent and Identically Distributed) from a parametric family of distributions. The initial focus is on estimation and confidence intervals. Key foundational tools are introduced:

Part II: Principles of Estimation
The course then delves into the theory of finding "good" estimators. Moving beyond simple sample averages, it introduces two major principled frameworks for deriving estimators:

Part III: Hypothesis Testing and Model Validation
The focus shifts from estimation to formal decision-making through hypothesis testing.

Part IV: Modeling Relationships and Discovering Structure
The course applies these foundational principles to two major areas of statistics.

Part V: Unifying Framework and Alternative Paradigms
The final part of the course introduces an alternative statistical philosophy and a powerful framework that unifies many of the preceding topics.

L1: Introduction

The lecture begins with an introduction to the course, 18.650 Fundamentals of Statistics, by the instructor, Professor Philippe Rigollet. He clarifies that the course is a mathematical introduction to the field, focusing on providing theoretical guarantees for statistical methods rather than on applied data analysis or "statistical thinking."
The primary goals of the course are for students to:

  1. Formulate real-world questions in precise mathematical terms. For example, translating "is a drug effective?" into a question about a specific parameter of a statistical model.
  2. Learn a catalog of fundamental statistical methods to apply to these formulated problems.
  3. Understand the assumptions and limitations of each method to make sound and critical conclusions from data.
  4. Gain the foundational knowledge necessary for more advanced, graduate-level courses in statistical machine learning.

Course Logistics and Requirements
The instructor outlines the practical details and expectations for the course.

Motivation: Why Study Statistics?
Professor Rigollet motivates the study of statistics by highlighting its ubiquity in science, media, and industry.

The Core Distinction: Probability vs. Statistics
The central theme of the lecture is the fundamental difference between probability and statistics.

A Case Study: The Kissing Couples Experiment
A study from the journal Nature on whether kissing couples tend to turn their heads to the right is used as a running example.

The Statistical Modeling Process
The kissing problem is used to demonstrate the formal steps of statistical modeling.

  1. Define Random Variables: The outcome for each couple is modeled as a random variable. R_i is an indicator variable: 1 if the i-th couple turns right, 0 otherwise.
  2. Define the Estimator: The estimator for p is the sample average, p̂ = (1/n) * Σ R_i. An estimator is a function of the random data and is therefore itself a random variable. The specific number it produces from a given dataset is the estimate.
  3. State the Modeling Assumptions (The IID Model):
    • Each R_i is a Bernoulli(p) random variable.
    • The parameter p is the same for all i (the data is Identically Distributed). This is a crucial assumption that allows us to pool information across observations.
    • The R_i variables are mutually Independent (one couple's choice doesn't affect another's).
    • Together, these form the IID (Independent and Identically Distributed) model, a cornerstone of classical statistics.

Practical Exercise: Estimating Mean and Variance
The lecture concludes with a quick, practical exercise to solidify the concept of estimation.

L2: Introduction cont.

The lecture begins with a review of how confidence intervals were constructed in the previous session using the Central Limit Theorem (CLT), taking the Bernoulli "kissing couples" example as a reference.

2. Alternatives to the CLT: Exact Calculations and Hoeffding's Inequality
The lecture explores alternatives to the asymptotic CLT approach.

3. The Theoretical Foundation: Modes of Convergence
To properly justify statistical procedures like the "plug-in" principle (replacing unknown parameters with their estimates), the lecture pivots to a more formal discussion on the different ways a sequence of random variables can converge.

4. Slutsky's Theorem: The Statistician's Best Friend
While convergence in distribution is very useful, it is too weak to allow for simple algebraic manipulation (e.g., the limit of a sum is not necessarily the sum of the limits). Slutsky's Theorem provides a critical exception that makes many statistical procedures valid.

5. New Example: Inter-arrival Times of the T
A new problem is introduced to apply these theoretical tools: modeling the inter-arrival times of the T at Kendall Square.

6. The Delta Method: CLT for Functions of Averages
The CLT applies directly to the sample mean T̄n, but we need a result for our estimator λ̂ = 1 / T̄n, which is a function of the sample mean. The Delta Method provides the tool to do this.

7. Justifying the "Plug-in" Principle with Slutsky's Theorem
The confidence interval derived from the Delta Method will still contain the unknown parameter λ in its variance term. The final step is to replace this unknown λ with its estimate λ̂.

L3: Parametric Inference

The lecture begins with a recap of the previous session's main topic: constructing confidence intervals using the Central Limit Theorem (CLT).

2. The Concept of a "Pivotal Distribution"
The instructor emphasizes the importance of finding a pivotal quantity. The key is that the limiting distribution (N(0,1) in the case of the CLT) does not depend on any unknown parameters. This is what allows us to use standard tables or software to find critical values (like quantiles q_(α/2)) and construct intervals. If the limiting distribution depended on p, the process would be circular.
3. Exact vs. Asymptotic Approaches
The lecture contrasts the asymptotic CLT approach with what would be required for an exact, finite-sample analysis.

4. Review of Convergence Modes for Random Variables
To justify more advanced statistical techniques, the lecture formally reviews different modes of convergence for sequences of random variables. The key takeaway is the hierarchy of these modes.

5. Slutsky's Theorem and the Delta Method
Two powerful theorems are introduced that allow for the manipulation of these convergence results.

6. Application: Estimating the Rate of the T
A new example is introduced: estimating the arrival rate λ of the T, assuming the inter-arrival times T₁, ..., Tn are IID Exponential(λ).

7. Introduction to Statistical Modeling
The second half of the lecture formalizes the concept of a statistical model.

8. Estimators and Their Properties
The lecture concludes by defining estimators and the properties used to evaluate their quality.

L4: Parametric Inference cont. and MLE

The lecture begins by reviewing the key properties used to evaluate the performance of a statistical estimator θ̂.

2. The Goal of Estimation: Finding a "Close" Distribution
The lecture transitions from evaluating estimators of a single parameter θ to the more fundamental goal of finding an entire probability distribution P_θ̂ that is "close" to the true, unknown data-generating distribution P_{θ*}.

3. A Principled Strategy for Estimation
A general strategy for finding a good estimator is proposed:

  1. Define a notion of distance (like TV distance) between the true distribution P_{θ*} and a candidate distribution P_θ.
  2. Find an estimator for this distance.
  3. Choose the θ̂ that minimizes this estimated distance.

4. A Surrogate Distance: Kullback-Leibler (KL) Divergence
To overcome this obstacle, a different measure of dissimilarity between distributions is introduced: the Kullback-Leibler (KL) divergence.

5. From KL Divergence to Maximum Likelihood
The crucial advantage of KL divergence is that it can be estimated from data.

The lecture concludes by showing that this very common and powerful estimation method (MLE) can be rigorously derived from the fundamental goal of finding a distribution that is "close" to the true one, using KL divergence as a mathematically convenient surrogate for the more intuitive TV distance.
6. Formalizing Statistical Models
The lecture also provides a formal definition of a statistical model.

L5: MLE cont.

The lecture begins with a recap of the key metrics used to evaluate the performance of a statistical estimator θ̂.

2. A Principled Approach to Estimation: Minimizing Distance Between Distributions
The lecture introduces a more fundamental, principled approach to finding good estimators. Instead of just estimating a parameter, the goal is to find a probability distribution P_θ̂ that is "close" to the true, unknown data-generating distribution P_{θ*}.

3. Kullback-Leibler (KL) Divergence: A More Convenient Surrogate
To overcome this, a different measure of dissimilarity, the Kullback-Leibler (KL) divergence, is introduced as a mathematically convenient surrogate for TV distance.

4. Deriving the Maximum Likelihood Principle
The lecture then shows how the strategy of minimizing the estimated KL divergence naturally leads to the principle of maximum likelihood.

  1. Decompose KL: The KL divergence is decomposed: KL(P_{θ*} || P_θ) = E_{θ*}[log(p_{θ*}(X))] - E_{θ*}[log(p_θ(X))].
  2. Identify the Objective: To find the best θ, we want to minimize this expression. The first term, E_{θ*}[log(p_{θ*}(X))], is the negative entropy of the true distribution. It is an unknown constant with respect to our choice of θ. Therefore, minimizing the KL divergence is equivalent to maximizing the second term: E_{θ*}[log(p_θ(X))].
  3. Replace Expectation with Average: We don't know the true expectation E_{θ*}. The core statistical principle is to estimate it with a sample average over our data X₁, ..., Xn. So, we aim to maximize: (1/n) * Σ log(p_θ(X_i)).
  4. Define the Likelihood: Maximizing the average of the logs is equivalent to maximizing the sum of the logs, which is equivalent to maximizing the product of the probabilities (or densities) themselves. This product, L(θ) = Π p_θ(X_i), is defined as the likelihood function.

5. Maximizing the Likelihood Function (Optimization Interlude)
The MLE principle turns an estimation problem into an optimization problem: maximizing the likelihood function.

6. Calculating MLEs for Standard Models
The lecture demonstrates how to apply the MLE principle to find estimators for common statistical models.

7. Performance of the MLE: The Fisher Information
The lecture concludes with a preview of how the performance of the MLE is analyzed.

L6: MLE cont. and MOM

The lecture begins with a recap of how to evaluate statistical estimators using the concepts of bias, variance, and quadratic risk (Mean Squared Error - MSE).

2. Maximum Likelihood Estimation (MLE) Review
The lecture revisits the principle of Maximum Likelihood Estimation (MLE) derived in the previous session.

3. Fisher Information: Quantifying Curvature and Precision
A new and central concept is introduced: Fisher Information.

4. Asymptotic Properties of the MLE
A major theorem is presented that describes the asymptotic behavior of the Maximum Likelihood Estimator under certain regularity conditions.

5. The Method of Moments: An Alternative Estimation Principle
A second major estimation technique is introduced: the Method of Moments (MoM).

6. Properties of the Method of Moments Estimator

L7: Parametric Hypothesis Testing

The lecture begins by revisiting the key properties used to evaluate a statistical estimator θ̂.

The instructor uses the example of estimating a Bernoulli parameter p to illustrate these concepts, showing that while the sample mean X̄n is unbiased and its variance decreases with n, a naive guess like 0.5 has zero variance but is biased. The choice between estimators involves a trade-off, but X̄n is generally superior as n grows.
2. Introduction to Hypothesis Testing
The lecture transitions from estimation (finding a value for a parameter) to hypothesis testing (making a yes/no decision about a parameter).

3. The Heuristic Approach and Its Flaw
A naive heuristic for testing the hypothesis would be to take a sample of n runners from 2012, compute their average time X̄n, and conclude that runners are faster if X̄n < 103.5.

4. The Formal Framework of Hypothesis Testing
The lecture formalizes the language and structure of hypothesis testing.

5. A Test: The Decision Rule
A test is a formal rule for making a decision based on the data.

6. Types of Errors and the Level of a Test
Since the decision is based on random data, it can be wrong. There are two types of errors.

Truth: Truth:
Decision: Fail to Reject Correct Decision Type II Error
Decision: Reject Type I Error Correct Decision (Power)

7. The Neyman-Pearson Paradigm: Controlling the Type I Error
There is an inherent trade-off between Type I and Type II errors. A test that never rejects H₀ has α = 0 but maximum β. A test that always rejects H₀ has β = 0 but maximum α.

This paradigm provides a principled way to choose the critical value c for a test. We choose c such that the probability of the test statistic exceeding c when is exactly α. For the coin example, c = 1.96 is chosen because the probability of a standard normal variable exceeding 1.96 in absolute value is 0.05.

L8: Parametric Hypothesis Testing cont.

The lecture begins with a review of the concepts from the previous session.

2. The Power Function, Level, and Neyman-Pearson Paradigm
The lecture further develops the framework for evaluating and designing tests.

3. Constructing Tests and the p-value
The lecture details the practical construction of a test and introduces the concept of the p-value.

4. The Chi-Squared (χ²) Distribution
To move beyond tests about means and proportions, which rely on the Gaussian distribution, the lecture introduces a new pivotal distribution: the chi-squared distribution. This is essential for making inferences about variances.

5. Cochran's Theorem and Inference on Variance
The connection between the χ² distribution and statistical inference is made through Cochran's Theorem.

The lecture concludes by noting that other important distributions, like the Student's t-distribution, are built from the Gaussian and chi-squared distributions, which will be covered in the next session.

L9: Parametric Hypothesis Testing cont.

The lecture begins by reviewing the core concepts and vocabulary of hypothesis testing from the previous session.

2. The Student's t-distribution
A new pivotal distribution, the Student's t-distribution, is introduced. It is essential for conducting inference on the mean when the variance is unknown.

3. Wald's Test: A General Test Based on the MLE
The lecture introduces a general and powerful hypothesis test based on the Maximum Likelihood Estimator (MLE), known as Wald's Test.

4. The Likelihood Ratio Test (LRT)
Another general and fundamental hypothesis test is introduced: the Likelihood Ratio Test (LRT).

5. The Delta Method for Hypothesis Testing
The lecture concludes by showing how the Delta Method can be used to construct tests for functions of parameters.

This provides a general recipe for constructing tests for a wide variety of complex hypotheses involving functions of the underlying model parameters.

L10: Testing Goodness of Fit

The lecture begins with a review of the hypothesis testing framework and the Chi-Squared (χ²) test, which was introduced in the previous session.

2. The Student's t-test: Inference on Means with Unknown Variance
The lecture introduces a new, fundamental test: the Student's t-test.

3. Goodness-of-Fit Tests for Continuous Distributions
The lecture then moves to the more general problem of testing whether a sample comes from a specific continuous distribution, a problem known as goodness-of-fit.

4. The Kolmogorov-Smirnov (KS) Test
The Glivenko-Cantelli theorem motivates a classic goodness-of-fit test.

5. Practical Considerations for Goodness-of-Fit

The lecture concludes by mentioning other goodness-of-fit tests, like the Cramér-von Mises and Anderson-Darling tests, which use different norms (e.g., L2-norm) to measure the distance between the ECDF and the hypothesized CDF.

L11: Testing Goodness of Fit cont.

The lecture begins by introducing goodness-of-fit tests as a way to answer the question: "Does my data come from a particular distribution?" This is a crucial step in many statistical analyses. For example, one might test if the zodiac signs of Fortune 500 CEOs are uniformly distributed, or more practically, if a dataset is normally distributed, which is a key assumption for applying a t-test.
Several standard tests exist for this purpose:

The choice of test can be subjective, as each has advantages and may be more powerful against different types of deviations from the hypothesized distribution.
A Special Case: Testing for Normality
A primary application of goodness-of-fit tests is to check if data is normally distributed before applying methods like the Student's t-test. However, "normal" isn't a single distribution but a family of distributions defined by a mean (µ) and a variance (σ²).
When testing for normality, the specific µ and σ² are usually unknown. The natural approach is to estimate them from the data itself using the sample mean (μ̂) and sample variance (σ̂²). The test then checks if the data fits a normal distribution with these estimated parameters.
This estimation process introduces a complication:

The Lilliefors Test: A Modification for Normality
To address the issue of testing for normality with estimated parameters, a modification of the K-S test known as the Lilliefors test is used.
The key insight is that while the test statistic's distribution is no longer the standard K-S distribution, it is pivotal. This means that under the null hypothesis (that the data is indeed Gaussian), its distribution does not depend on the specific true values of µ and σ.
This property arises from standardizing the data. The test statistic, which depends on terms like (μ̂ - μ) / σ and σ̂² / σ², relies on quantities whose distributions (Normal and chi-squared, respectively) do not depend on the unknown parameters. Because these quantities are also independent (a result of Cochran's theorem for Gaussian data), their joint distribution is also independent of μ and σ.
Interpreting Lilliefors Test Results:

Visual Diagnostics: Quantile-Quantile (QQ) Plots
Beyond numerical tests, visual tools are essential for diagnosing how a distribution deviates from a theoretical one. Quantile-Quantile (QQ) plots are a powerful method for this, especially for examining the tails of a distribution.
How QQ Plots Work:

Interpreting Deviations:

The Chi-Square Test for Parametric Families
The lecture revisits the chi-square goodness-of-fit test, extending it from testing against fixed probabilities (like a fair die) to testing against a parametric family of distributions, such as the Binomial or Poisson distributions.
The Process:

  1. Binning: The data, whether discrete or continuous, is grouped into a finite number of categories or bins.
  2. Parameter Estimation: The unknown parameters of the distribution (e.g., the probability p in a binomial distribution) are estimated from the data, typically using the maximum likelihood estimator.
  3. Calculating Probabilities: The estimated parameters are used to calculate the expected probability for each bin according to the theoretical distribution.
  4. Test Statistic: The chi-square statistic is computed by summing the squared differences between the observed proportions in each bin and the expected probabilities, scaled by the expected probabilities.

Degrees of Freedom:

This method allows the chi-square test to be a flexible tool for testing goodness-of-fit for a wide range of distributions, including continuous ones like the normal distribution, by first discretizing the data through binning.

L12: Regression

Regression analysis aims to predict or explain a variable, called the explained variable (denoted as y), as a function of one or more other variables, known as explanatory variables (denoted as x). The core task is to estimate the underlying function f in the relationship y = f(x) using a set of data points (xi, yi).
2. The Linear Regression Model
The simplest and most common form of regression is linear regression, which assumes the relationship between x and y is a straight line.

3. Finding the "Best Fit" Line: The Method of Least Squares
To find the best possible line that explains the data, a criterion is needed to measure how well a given line fits the points. The standard method is least squares.

4. Properties of the Noise Term (ε)
The least squares method implicitly makes two important assumptions about the noise term ε:

  1. Zero Mean: The expected value of the noise is zero (E[ε] = 0). This means the errors are not systematically positive or negative.
  2. Uncorrelated with x: The noise is uncorrelated with the explanatory variable (Cov(x, ε) = 0). This ensures that the errors are random and not related to the value of x.
    More advanced statistical inference often requires stronger assumptions, such as the noise being normally distributed.

5. Multivariate Regression and Matrix Notation
When dealing with multiple explanatory variables, solving for each coefficient individually becomes complicated. The problem is simplified by using matrix notation.

This matrix formulation is the standard approach for solving multivariate linear regression problems.

L13: Regression cont.

The lecture begins by formalizing the multivariate linear regression model using matrix notation, which simplifies the calculations.

2. Conditions for the Estimator to Exist
The formula for β̂ requires the matrix (XᵀX) to be invertible.

3. The Geometric Interpretation: Orthogonal Projection
Linear regression has a powerful geometric interpretation.

4. Statistical Assumptions for Inference
To move from merely fitting a line to performing statistical inference (e.g., creating confidence intervals or hypothesis tests), we need a formal statistical model with three key assumptions:

  1. Deterministic Design Matrix The values of the explanatory variables are treated as fixed, not random.
  2. Homoscedasticity: The noise terms εᵢ are independent and have the same constant variance, σ².
  3. Gaussian Noise: The noise vector ε follows a multivariate normal distribution with a mean of zero and a covariance matrix of σ²I (where I is the identity matrix).

5. The Distribution of the Estimator and Residuals
Under these assumptions, we can derive the exact distributions of our estimators.

6. Towards Hypothesis Testing
The lecture concludes by setting the stage for hypothesis testing. The key insight, derived from Cochran's Theorem, is that the estimator β̂ (which is normally distributed) is independent of the variance estimator σ̂² (which follows a chi-squared distribution). This independence is exactly the condition required to construct a Student's t-statistic to test hypotheses about individual coefficients, such as whether a particular βⱼ is equal to zero.

L14: Regression cont.

This lecture focuses on the core principles of statistical inference in linear regression, building upon the derivation of the least squares estimator. It covers how to perform hypothesis tests on the model's coefficients, address the challenges of multiple testing, and understand the critical assumptions that underpin the entire framework.
1. Recap: The Foundation for Inference
The lecture begins with a summary of the key results for the least squares estimator, β̂, under the Gaussian noise model (y = Xβ + ε, where ε ~ N(0, σ²I)):

2. Testing Individual Coefficients: The t-test
A primary goal in regression is to determine which explanatory variables are significantly related to the outcome variable. This is done by testing if their corresponding coefficients are non-zero.

3. The Problem of Multiple Testing and the Bonferroni Correction
When a regression model has many variables, analysts typically examine the t-test for every single coefficient. This practice of conducting multiple simultaneous tests creates a problem.

4. General Linear Hypotheses: The F-test
The t-test is limited to testing a single coefficient at a time. The F-test is a more general tool for testing multiple linear constraints on the coefficients simultaneously.

5. Key Assumptions and Practical Considerations
The lecture concludes by highlighting the critical assumptions and potential misinterpretations in regression analysis.

L15: Bayesian Statistics

The fundamental difference between the two statistical paradigms lies in how they treat the unknown parameter (e.g., θ).

2. The Core Mechanism: Bayes' Rule
The updating of belief from prior to posterior is governed by Bayes' Rule. For a parameter θ and data X₁,...,Xₙ, the rule states:
Posterior ∝ Likelihood × Prior
Mathematically, this is written as:
π(θ | X₁,...,Xₙ) ∝ P(X₁,...,Xₙ | θ) * π(θ)

3. Priors in Practice: Conjugate and Uninformative Priors
Choosing a prior is a central part of the Bayesian workflow.
A. Conjugate Priors
A prior distribution is called conjugate for a given likelihood if the resulting posterior distribution belongs to the same family of distributions as the prior.

B. Uninformative Priors
What if you have no prior knowledge and want the data to speak for itself? You can use an uninformative prior.

4. Example: Bayesian Inference for a Gaussian Mean
Let's assume our data X₁,...,Xₙ comes from a N(θ, 1) distribution, and we want to find the posterior distribution for θ.

To understand this distribution, we complete the square in the exponent with respect to θ. After some algebra, the exponent can be rewritten as:
exp(-n/2 * (θ - X̄ₙ)²), plus terms that do not depend on θ.
This is the kernel of a Gaussian density for θ. We can therefore identify the posterior distribution:
θ | data ~ N(X̄ₙ, 1/n)
This is a powerful result. It states that our updated belief about the mean θ is a normal distribution centered at the sample mean X̄ₙ, and our certainty about this mean increases (the variance 1/n decreases) as we collect more data.
5. Jeffrey's Priors
A more principled, generic type of uninformative prior is Jeffrey's prior, which is defined as being proportional to the square root of the determinant of the Fisher information matrix.

L16: Bayesian Statistics cont.

This lecture concludes the short chapter on Bayesian inference, delving into principled ways of choosing priors, the interpretation and construction of Bayesian confidence regions, and how Bayesian estimators behave.
1. Principled Priors: The Jeffreys Prior
While priors can encode subjective, domain-specific knowledge, there are also principled, "objective" ways to select them. The lecture focuses on the Jeffreys prior.

2. Bayesian Confidence Regions
The main output of a Bayesian analysis is the entire posterior distribution, π(θ | data). A Bayesian confidence region is a way to summarize this distribution.

3. The Crucial Difference: Bayesian vs. Frequentist Interpretation
The interpretation of a confidence region is a major philosophical dividing line between the two paradigms.

4. From Posterior to Point Estimate
While the full posterior is the ideal output, a single-point estimate is often needed. Common choices include:

5. The Asymptotic Behavior of Bayesian Methods
As the sample size n grows, the influence of the prior is "washed away" by the overwhelming evidence from the data.

L17: PCA

This lecture introduces Principal Component Analysis (PCA), a fundamental technique for dimension reduction in unsupervised learning. In unsupervised learning, we are given a dataset of multi-dimensional observations without any corresponding outcome or "y" variable. The goal is to understand the inherent structure, patterns, and relationships within the data itself.
1. The Setup: High-Dimensional Data

2. The Language of Covariance
PCA is fundamentally based on analyzing the variance and covariance of the data.

3. The Matrix Formulation of Sample Covariance
The sample covariance matrix S can be expressed elegantly using the data matrix X.

4. The Core Idea: Maximizing Variance
The central principle of PCA is to find the directions in the d-dimensional space along which the data has the largest spread or variance. Projecting the data onto these directions preserves the most "information."

5. The Solution: Eigenvalues and Eigenvectors
This seemingly complex, non-convex optimization problem has an elegant and efficient solution from linear algebra, based on the eigen-decomposition (or spectral decomposition) of the sample covariance matrix S.

6. The PCA Algorithm
Principal Component Analysis is the procedure of finding these directions of maximal variance sequentially.

  1. First Principal Component (PC1): Find the eigenvector v₁ of the sample covariance matrix S that corresponds to the largest eigenvalue λ₁. This is the direction of maximum variance in the data.
  2. Second Principal Component (PC2): Find the eigenvector v₂ corresponding to the second-largest eigenvalue λ₂. This is the direction that has the largest variance among all directions orthogonal to the first principal component.
  3. Subsequent Components: Continue this process. The k-th principal component is the eigenvector vₖ corresponding to the k-th largest eigenvalue λₖ.

To perform dimension reduction from d dimensions to a smaller number d', you project the original data onto the subspace spanned by the first d' principal components (v₁, ..., v_d').

L18: PCA cont.

This lecture continues the exploration of Principal Component Analysis (PCA), detailing the algorithm, its geometric interpretation, the process of dimension reduction, and the statistical challenges associated with high-dimensional data.
1. Recap: The Core Idea of PCA
PCA is a technique for transforming a high-dimensional dataset into a new, lower-dimensional coordinate system. The goal is to retain as much of the original data's "information" as possible. In PCA, "information" is defined as variance.

2. The PCA Algorithm: A Sequential Approach
PCA finds the optimal low-dimensional subspace by identifying the directions of maximal variance in a step-by-step manner.

  1. First Principal Component (PC1): The first principal component is the eigenvector v₁ corresponding to the largest eigenvalue λ₁. This is the single direction in the data space that captures the most variance.
  2. Second Principal Component (PC2): The second principal component is the eigenvector v₂ corresponding to the second-largest eigenvalue λ₂. This direction captures the most remaining variance, subject to being orthogonal to the first principal component.
  3. Subsequent Components: This process continues. The k-th principal component, vₖ, is the direction that maximizes variance while being orthogonal to all the previously found components (v₁ through vₖ₋₁).

The complete set of eigenvectors v₁, ..., vᵈ forms a new, rotated orthonormal basis for the data space, where the axes are aligned with the directions of decreasing variance.
3. Dimension Reduction in Practice
To reduce data from d dimensions to a smaller dimension k (e.g., k=2 or 3 for visualization):

  1. Compute the Covariance Matrix: Calculate the sample covariance matrix S from the data.
  2. Find Eigenvectors: Perform an eigen-decomposition of S to find the eigenvectors v₁, ..., vᵈ and their corresponding eigenvalues λ₁, ..., λᵈ.
  3. Select Choose the first k eigenvectors (v₁ through vₖ) corresponding to the k largest eigenvalues. These k vectors form the basis of the new, lower-dimensional subspace.
  4. Project the Data: Project each original data point Xᵢ onto this subspace. The new k-dimensional coordinates for each point are calculated by Yᵢ = PₖᵀXᵢ, where Pₖ is the d x k matrix whose columns are the first k eigenvectors.

4. How to Choose
Choosing the right number of components to keep is a critical, and often subjective, part of PCA.

5. Interpretation and the Challenge of Sparsity
While PCA provides the mathematically optimal directions of variance, interpreting what these directions mean can be challenging.

6. Statistical Theory: The High-Dimensional Setting
The lecture concludes by touching on the statistical theory behind PCA, especially in the challenging modern setting where the dimension d can be comparable to or even larger than the sample size n.

L19: Generalized Linear Models

This lecture introduces Generalized Linear Models (GLMs), a powerful and flexible framework that extends the principles of linear regression to a much broader range of problems.
1. Limitations of the Linear Model
The standard linear model, y = Xβ + ε, is built on several key assumptions:

  1. Gaussian Response: The response variable y is assumed to be normally distributed.
  2. Linearity: The mean of y is a linear combination of the predictors, E[y|x] = xᵀβ.
  3. Constant Variance: The variance of y is constant and does not depend on the predictors.

These assumptions are often violated in practice:

2. The Three Components of a GLM
GLMs generalize the linear model by relaxing these assumptions. Every GLM is defined by three components:

  1. Random Component: Specifies the conditional distribution of the response variable y given the predictors x. Instead of being restricted to the Gaussian distribution, this distribution can be any member of the exponential family. This is a broad class of distributions that includes the Gaussian, Bernoulli, Poisson, Binomial, and Gamma distributions, among others.
  2. Systematic Component: This is the linear predictor, η = xᵀβ. This part remains the same as in the standard linear model. It specifies that the predictors are combined linearly.
  3. Link Function: This component connects the random and systematic parts. The link function g specifies how the mean of the response, μ = E[y|x], is related to the linear predictor η.
    • g(μ) = η = xᵀβ
      The link function's role is to map the range of the mean μ (which might be constrained, e.g., to the interval for a Bernoulli) to the entire real line (the range of xᵀβ).

3. The Exponential Family of Distributions
A distribution belongs to the exponential family if its probability density (or mass) function can be written in the form:
f(y; θ) = exp[ (η(θ)ᵀT(y) - b(θ)) ] * h(y)
In the simpler canonical form, this becomes:
f(y; θ) = exp[ (yθ - b(θ))/φ + c(y, φ) ]

Why is this family important?

4. Examples of GLMs in Practice

5. Properties of the Canonical Exponential Family
For distributions in the canonical form, the mean and variance of the response variable y have a simple and direct relationship with the cumulant generating function b(θ).

This relationship is proven using the identity E[∂log(L)/∂θ] = 0, a property used in the derivation of the Cramér-Rao lower bound. A key consequence is that b''(θ) = Var(y)/φ, which must be positive. This implies that the function b(θ) is always convex, a property that is crucial for the optimization of the likelihood function in GLMs.

L20: Generalized Linear Models cont.

This lecture dives deeper into the mechanics of Generalized Linear Models (GLMs), focusing on the properties derived from the exponential family and the role of the link function in connecting the model components.
1. Properties of the Canonical Exponential Family
The lecture begins by revisiting the canonical exponential family, a simpler, one-parameter subclass of the exponential family. Its probability density/mass function has the form:
f(y; θ) = exp[ (yθ - b(θ))/φ + c(y, φ) ]

A crucial insight is that the mean and variance of the response variable y can be derived directly from b(θ) using calculus, without needing to perform explicit integration or summation.

2. The Role of the Link Function
The link function g is the bridge between the mean of the response, μ = E[y|x], and the linear predictor, η = xᵀβ.

3. Common Link Functions

4. The Canonical Link Function
For each member of the canonical exponential family, there is a "natural" or canonical link function.

5. Estimation in GLMs
With the model fully specified, the goal is to estimate the coefficient vector β from the data.

L21: Generalized Linear Models cont.

This lecture delves into the core mechanics of fitting Generalized Linear Models (GLMs), focusing on maximum likelihood estimation. It bridges the theoretical properties of the exponential family with the practical algorithms used to find the model parameters.
1. Setting Up the Likelihood Function
The goal is to estimate the parameter vector β using the principle of maximum likelihood. This requires constructing the log-likelihood function for all n observations.

2. The Convexity of the Log-Likelihood
A key property of GLMs with a canonical link is that the log-likelihood function l(β) is concave.

3. Numerical Optimization: The Newton-Raphson Method
Except for the simple Gaussian case (which is just linear regression), the equation ∇l(β) = 0 does not have a closed-form solution. We must use an iterative numerical method to find the maximum. The standard algorithm is the Newton-Raphson method.

4. Fisher Scoring: A Statistical Simplification
The Newton-Raphson method requires computing and inverting the Hessian matrix H at each step. The Fisher Scoring algorithm simplifies this by replacing the observed Hessian with its expected value.

5. Iteratively Reweighted Least Squares (IRLS)
The final step is to show that the Fisher Scoring update for a GLM can be cleverly rewritten as a weighted least squares problem. This algorithm is known as Iteratively Reweighted Least Squares (IRLS) and is the standard method for fitting GLMs.

This algorithm is elegant because it recasts a complex non-linear optimization problem into a sequence of familiar linear regression problems, which can be solved efficiently.

L22: Generalized Linear Models cont.

This lecture details the numerical algorithms used to perform maximum likelihood estimation for Generalized Linear Models (GLMs). Since a closed-form solution for the parameter vector β generally does not exist, iterative methods are required.
1. Recap: The GLM Log-Likelihood
The foundation for estimation is the log-likelihood function. For n independent observations (xᵢ, yᵢ), where each yᵢ follows a distribution from the canonical exponential family, the log-likelihood is:
l(β) = Σ [ (yᵢθᵢ - b(θᵢ))/φ + c(yᵢ, φ) ]
The canonical parameter θᵢ is linked to the linear predictor xᵢᵀβ via the composite function h = (b')⁻¹ ∘ g⁻¹, such that θᵢ = h(xᵢᵀβ). When using the canonical link g = (b')⁻¹, this simplifies to θᵢ = xᵢᵀβ.
Crucially, this log-likelihood function is concave, which guarantees that a unique maximum exists and can be found by numerical optimization algorithms.
2. The Newton-Raphson Method
Newton-Raphson is a general-purpose, second-order optimization algorithm for finding the maximum (or minimum) of a function.

3. Fisher Scoring: A Statistical Adaptation
The Fisher Scoring algorithm is a modification of Newton-Raphson specifically for statistical estimation problems. It simplifies the update step by replacing the observed Hessian matrix with its expected value.

4. Iteratively Reweighted Least Squares (IRLS)
The most common algorithm for fitting GLMs is Iteratively Reweighted Least Squares (IRLS). It is a brilliant statistical trick that shows the Fisher Scoring update step is equivalent to solving a weighted least squares problem at each iteration.

This algorithm is powerful because it recasts a potentially complex non-linear optimization into a sequence of well-understood and efficiently solvable linear algebra problems (weighted least squares).

All writing