Statistical Inference

Least Squares and Regression in R

24:11

Plays from YouTube. Watch on YouTube

Why is the fitted regression line the one with the smallest squared errors?

Meet least squares and regression in r and learn residual squares, normal equations, coefficient formulas and R output through synthetic paired data, diagrams and independently worked mathematics.

We start with define the objective and differentiate with respect to intercept. OLS minimizes the sum of squared residuals. The fitted residuals sum to zero when an intercept is present.

From there, we develop differentiate with respect to slope, recover the intercept, residual orthogonality. Centered cross-products determine the fitted slope. The fitted line crosses the sample-mean point. OLS residuals are orthogonal to included regressors.

Then we examine likelihood connection, regression in r, model diagnostics and reporting, while separating estimation, prediction and explanation.

The big idea: Name your model, your estimate and your uncertainty. Regression fit quality alone is not a causal argument.

Learn regression and statistical inference visually, one mathematical mechanism at a time.