Main Ideas of Linear Regression

1. Introduction and fundamentals of linear regression

Linear regression is a statistical modeling technique used to describe the linear relationship between a dependent variable and one or more independent variables by fitting a straight line to the data to facilitate predictions. The core methodology discussed here for finding this best-fit line is the Ordinary Least Squares (OLS) method 2.

1.1 Components of a simple linear regression model

A simple linear regression model specifically utilizes only one predictor variable to model the target variable. The general structure involves several key components 3:

  • Target/Response/Dependent Variable (YY): This is the variable we aim to predict or explain.
  • Input/Predictor/Independent Variable (X1X_1): This is the variable used to make the prediction.
  • Intercept (β0\beta_0): This is the value of the target variable when the predictor variable is zero.
  • Slope Coefficient (β1\beta_1): This dictates the magnitude and direction of the relationship between X1X_1 and YY.
  • Stochastic Component or Error Term (ϵ\epsilon): This represents the inherent randomness or variation not explained by the model.

The conceptual relationship is represented by the linear equation: Y=β0+β1X1+ϵY = \beta_0 + \beta_1 X_1 + \epsilon A diagram illustrating the components of a simple linear regression model formula.

1.2 The goal: Fitting a line to data

The fundamental goal when introducing linear regression is "fitting a line with data". This process involves finding the specific line that best summarizes the observed trend in the relationship between the predictor and the response variables.

When visualizing this, data points are scattered based on their observed values for the predictor (e.g., Height on the x-axis) and the response (e.g., Weight on the y-axis). The fitted regression line attempts to minimize the overall distance between itself and all observed data points5.

Example: In a Height versus Weight analysis, the data points represent individual observations, and the goal is to draw a line that captures the general positive correlation observed.

A scatter plot illustrating the relationship between Height and Weight, with a line of best fit determined by the Least-Squares method.

1.3 The Ordinary Least Squares (OLS) iterative fitting process

The OLS method determines the best-fit line through an iterative process focused on minimizing the total error associated with the model. This process involves several systematic steps to achieve the optimal line rotation 4 8.

Step 1: Initial visualization and line drawing

The initial step involves plotting the data points (scatter plot) and drawing an initial line passing through them 6.

A scatter plot displaying a relationship between Height (x-axis) and Weight (y-axis) with a horizontal line drawn across the data points.

Step 2: Measuring and summing squared residuals

Once an initial line is established, the model quantifies the error. This involves measuring the vertical distance from each individual data point to the current line; this distance is termed the residual. Each residual is then squared, and these squared distances are summed up to yield the Sum of Squared Residuals (SSR). Minimizing this total sum is the objective of OLS.

Tip: The residual (eie_i) for an observation ii is defined as the difference between the observed value (yiy_i) and the predicted value (y^i\hat{y}_i): ei=yi−y^ie_i = y_i - \hat{y}_i 7.

A scatter plot illustrating the concept of residuals in regression analysis, showing the vertical distance between data points and a fitted line.

Step 3 & 4: Iteration and re-evaluation

The next phase involves slightly rotating the initial line and then repeating Step 2: measuring the residuals, squaring them, and calculating the new SSR 9.

A scatter plot showing the relationship between Height (x-axis) and Weight (y-axis), with a line of best fit being adjusted.

This rotation and re-computation are performed multiple times to explore various line orientations and their resulting error measurements 10.

A scatter plot illustrating the relationship between Height and Weight, with a regression line and vertical dashed lines representing the residuals.

Step 5: Identifying the minimum error

After testing several different rotations, the Sum of Squared Residuals is plotted against the corresponding rotation applied. The goal is to locate the rotation angle that corresponds to the absolute lowest value for the SSR 11.

A scatter plot illustrating the concept of residuals in linear regression, showing data points and a fitted line.

The rotation that yields the least sum of squares is the one used to define the line of best fit. This determination of the optimal line based on the minimum SSR is precisely why the fitting technique is called the Least Squares Method 12 13.

A scatter plot illustrating the relationship between Height and Weight, with a line of best fit demonstrating the least squares method.

Tip: Once the least squares line is found, further analysis typically involves calculating the RR-squared value (Goodness of Fit) and performing hypothesis tests (e.g., calculating the p-value for the test of significance) 1.

2. Calculating and interpreting R-square and significance testing

This section details the calculation and interpretation of R-square (R2R^2) as the measure of goodness of fit in regression analysis, which quantifies the reduction in variance achieved by the model, and introduces the concept of the p-value for testing statistical significance.

2.1 Quantifying variance reduction using R-square

R-square, or the coefficient of determination, measures how well the regression model fits the data by quantifying the proportion of variance in the dependent variable that is predictable from the independent variable(s). The process involves comparing the variability of the data points around the mean versus the variability around the fitted regression line 14.

