If you have ever wondered how a researcher predicts next year’s library budget from this year’s footfall, or how an economist forecasts demand from price, the answer often lies in one of the most widely used tools in statistics: linear regression. It takes two related variables and draws a single straight line through the data that captures their relationship, and then uses that line to make predictions. This post breaks down what linear regression is, how the line is actually calculated using the least squares method, and how you can apply it to real numbers to estimate future outcomes.

Table of Contents

The concept of linear regression

Linear regression is a statistical method that models the relationship between a dependent variable and one or more independent variables using a straight-line equation. In statistical terms, it estimates the relationship between a response variable and one or more explanatory variables. When there is only one independent variable, it is called simple linear regression; when there are two or more, it becomes multiple linear regression.

The core idea is straightforward. The dependent variable is the outcome you want to predict or explain. The independent variable is the factor you use to do the predicting. For example, if you are predicting sales from advertising spend, sales is the dependent variable and advertising expenditure is the independent variable. The dependent variable is also known as the explained, outcome, or criterion variable, while the independent variable is also called the predictor or explanatory variable.

The straight-line equation

Linear regression assumes that the relationship between the two variables can be approximated by a straight line. This line is expressed through a simple equation:

Y = a + bX

Here, Y is the predicted value of the dependent variable, X is the value of the independent variable, a is the intercept (the predicted value of Y when X equals zero), and b is the slope (how much Y changes for every one-unit increase in X). You may also see this written as Y = mx + c, or in statistical notation as Y = β₀ + β₁X, but every version describes the same straight line. The slope captures the direction and strength of the relationship: a positive slope means Y rises as X rises, while a negative slope means Y falls as X rises.

Why we use it

Regression is valuable because it does two things at once. First, it tells us whether a meaningful relationship exists between variables. Second, it lets us forecast: once we know the line, we can plug in a new value of X and read off the expected value of Y. The linear least squares method is by far the most widely used modelling approach, and it is what most people mean when they simply say “regression.” It also forms the foundation for many advanced techniques, which is why understanding it well pays off across research and analytics.

How the regression line is calculated

The obvious question is: out of the infinite number of straight lines we could draw through a cluster of points, which one is the “best”? This is where the least squares method comes in. The method finds the best-fit line by minimizing the sum of the squared residuals, where a residual is the difference between an observed value and the value predicted by the line.

Understanding residuals

A residual is simply the vertical distance from each actual data point to the regression line. If a point sits above the line, its residual is positive; if below, negative. The least squares method squares each of these distances before adding them together. Squaring serves two purposes: it removes the negative signs so positives and negatives do not cancel out, and it penalizes larger errors more heavily. The line that produces the smallest total of these squared distances is the line of best fit. A smaller residual sum indicates a closer fit to the data.

The formulas for slope and intercept

To fit the line, we need to calculate the slope (b) and the intercept (a). The slope is calculated first using the following formula, where x̄ and ȳ represent the mean of the X values and the mean of the Y values:

b = Σ[(xᵢ − x̄)(yᵢ − ȳ)] / Σ[(xᵢ − x̄)²]

In words, you multiply each deviation of X from its mean by the matching deviation of Y from its mean, add up these products, and divide by the sum of the squared deviations of X. This gives the slope of the line.

Once the slope is known, the intercept is found by subtracting the slope times the mean of X from the mean of Y:

a = ȳ − b·x̄

This equation carries a neat implication: the regression line always passes through the point of average values (x̄, ȳ). In other words, when X equals its own average, Y is predicted to equal its own average. The least square method for fitting a line can therefore be summarized in clear steps: label the X and Y values, compute their means, work out the slope using the deviations, calculate the intercept, and finally write the equation Y = a + bX.

A worked example with real data

Theory becomes clear once you push numbers through it. Suppose a college librarian wants to understand how the number of hours students study in the library relates to their exam scores, and then predict a score for a study time not yet observed. Consider the following small dataset.

The data

Five students reported their weekly study hours in the library (X) and their exam scores out of 100 (Y):

Student 1: X = 2, Y = 50
Student 2: X = 4, Y = 60
Student 3: X = 6, Y = 70
Student 4: X = 8, Y = 80
Student 5: X = 10, Y = 90

Step one: find the means

The mean of X is (2 + 4 + 6 + 8 + 10) ÷ 5 = 30 ÷ 5 = 6. The mean of Y is (50 + 60 + 70 + 80 + 90) ÷ 5 = 350 ÷ 5 = 70.

