Statistics and research

Linear regression calculator

Least-squares line with standard errors, t-tests, R², ANOVA table, residuals and leverage, plus confidence and prediction intervals at any x.

Runs in your browser. What you enter stays on this page and is not uploaded.

Separate values with spaces, commas, tabs or new lines (paste a spreadsheet column). Use a point for decimals. The example is NIST’s Norris calibration data.

Results

Slope1.00212Intercept-0.262323R²0.999994p (slope)4.654e-90
Equation
ŷ = -0.26232307 + 1.0021168 x
R²
0.99999375
Adjusted R²
0.99999356
Correlation r
0.99999687
Residual standard error
0.884796396144 on 34 df
F statistic
5436385.5 on 1 and 34 df, p 4.654e-90
Predicted ŷ at x = 500
500.79609
95% confidence interval for the mean response
500.4882 to 501.10398
95% prediction interval for a new observation
498.97179 to 502.62038
Coefficients
TermEstimateStd. errortp-value95% CI lower95% CI upper
Intercept-0.2623230737740.232818234301-1.126730.2677-0.735466650.2108205
Slope1.002116818020.00042979684822331.614.654e-901.00124341.0029903
Analysis of variance
SourcedfSum of squaresMean squareFp-value
Regression14255954.132324255954.132325436385.54.654e-90
Residual3426.61739852940.78286466263
Total354255980.74972
Fitted values and residuals
#xyFitted ŷResidualLeverage hStudentized residual
10.20.1-0.061899710.16190.06920.1897
2337.4338.8337.851890.9481090.029361.088
3118.2118.1118.18788-0.08788480.04915-0.1019
4884.6888886.210211.789790.078892.108
510.19.29.8590568-0.6590570.06726-0.7713
6226.5228.1226.717141.382860.036541.592
7666.3668.5667.448111.051890.042191.215
8996.3998.5998.146660.3533370.10640.4224
9448.6449.1449.28728-0.1872810.02798-0.2147
10777778.9778.382440.5175550.057990.6027
11558.2559.2559.119280.08071530.032340.09274
120.40.30.138523650.1614760.069160.1892
130.60.10.33894702-0.2389470.06912-0.2799
14775.5778.1776.879271.220730.057741.421
15666.9668.8668.049380.7506170.042260.8669
16338339.3338.453160.8468390.029330.9715
17447.5448.9448.184950.7150470.027970.8197
1811.610.811.362232-0.5622320.06698-0.6578
19556557.7556.914630.7853720.03220.9023
20228.1228.3228.32052-0.02052310.03639-0.02363
21995.8998997.64560.3543960.10620.4237
22887.6888.8889.21656-0.4165650.07955-0.4907
23120.2119.6120.19212-0.5921180.04887-0.6862
240.30.30.0383119720.2616880.069180.3066
250.30.60.0383119720.5616880.069180.658
26556.8557.6557.71632-0.1163210.03225-0.1336
27339.1339.3339.55549-0.255490.02929-0.2931
28887.2888888.81572-0.8157180.07946-0.9609
29999998.51000.8524-2.352380.1071-2.814
30779778.9780.38668-1.486680.05833-1.732
3111.110.210.861174-0.6611740.06707-0.7737
32118.3117.6118.2881-0.6880960.04914-0.7975
33229.2228.9229.42285-0.5228520.03629-0.602
34669.1668.4670.25404-1.854040.04252-2.141
35448.9449.2449.58792-0.3879170.02799-0.4447
360.50.20.23873534-0.03873530.06914-0.04538

Studentized residuals (internally) beyond about ±2 deserve a look; leverage above 4/n marks influential x values.

Method and limits

How to use it

Paste the predictor values (X) and the response values (Y) in the same order. Optionally enter an x at which to predict: you get the fitted value, a confidence interval for the mean response and a prediction interval for a single new observation.

Formulas

  • Slope b₁ = Sxy / Sxx, intercept b₀ = ȳ − b₁x̄, with Sxx = Σ(x − x̄)², Sxy = Σ(x − x̄)(y − ȳ).
  • Residual SE s = √(SSE / (n − 2)); SE(b₁) = s / √Sxx; SE(b₀) = s √(1/n + x̄²/Sxx); t = estimate / SE with n − 2 df.
  • R² = 1 − SSE / SST; adjusted R² = 1 − (1 − R²)(n − 1)/(n − 2); F = MSR / MSE on 1 and n − 2 df.
  • At x₀: mean response ŷ ± t s √(1/n + (x₀ − x̄)²/Sxx); prediction ŷ ± t s √(1 + 1/n + (x₀ − x̄)²/Sxx).
  • Leverage hi = 1/n + (xi − x̄)²/Sxx; studentized residual ei / (s √(1 − hi)).

Assumptions and limits

  • A straight-line relation, independent errors with constant variance; normal errors for the tests and intervals. Check the residual table for curvature, outliers (|studentized| > 2) and high leverage (> 4/n).
  • Predictions outside the observed range of X are extrapolation and are flagged.
  • One predictor only. Up to 100,000 pairs; the residual table shows the first 1,000.

Worked example

The default data are NIST’s Norris ozone-monitor calibration set (36 pairs). The fit is ŷ = −0.262323073774 + 1.00211681802 x, R² = 0.999993745884, residual SE 0.884796 on 34 df — the NIST certified values to at least 10 significant digits. At x = 500 the prediction interval is 498.97 to 502.62.

References

Related tools

Share this page

Remind me to visit Contifield

Adds a repeating reminder to your calendar, titled “Contifield Reminder: Visit www.contifield.com”.