About Linear and Polynomial Regression Calculator
Paste pairs of numbers, one x and y per line, straight from a spreadsheet, and see the least-squares line through them: its equation, slope and intercept, R² and adjusted R², the standard error, the correlation coefficient and every residual, with a scatter plot of the points and the fitted line.
When a straight line is the wrong shape, choose a quadratic, cubic or higher polynomial up to degree 6. Enter an x value to predict y there; the result warns when that x lies outside your data, where a fitted curve is least to be trusted.
How it works
- The coefficients minimise the sum of squared vertical distances from the points to the curve (ordinary least squares).
- Before fitting, x and y are centred on their means and scaled to the range −1 to 1, and the system is solved by QR decomposition rather than the normal equations, so large values such as years or prices in the millions keep their precision.
- R² is the share of the variation in y that the curve explains. Adjusted R² and the standard error take the number of coefficients into account, so they are only defined with more points than coefficients.
- A fit of degree d needs at least d + 1 different x values. Repeated x values are allowed; each point counts once.
Questions
How should I enter the data?
One point per line, x first and then y, separated by a comma, tab, semicolon or spaces, as cells copied from two spreadsheet columns arrive. Use a point for decimals. A first line of column names is read as axis labels, and blank lines or lines starting with # are skipped.
Which degree should I choose?
Start with a straight line and look at the residuals: if they curve in a clear pattern, try degree 2 or 3. A higher degree always raises R², but it starts to follow the noise and can swing wildly between and beyond the points. Compare adjusted R², which allows for the extra coefficients.
Why does it show a second, centred equation?
When the x values are far from zero compared with their spread (years, for instance) and the degree is high, the expanded coefficients are huge numbers that cancel each other out, and typing them into another program would give the wrong curve. The tool then also shows the same curve in powers of x minus the mean of x, which keeps its precision.
How much data can it take?
Up to 10,000 points. The plot draws up to 2,000 of them, spread evenly through the data, and the residuals table lists the first 500; the fit always uses every point. The data is not put in the page address.
Everything you enter here is processed in this browser tab. Nothing is uploaded, logged or shared. How privacy works here.