Step two: calculate the deviations and products

Next, find how far each value sits from its mean. For X, the deviations (xᵢ − x̄) are −4, −2, 0, 2, and 4. For Y, the deviations (yᵢ − ȳ) are −20, −10, 0, 10, and 20.

Now multiply each pair of deviations together to get the product (xᵢ − x̄)(yᵢ − ȳ): (−4 × −20) = 80, (−2 × −10) = 20, (0 × 0) = 0, (2 × 10) = 20, and (4 × 20) = 80. The sum of these products is 80 + 20 + 0 + 20 + 80 = 200.

Step three: calculate the squared deviations of X

Square each X deviation: (−4)² = 16, (−2)² = 4, (0)² = 0, (2)² = 4, and (4)² = 16. The sum of squared deviations is 16 + 4 + 0 + 4 + 16 = 40.

Step four: calculate the slope

Using the slope formula, b = 200 ÷ 40 = 5. This means that for every additional hour a student studies in the library, the model predicts the exam score will rise by 5 marks.

Step five: calculate the intercept

Using a = ȳ − b·x̄, we get a = 70 − (5 × 6) = 70 − 30 = 40. So the intercept is 40, the predicted score for a student who studies zero hours.

Step six: write the equation and predict

Putting it together, the regression equation is:

Y = 40 + 5X

This single equation now lets us forecast. If a new student plans to study 7 hours per week, the predicted score is Y = 40 + (5 × 7) = 40 + 35 = 75 marks. Notice that 7 hours was never in our original data, yet the line allows us to estimate an outcome for it. This ability to predict results based on an existing set of data is exactly why the method is used so widely by statisticians, economists, managers, and researchers.

Where linear regression is applied

The reach of regression goes far beyond classroom examples. It is used in market research and the analysis of customer survey results, in forecasting demand from price, and in estimating budgets from usage patterns. In library and information science specifically, you might use it to project annual circulation figures from membership growth, or to estimate staffing needs from expected visitor numbers. The interpretation always stays the same: the slope tells you how much the outcome moves per unit of input, and the equation lets you predict.

Keep the assumptions in mind

Linear regression is powerful but not unconditional. It rests on a few key assumptions: the relationship between the variables should be roughly linear, the observations should be independent of one another, the spread of residuals should stay fairly constant, and the residuals should be approximately normally distributed. The method is also sensitive to outliers, since one extreme point can pull the line noticeably. Before trusting a regression line, it is wise to plot the data on a scatter plot to check that a straight line is a sensible approximation in the first place. When the relationship is clearly curved, a non-linear model may serve better.

Used thoughtfully, linear regression turns a scatter of past observations into a clean, interpretable rule for predicting the future, all from a single straight line and a few sums.

What do you think? If you collected study-hour and exam-score data from your own classmates, do you think a straight line would fit the relationship well, or would the points scatter too widely? And which variable in your own field of study would you most want to predict using a regression line?

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

References
  1. https://en.wikipedia.org/wiki/Linear_regression
  2. https://www.scribd.com/document/547864464/Linear-Regression
  3. https://www.itl.nist.gov/div898/handbook/pmd/section1/pmd141.htm
  4. https://en.wikipedia.org/wiki/Least_squares
  5. https://www.technologynetworks.com/informatics/articles/calculating-a-least-squares-regression-line-equation-example-explanation-310265
  6. https://people.duke.edu/~rnau/mathreg.htm
  7. https://www.geeksforgeeks.org/maths/least-square-method/
  8. https://www.freecodecamp.org/news/the-least-squares-regression-method-explained/
  9. https://www.geeksforgeeks.org/maths/linear-regression-formula/
  10. https://sixsigmadsi.com/glossary/simple-linear-regression/

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Research Methodology

1 Research- Meaning, Concept, Need

  1. Definition of Research
  2. Need for and Purpose of Research
  3. Conceptual Framework of Research and Terminology
  4. Basic and Applied Research
  5. Scientific Method
  6. Research Design
  7. Value of Studying Research Methodology for Library and Information Professionals

2 Historical Research

  1. Historical Research
  2. Definitions
  3. What is Not Historical Research?
  4. What Constitutes Historical Research?
  5. Advantages
  6. Limitations
  7. Purposes
  8. Scope of Application
  9. Types
  10. Importance in LIS
  11. Process of Conducting Research
  12. Internet
  13. Scientific Research
  14. Problems