The core concept involves dimensionality reduction to isolate the variance components. If we start with a bivariate plot (e.g., Height vs. Weight), we first analyze the total variation in the dependent variable (Weight) by projecting the data onto the vertical axis (Weight axis) to find the mean weight.

This visual demonstrates the process of removing the height dimension from a bivariate scatter plot by projecting the data points onto the vertical axis, effectively creating a one-dimensional representation based on weight.

Next, the average weight (mean weight\text{mean weight}) is computed for all observations plotted along the vertical axis.

A simple coordinate system illustrating the concept of computing the average weight from a set of data points plotted along the vertical axis.

The total variability remaining when only the mean is known is quantified by calculating the Sum of Squares around the Mean, denoted as SS(mean)\text{SS(mean)}: SS(mean)=∑(yi−yˉ)2\text{SS(mean)} = \sum (y_i - \bar{y})^2 This calculation measures the distance of each data point from the mean, squares these distances, and sums them up . This value, SS(mean)\text{SS(mean)}, represents the raw variation in the dependent variable before the model is applied 17.

2.2 Calculating the Sum of Squares for the Fit

Once the regression line (line of best fit) is established, we calculate the error or residual variance—the distance between the actual data points and the fitted line.

A scatter plot showing the relationship between Height and Weight, with a regression line fitted to the data points and vertical dashed lines indicating the residuals (distance from data point to the line).

The variation around the least squares regression line is called SS(fit)\text{SS(fit)} . This represents the variation around the least squares line after accounting for the independent variable (Height) 19 20.

This image compares the raw variation in weight (left) with the variation around the least squares regression line (right) for weight versus height.

When height is taken into account, the remaining variation in weight is reduced compared to the variation around the simple mean. This reduction signifies that some of the weight variability is explained by height (taller people tend to be heavier) 21.

Example: In the Height vs. Weight example:

  • The initial variance relative to the mean (SS(mean)\text{SS(mean)}) was 44.3 units squared.
  • The variance remaining after fitting the model (SS(fit)\text{SS(fit)}) was 15.59 units squared .

2.3 Interpreting the R-square Value

R-square is calculated as the proportion of variance explained, derived from the reduction in variability achieved by the model: R2=Variance(mean)−Variance(fit)Variance(mean)R^2 = \frac{\text{Variance}(\text{mean}) - \text{Variance}(\text{fit})}{\text{Variance}(\text{mean})} This formula, often expressed using Sums of Squares as SS(mean)−SS(fit)SS(mean)\frac{\text{SS(mean)} - \text{SS(fit)}}{\text{SS(mean)}} or 1−SS(fit)SS(mean)1 - \frac{\text{SS(fit)}}{\text{SS(mean)}}, yields the proportion of variance in the dependent variable explained by the independent variable(s) .

In the running example, the calculated R2R^2 was 0.648, meaning that 64.8% of the variation in weight is explained by height . This demonstrates a 64.8% reduction in the variation of weight once height is included in the model 22 23.

A scatter plot comparing weight and height shows a positive linear relationship, illustrating how height explains some variation in weight.

The interpretation of the boundaries of R2R^2 helps contextualize the fit:

  • Perfect Fit (R2=1R^2 = 1 or 100%100\%): If Variance(fit)=0\text{Variance(fit)} = 0, the regression line passes perfectly through all data points. Height explains 100%100\% of the variation in weight . A scatter plot comparing weight and height shows a positive linear relationship, illustrating how height explains some variation in weight.
  • No Fit (R2=0R^2 = 0): If Variance(mean)=Variance(fit)\text{Variance(mean)} = \text{Variance(fit)}, the model explains none of the variation. Knowing the height provides no useful information about the weight 26. This visual compares the variance of weight around the mean weight (left) versus the variance around the fitted model (right) to illustrate an R-squared calculation of 0%.

Tip: Always remember that R2R^2 is interpreted in terms of variance explained, not the strength of the slope itself. A high R2R^2 suggests the model accounts for a large portion of the total data spread 25.

2.4 Testing for significance (p-value)

While R2R^2 measures how much variance is explained, the next crucial step is determining if this relationship is statistically significant, which is done by calculating the p-value (Test of Significance) .

Tip: Calculating the p-value involves rigorous statistical testing that confirms whether the observed relationship is likely due to chance or reflects a true underlying relationship in the population .

This significance testing will be demonstrated in the actual application phase of the analysis 27.

Common mistakes to avoid

  • Review all topics thoroughly before exams
  • Pay attention to formulas and key definitions
  • Practice with examples provided in each section
  • Don't memorize without understanding the underlying concepts

© 2026 Maeve. All rights reserved. This content is protected by copyright.

See also