Linear Regression & Correlation Calculator
Paste x,y data for the least-squares line, Pearson r and r², standard errors, t-tests, p-values, residual plot and prediction intervals.
Still loading. If the tool doesn’t appear, reload this page.
About this tool
Linear Regression & Correlation Calculator
Paste x,y data to get the least-squares line, r and r², standard errors, t-tests, p-values, a residual plot and prediction intervals.
Simple linear regression fits the straight line ŷ = b₀ + b₁x that minimises the sum of squared residuals: b₁ = Sxy ÷ Sxx and b₀ = ȳ − b₁x̄. Paste x,y pairs to get that line with Pearson r, r², standard errors, t-tests and p-values (n − 2 degrees of freedom), plots and prediction intervals, using the NIST/SEMATECH e-Handbook formulas.
How to use Linear Regression & Correlation Calculator
- 1
Paste or type your data, one x, y pair per line, or load the study-hours example or the NIST Norris dataset.
- 2
Choose the confidence level for the intervals: 90 %, 95 % or 99 %.
- 3
Read the fitted line, r and r², then the coefficient table with standard errors, t statistics and p-values, and the ANOVA table.
- 4
Check the scatter plot and the residual plot to see whether a straight line suits the data.
- 5
Enter a new x to get the predicted y with a confidence interval for the mean and a prediction interval for one new value.
Why use Linear Regression & Correlation Calculator
Verified against NIST
The NIST StRD Norris dataset is built in. Every certified value — both coefficients, their standard errors, the residual standard deviation, r², the sums of squares and F — is reproduced to its 15 printed digits, within the last-digit rounding of double precision.
Exact sums
Your decimals are read exactly and the sums of squares are formed in whole-number (BigInt) arithmetic, so large offsets such as years or calibration counts in the billions do not lose precision.
The whole output, not just the line
Coefficient table with t and p, an ANOVA table, adjusted r², confidence intervals at 90 %, 95 % or 99 %, a scatter plot with confidence and prediction bands, and a residual plot that flags standardized residuals beyond ±2.
Paste from anywhere
Commas, tabs, semicolons or spaces; a header row becomes the axis labels; decimal commas work in tab- or semicolon-separated data. Nothing is uploaded.
Common use cases
- Fitting a calibration line for a lab instrument and reading the slope, intercept and their standard errors for the write-up
- Testing whether a relationship is real: the slope's t statistic and p-value test the null hypothesis that the slope is 0
- Predicting a value at a new x with a confidence interval for the mean and a wider prediction interval for a single new observation
- Checking whether a straight line is the right model by looking for curves or funnels in the residual plot
Frequently asked questions
How do you calculate a linear regression line?
Compute the means x̄ and ȳ, then Sxx = Σ(x − x̄)² and Sxy = Σ(x − x̄)(y − ȳ). The slope is b₁ = Sxy ÷ Sxx and the intercept is b₀ = ȳ − b₁x̄. For x = 1 to 8 with scores 52, 55, 61, 64, 70, 72, 79, 83, Sxx = 42 and Sxy = 188, so b₁ = 4.476 and b₀ = 46.857.
What is the difference between r and r²?
r is the Pearson correlation coefficient, from −1 to 1, and its sign gives the direction of the relationship. r² is its square, from 0 to 1, and is the share of the variation in y that the line explains. r = 0.9 means r² = 0.81, or 81 % of the variation.
How do I know if the slope is statistically significant?
Divide the slope by its standard error to get t, and compare it with the t distribution on n − 2 degrees of freedom. The two-sided p-value is the probability of a |t| at least that large if the true slope were 0; p below your chosen α, often 0.05, means the slope is significant at that level. In simple regression this test is identical to the ANOVA F-test, since F = t².
What is the difference between a confidence interval and a prediction interval?
A confidence interval covers the mean of y at a given x; a prediction interval covers a single new observation, so it adds the scatter of individual points and is always wider. Their standard errors are s·√(1/n + (x₀ − x̄)²/Sxx) and s·√(1 + 1/n + (x₀ − x̄)²/Sxx).
How accurate is this regression calculator?
On the NIST Statistical Reference Datasets' Norris problem it matches all certified values to their 15 printed digits, within the rounding of the last digit. It reads decimals exactly and forms every sum of squares and cross-product in exact integer arithmetic, so rounding enters only at the final divisions and square roots. p-values use the regularised incomplete beta function, the same code as the critical value tables on this site.
What should a residual plot look like?
A shapeless horizontal band around zero. A curve means a straight line is the wrong model, and a funnel that widens means the spread of y changes with x, which makes the standard errors and p-values unreliable. Points with a standardized residual beyond ±2 are marked for a closer look.
Embed this tool on your site
Add the Linear Regression & Correlation Calculator widget to your blog or website — free, responsive, no signup. Just keep the “Widget by AltFTool” credit link visible.
<iframe src="https://www.altftool.com/embed/widget/linear-regression-calculator"
title="Linear Regression & Correlation Calculator — free AltFTool widget"
width="100%" height="640" style="border:0;border-radius:12px;overflow:hidden"
loading="lazy" referrerpolicy="no-referrer-when-downgrade" allow="clipboard-write"></iframe>
<p style="font-size:12px;margin:4px 0 0">Widget by <a href="https://www.altftool.com/tools/all/linear-regression-calculator?utm_source=embed&utm_medium=widget" rel="nofollow">AltFTool — free online tools</a></p>