Skip to content
callum.science

Linear Regression

Least-squares fit for pasted x,y data, with standard errors, R² and a residual plot.

Data

x, y, and σy if you have it

One point per line, separated by a comma, tab, semicolon or space. A first line that is not numbers is taken as a header. Where a semicolon or tab is doing the separating, a comma is read as a decimal point.

Fit

Each point weighted by 1/σ², so the best-measured points pull hardest.

Line of best fit

—

Parameters

± one standard error

Slope
—
Intercept
—
Pearson r
—
R²
—
Standard error of the estimate
—

Scatter about the line, in units of y

Points fitted
—
Degrees of freedom
—
Reduced χ²
—

Weighted fits only

Data and fit

y vs x

The dashed line is the least-squares fit evaluated at each measured x.

Residuals

observed minus fitted, vs x

Scatter with no pattern is what a straight line should leave behind. A curve or a fan here says the model, not the noise, is what is off.