3 Survey Research

  1. Data Collection
  2. Sampling
  3. How to Conduct a Survey
  4. Problems
  5. Instruments of Survey Research

4 Experimental Research

  1. Experimentation
  2. Hypothesis
  3. Research Procedure
  4. Validity
  5. Design of the Experiment
  6. Limitations of Experimental Method

5 Fundamental, Applied and Action Research

  1. Scientific Method
  2. S. R. Ranganathan’s Spiral of Scientific Method
  3. Basic Research
  4. Applied Research
  5. Action Research
  6. Descriptive Research
  7. Comparative Research
  8. Exploratory Research
  9. Diagnostic Research
  10. Social Research

6 Measurement of Variables

  1. Types of Variables
  2. Measurement of Qualitative Data
  3. Census versus Sample Survey
  4. Sampling Procedure
  5. Types of Sampling

7 Data Presentation

  1. Preparation of a Table
  2. Tabular Presentation
  3. Graphical Presentation
  4. Bar Diagrams
  5. Pie Chart

8 Statistical Techniques

  1. Measures of Central Tendency
  2. Arithmetic Mean
  3. Median
  4. Mode
  5. Measures of Dispersion
  6. Variance and Standard Deviation
  7. Coefficient of Variation
  8. Correlation
  9. Pearson’s Product Moment Correlation
  10. Regression Analysis
  11. Linear Regression
  12. Non-linear Regression
  13. Time Series Analysis

9 Statistical Packages

  1. Statistical Packages
  2. Microsoft Excel
  3. SPSS
  4. Other Software for Statistical Analysis

10 Observation Method

  1. Meaning and Definition
  2. Purpose
  3. Characteristics
  4. Planning and Process of Observation
  5. Recording of Data
  6. Types
  7. Advantages and Disadvantages
  8. Application in Libraries and Information Centers

11 Questionnaire Method

  1. Questionnaire Method: Definition
  2. Questionnaire Construction
  3. Types of Questionnaires
  4. Types of Questions
  5. Use of Scales
  6. Precautions in Questionnaire Construction
  7. Pretesting of Questionnaire
  8. Distribution of Questionnaire
  9. Response Rate
  10. Advantages and Limitations of Questionnaire Method

12 Interview Method

  1. Introduction
  2. Interviewing
  3. Types of Interviews
  4. Structured Interview
  5. Unstructured Interview
  6. Focussed Interview
  7. Non-directive Interview
  8. Clinical Interview
  9. Telephonic Interview
  10. Computer Assisted Telephone Interviewing (CATI) System
  11. Interview Process
  12. Advantages and Limitations of Interview Method

13 Experimental Method

  1. Research Problem Appropriate for an Experiment
  2. Parts of an Experiment
  3. Steps in Planning an Experimental Research
  4. Laboratory Experiment and Field Experiment
  5. Experimental Research Design
  6. Advantages, Disadvantages, and Limitations of Experimental Method

14 Case Study

  1. Case Study: Definition, Characteristics, and Importance
  2. Uses, Advantages, Disadvantages, and Limitations of Case Study
  3. Research Problem Appropriate for a Case Study
  4. Research Design in Case Study
  5. Steps in Case Study Method
  6. Case Study vs Case Work and Other Methods

15 Research Design

  1. What is Research Design?
  2. Need and Purpose
  3. Functions of Research Design
  4. Types of Research Design
  5. Based on Nature of Investigation
  6. Based on Data Collection Methods
  7. Based on Number of Contacts Made with the Subjects
  8. Based on Reference Period
  9. Summary

16 Research Plan

  1. Definition
  2. Need and Purpose
  3. Functions
  4. Types
  5. Structure
  6. Funding
  7. Monitoring
  8. Ethics

17 Statistical Inference

  1. Concept of Statistical Inference
  2. Statistical Estimation
  3. Concept of Hypothesis Testing
  4. Critical Regions and Types of Errors
  5. Testing of Hypothesis for a Single Sample
  6. Test for Difference between Two Samples
  7. Contingency Table

18 Presentation of Results

  1. Research Reports and their Types
  2. Importance and Significance of Research Reports
  3. Preparation of a Research Proposal
  4. Research Reports: Plan Outline, Format and Contents
  5. Preparation and Organisation of Research Notes
  6. Drafting of Research Reports
  7. Language and Grammar
  8. Physical Production