Regression Calculator

Linear, Exponential, Power, Logarithmic

Enter X and Y Data Pairs Below
     X     Y
     X     Y
     X     Y



How to Fit Lines and Curves to Data: Least Squares Regression

The method of least squares regression allows you to fit an equation through set of data points. In linear regression, the "best fit" line y = mx + b satisfies the condition that the sum of the squared vertical distances between the points and the line is minimized, hence the name least squares. You can adapt the method of linear least squares regression to find an exponential regression curve y = acx, power regression curve y = axc, or logarithmic regression curve y = a + cLn(x).

Step 1

To find the regression line y = mx + b, you must compute the following quantities from the paired x and y data:

x, y, ∑(x2), ∑(xy), ∑(y2)

Step 2

The slope of the regression line, m, is given by the formula

m = [∑(xy) - n(x)(y)]/[∑(x2) - n(x)2],

where n is the number of data points. Once you calculate m, the forumula for b is

b = y - mx

Step 3

You can compute the correlation coefficient which indicates how closely the line fits. The correlation coefficient ranges from -1 to 1, with -1 meaning perfect negative correlation (negative slope) and 1 meaning perfect positive correlation. When the coefficient is close to zero, data does not exhibit a linear relation. The correlation coeffeicient equation is

[∑(xy) - n(x)(y)]/sqrt[(∑(x2) - n(x)2)(∑(y2) - n(y)2)]

Step 4

You can obtain the equations for exponential, power, and logarithmic regression curves by linearizing the functions. For example, the equation y = acx can be linearized by taking the natural logarithm of both sides. Doing this yields Ln(y) = Ln(a) + Ln(c)x. This is now linear in the varialbes Ln(y) and x. You can solve for Ln(c) and Ln(a) by using the formulas for straight line regression, just replace the y data with Ln(y).

Similarly, the equation y = axc can be linearlized to Ln(y) = Ln(a) + cLn(x). This is now linear in the variables Ln(y) and Ln(x).

The equation y = a + cLn(x) is already linear in the variables y and Ln(x).

The regression calculator above will compute all four types of simple regression along with the correlation coefficients of each curve so that you can see which line or curve fits best.



© Had2Know 2010

Descriptive Statistics Calculator

How to Minimize the Sum of Perpendicular Offsets (Deming Regression)

How to Find the Equation of a Plane Through Three Points

How to Solve a System of Three Equations in Three Variables

How to Solve Rational Equations

How to Convert a Number to Roman Numerals