- Published on
Statistical Foundations of Machine Learning
- Authors
- Name
- Advait Lonkar
- @advait_l
See also: Probability, Linear Regression, R-Squared, p-value, Multiple Regression, t-tests, ANOVA
Mutual Information
- Mutual information measures how closely two variables are related.
- Joint probabilities: probability of two things occurring at the same time.
- Marginal probabilities: probability of just one thing occurring.
- A variable that never changes has zero mutual information with anything else (it provides no information).
Least Squares
- Fit a line among points by minimizing vertical distances from points to the line.
- Square each distance so contributions are non-negative.
- For a line , find and that minimize the sum of squared residuals.
- This method is called Least Squares.
- Conceptually, consider the sum of squared residuals as a surface over ; the optimal fit occurs where the derivatives are zero (a minimum).
We want to minimize the squared distance between observed values and the line. We find the minimum by taking derivatives with respect to the line parameters and solving where the derivatives are zero. The resulting line minimizes the sum of squares.
Linear Regression
Linear Regression is:
- Use least squares to fit a line to the data
- Calculate
- Calculate a -value for
Example context: mouse size vs. mouse weight. Least squares estimates two parameters: slope and intercept.
R2
- Calculate average mouse size (the mean).
- Sum of squares around the mean:
- Variation around the mean:
- Sum of squares around the least squares fit:
- Variation around the fit:
Variance is the average of the sum of squares.
- explains how much of the variation in mouse size is explained by mouse weight.
- Formula:
- A perfect fit yields (100% of variation explained).
- Adjusted penalizes additional parameters.
How to determine if the value is significant?
p-value
- = (variation explained by weight) / (variation without using weight)
- Define an F-statistic:
- Residuals are the variations not explained by weight (the errors around the fit).
- (parameters in the fit line) = 2: intercept and slope
- (parameters in the mean-only model) = 1: intercept
- Numerator: variance explained by the extra parameter(s)
- Denominator: variance not explained by the fit (sum of squares of residuals)
How to turn F into a p-value?
- Simulate or consider the distribution of F under the null hypothesis by computing F for many random datasets.
- Compute F for the original dataset.
- The p-value is the fraction of simulated F values that are greater than or equal to the observed F (more extreme), i.e., “extreme count / total count.”
In practice, closed-form F-distribution is used to compute the p-value (one F-distribution for the test; two if comparing models with different parameter counts in nested models).
[!INFO] p-value
- A low p-value (typically < 0.05) means it is very unlikely to obtain such a high F-statistic by chance. The model is statistically significant and better than predicting just the mean.
- A high p-value means the result could have occurred by chance; you cannot conclude the model predicts better than the mean.
IMPORTANT
, -statistic, and -value are related
- Higher (better fit) generally corresponds to a larger F-statistic and therefore a smaller p-value.
- Strong fit () provides strong evidence (large F) against the null (useless model), implying a low probability (p-value) that the result occurred by chance.
- Together these quantify model usefulness.
Multiple Regression
- Simple regression fits a line to data (one predictor).
- Multiple regression fits a plane (or higher-dimensional hyperplane) using multiple predictors.
- Use adjusted to compensate for additional parameters.
- Computing F and p-values follows the same principles as simple regression.
[!INFO] Is multiple regression worth it? If the increase in from adding predictors is large and the p-value is small, then adding the predictor(s) (e.g., tail length) is worth the added complexity.
t-tests and ANOVA
Example: gene expression differences between control and mutant mice.
t-test vs. linear regression
- Ignore the x-axis and compute the overall mean.
- Compute SS(mean): sum of squared residuals around the mean.
- Fit models:
- Least squares line(s) for linear regression.
- Group means for a t-test (separate means for control and mutant).
- Combine via a design matrix to represent group membership for each point:
- For a control point:
- For a mutant point:
- Equivalently:
- Compute SS(fit): sum of squared residuals around the fitted line(s) or group means.
- Calculate the F-statistic and p-value for the t-test.
ANOVA
- ANOVA generalizes the t-test to compare more than two groups by partitioning variance into between-group and within-group components.
t-tests and linear regression are closely related; ANOVA provides the framework for multi-group comparisons. A common setup is mutant vs. control mice with mouse size vs. mouse weight as covariates.