About Linear Regression Calculator
This linear regression calculator is free, needs no sign-up and runs in your browser, so your data is never uploaded. It fits the least squares line and reports the slope, intercept, correlation r, r², the standard errors and the p-value for the slope, with confidence intervals for the coefficients.
You also get the equation typeset in KaTeX, a scatter plot with the fitted line and a prediction band, a residual plot and a residuals table. Enter an x value to predict y with a prediction interval for one new observation and a confidence interval for the mean.
If a straight line is not the right shape, switch the model to polynomial (degree 2 to 6), exponential or logarithmic. A comparison table ranks them by R² and adjusted R² so you can see what each extra curve buys you.
How to use Linear Regression Calculator
- Paste two columns from a spreadsheet or type one x, y pair per line. A text first line is used as the axis names.
- Choose the model: linear, polynomial, exponential or logarithmic. For a polynomial, pick the degree.
- Read the equation and the statistics table. For the line, the slope p-value tests whether x helps predict y at all.
- Type an x value in the prediction box to get the predicted y and, for the linear model, its intervals.
- Check the residual plot. Residuals should scatter randomly around zero. A curve or a funnel means the model is wrong or the spread changes.
- Open the comparison table to see which model has the highest R², and look at adjusted R² before trusting a high degree.
Features
- Least squares line with slope, intercept, r, r², standard error of the estimate and of the slope.
- t test and p-value for the slope, with confidence intervals for slope and intercept.
- Prediction interval for one new point and confidence interval for the mean response.
- Polynomial regression of degree 2 to 6, exponential y = a·e^(bx) and logarithmic y = a + b·ln x.
- Model comparison table with R² and adjusted R².
- Equation in KaTeX, scatter plot with fitted curve and prediction band, and PNG download.
- Residual plot and a residuals table with fitted values.
- Step by step working for the least squares line, copyable as LaTeX.
Least squares formulas
The least squares line minimises the sum of the squared vertical distances from the points to the line. Its slope is the covariance of x and y over the variance of x, and the line always passes through the point of means.
The slope test uses t = m ÷ SE(m) with n - 2 degrees of freedom. Polynomial fits solve the normal equations. The exponential model is fitted on ln y and the logarithmic model on ln x.
m = Sxy / Sxx
b = mean y − m × mean x
r² = 1 − SSres / SStot
s = sqrt(SSres / (n − 2))
SE(m) = s / sqrt(Sxx)Worked examples
x = 1, 2, 3, 4, 5 and y = 2, 4, 5, 4, 5 gives y = 2.2 + 0.6x
r = 0.7746, r² = 0.6, standard error of the estimate 0.8944.
Predict y at x = 6 for the same data gives 5.8
The 95% prediction interval for one new observation is 1.68 to 9.92.
Models in this calculator
| Model | Equation | Needs |
|---|---|---|
| Linear | y = b + m·x | Any data, at least 3 points |
| Polynomial | y = c0 + c1·x + ... + ck·x^k | More points than the degree |
| Exponential | y = a·e^(b·x) | Every y above 0 |
| Logarithmic | y = a + b·ln x | Every x above 0 |
Good to know
Regression is not a license to extrapolate
The line describes the range of x in your data. Predicting far outside that range assumes the pattern continues, which often fails. The prediction interval also widens as x moves away from the mean of x.
Limits of this calculator
Standard errors, p-values and intervals are given for the linear model only. For the other models you get the equation, R², adjusted R² and residuals. Fits use the normal equations, which can lose accuracy for a high degree on data with large x values, so centre or rescale x if a fit looks wrong. At most 5000 points are accepted.
Privacy: how it works
- Everything is calculated by code running in your browser tab. Your data is not sent to Ulkaa or to any other server, and there is nothing to sign in to.
Tips
- A high R² does not prove a good model. Look at the residual plot as well.
- Prefer the lowest degree that fits. Adjusted R² drops when an extra term adds nothing.
- For the exponential model, R² is measured on the original y, so it can be compared fairly with the line.
- If the points form a curve that rises and levels off, try the logarithmic model.
Frequently asked questions
Is it really free?
Yes. There is no price, no trial and no credit card. Ulkaa Tool does the work with your own device, so there is no server bill to pass on to you.
Do I need an account?
No. There is no sign-up and no login. Open the page and use it. An Ulkaa account is not needed for anything on this tool.
Does it run in my browser?
Yes. Your data are processed by code running in your browser tab, on your own device.
Is my data uploaded?
No. Your data are never sent to Ulkaa or to anyone else. You can check this yourself by watching the Network tab in your browser developer tools while you use the tool.
How is the least squares line calculated?
The slope is Sxy divided by Sxx, the sum of cross deviations over the sum of squared x deviations. The intercept is the mean of y minus the slope times the mean of x. The steps panel shows the numbers for your data.
What does the p-value for the slope mean?
It tests whether the true slope is zero. A small p-value, below 0.05 for example, means the data give evidence that y changes with x.
What is the difference between a prediction interval and a confidence interval?
The confidence interval is for the average y at a given x. The prediction interval is for one new observation and is wider because it includes the scatter of individual points.
What is R squared?
The share of the variation in y that the model explains, from 0 to 1. For a straight line it equals r squared.
How many points do I need?
At least three for a line, since two points always fit perfectly and leave no degrees of freedom. More is better, and a polynomial needs more points than its degree.
Why does the exponential or logarithmic model say it cannot be fitted?
The exponential model takes the log of y, so every y must be above zero. The logarithmic model takes the log of x, so every x must be above zero.
Popular Linear Regression Calculator pages
- Least Squares Regression Line CalculatorPaste x, y data to get the line y = b + mx that minimises the squared errors.
- Line of Best Fit CalculatorPaste your points to see the best fit line on a scatter plot, with its equation and predictions.
- Polynomial Regression CalculatorPaste x, y data to fit a quadratic, cubic or higher degree curve, up to degree 6.
- Exponential Regression CalculatorPaste x, y data to fit y = a·e^(bx) and see the growth factor per step.