Fit a least squares line to your X and Y pairs, then look at the residual plot before you trust the R² above it. A straight line fits almost any data. The residuals tell you whether it should.
| # | X | Y |
|---|
No fit yet
Enter at least two pairs with different X values, then press Fit the line. Sample datasets above load instantly if you want to see the output first.
Predict a Y value
| # | X | Y observed | Y predicted | Residual |
|---|
Every straight line drawn through a scatter of points misses most of them. Least squares picks the one line where the squared vertical misses add up to the smallest total. Nothing about the method asks whether a line was the right shape in the first place.
Two numbers come out of the fit. The slope says how much Y moves for a one unit move in X. The intercept says what the line predicts when X sits at zero. A slope of 4.2 on ad spend and revenue reads as four dollars and twenty cents of revenue per extra dollar spent, inside the spending range you actually observed.
Squaring the misses is the part with consequences. A point sitting ten units off the line pulls a hundred times harder than a point sitting one unit off. One mistyped row drags the whole line toward itself, and the fit still returns a clean equation with no complaint. Load the One bad outlier sample above to watch a good fit collapse from a single point.
The intercept is the value of the line at X equals zero, and X equals zero is frequently nowhere near your data. Fit height against age using adults aged 20 to 60 and the intercept describes a newborn, which the model never saw. Read the intercept as an anchor that positions the line, not as a prediction, unless zero falls inside your observed X range.
R² reports the share of variation in Y the line accounts for. An R² of 0.87 means the line explains 87 percent of how Y spreads out, leaving 13 percent to everything else.
High values feel reassuring and mislead in three specific ways.
Reading an R² value
Thresholds shift by field. A 0.30 in psychology research and a 0.30 in a calibration lab mean opposite things about the quality of the work.
Each vertical stub in the scatter above is one residual, the distance from an observed point down or up to the line. Their pattern is the honest diagnostic, and four shapes cover nearly everything you will see.
Scattered with no pattern
Residuals fall above and below the line at random across the X range. A line was the right model. Read the slope and move on.
A U shape or an arch
Residuals sit above the line at both ends and below in the middle, or the reverse. The relationship bends. Fit a curve, or log-transform one variable and refit.
A widening fan
Small misses at low X, large misses at high X. Variance grows with the level, which happens constantly with money and counts. The slope stays usable, the standard errors do not.
One enormous stub
A single point far off while the rest sit close. Go back to the source row. Data entry beats statistics as an explanation most of the time.
The four sample datasets on the calculator produce these four shapes in order, so you get a feel for the difference between a fit that works and a fit that only scores well.
A shop records monthly ad spend in thousands and revenue in thousands for six months.
| Month | Ad spend (X) | Revenue (Y) |
|---|---|---|
| January | 2 | 18 |
| February | 3 | 23 |
| March | 5 | 30 |
| April | 6 | 36 |
| May | 8 | 41 |
| June | 9 | 48 |
The fit returns ŷ = 4.08x + 10.2267 with R² of 0.9888. Each extra thousand in ad spend lines up with about 4,080 in revenue across the range from 2 to 9.
Now the part the numbers do not cover. The intercept near 10.23 suggests about 10,230 in revenue at zero ad spend, which is plausible for a shop with existing customers, so the intercept survives a sanity check. Predicting at X equals 40 does not survive one. No month in the record spent above 9, the line has no evidence about what happens at four times the maximum, and returns diminish in real ad markets. The prediction box flags any X outside the observed range for exactly that reason.
Know these limits before a result goes into a report.
Slope reading, R² thresholds, outliers, sample size, and what regression will not tell you.
It depends entirely on the field. Physics and calibration work routinely see 0.95 and above, because the underlying relationship is close to deterministic. Marketing data at 0.60 is a strong result. Human behaviour research treats 0.20 as meaningful. Compare your R² against typical values in your own domain rather than against a universal threshold, and always look at the residual plot alongside it.
The math runs from two points, but two points give a perfect fit and zero information. Ten pairs is a reasonable floor for a slope you would report, and thirty starts giving stable standard errors. Below ten, a single unusual observation controls the result, so check the residual table for one point dominating the fit.
Least squares minimises squared vertical distances, so a point twice as far off pulls four times as hard. Points at the extreme ends of the X range pull harder still, because the line pivots around the middle of the data. A far point at high X swings the slope more than the same distance at the centre would.
The correlation coefficient r runs from -1 to +1 and carries the direction of the relationship. R² is r squared, runs from 0 to 1, and drops the sign in exchange for a clean interpretation as the share of variance explained. An r of -0.9 and an r of +0.9 both produce R² of 0.81, describing equally tight fits sloping opposite ways.
The calculator will compute the value and mark it as extrapolation. Whether the number means anything depends on knowledge the data does not contain. A linear relationship holding between X values of 2 and 9 says nothing about behaviour at 40, and most real relationships bend or saturate eventually. Treat any extrapolated prediction as a hypothesis rather than a result.
A curved residual pattern means a line is the wrong shape. Try taking the log of Y and refitting, which straightens exponential growth. Log both variables for power relationships. Where the pattern is a genuine arch with a peak or trough, a quadratic term is needed and a straight line will never describe it.
Swapping the columns gives a different line. Regressing Y on X minimises vertical distances, and regressing X on Y minimises horizontal ones, so the two slopes are not reciprocals of each other. Put the variable you are predicting in the Y column. The correlation r stays identical either way.
No. Parsing, fitting, and plotting all run in your browser with JavaScript. Nothing is uploaded and nothing is stored, so closing the tab discards the dataset. Copy the equation or the residual table before you leave if you need a record.