Calculator-Online.net

Calculator Online

Calculator-Online.net

Calculator Online

Follow Us On:

Your Result is copied!
Advertisement

Linear Regression Calculator

Advertisement

The linear regression calculator helps you determine the line of best fit using the least squares method. It provides instant results along with a graphical representation of the regression line for your dataset.

What Is Linear Regression?

“Linear regression is a statistical technique used to predict the value of a dependent variable based on one independent variable.” It assumes a straight-line relationship between the variables. This calculator makes it easy to compute the slope, intercept, and predicted values accurately.

Linear Regression Formula:

The equation for the line of best fit is:

ŷ = bX + a

Where:

ŷ = predicted value of the dependent variable

b = slope of the line

X = independent variable

a = y-intercept (value of y when X = 0)

To calculate the slope (b) and intercept (a), use the following formulas:

b = SP / SSx

SP (Σ(X - Mx)*(Y - My)) = sum of the products of deviations of X and Y from their means

SSx (Σ(X - Mx)²) = sum of squared deviations of X from its mean

a = My - b * Mx

Where Mx and My are the means of X and Y respectively.

How To Find the Line of Best Fit?

Here’s an example to illustrate how linear regression works:

Example:

Calculate the least squares regression line for the dataset:

{(1, 2), (3, 5), (4, 4), (6, 7)}

Also, predict the value of Y for X = 2 and X = 5.

Solution:

Step 1: Calculate sums and means:

Sum of X = 1 + 3 + 4 + 6 = 14

Sum of Y = 2 + 5 + 4 + 7 = 18

Mean of X = Mx = 14 / 4 = 3.5

Mean of Y = My = 18 / 4 = 4.5

Step 2: Compute deviations, squares, and products:

X - Mx Y - My (X - Mx)² (X - Mx)*(Y - My)
-2.5 -2.5 6.25 6.25
-0.5 0.5 0.25 -0.25
0.5 -0.5 0.25 -0.25
2.5 2.5 6.25 6.25

Step 3: Calculate slope (b) and intercept (a):

SSx = 6.25 + 0.25 + 0.25 + 6.25 = 13

SP = 6.25 - 0.25 - 0.25 + 6.25 = 12

b = SP / SSx = 12 / 13 ≈ 0.923

a = My - b * Mx = 4.5 - (0.923 * 3.5) ≈ 1.37

Step 4: Form the regression equation:

ŷ = 0.923X + 1.37

Step 5: Predict Y for X = 2 and X = 5:

X Estimated Y
2 3.22
5 6.485

The graphical plot of the line of best fit clearly shows the trend of the dataset, helping visualize the relationship between X and Y.

animal image
sales modal popup close

Easter into Action, Save With Satisfaction

UPTO

50 %

OFF

Online Calculator

Calculator Online

Get the ease of calculating anything from the source of calculator online

Email us at

Contact Us

© Copyrights 2026 by Calculator-Online.net