STATISTICSInference & TestsStatistics Calculator
📊

Linear Regression Calculator

Free linear regression calculator. Slope, intercept, R², SE, t-tests, ANOVA, confidence and predicti

Run CalculatorExplore data analysis and statistical calculations

Why This Statistical Analysis Matters

Why: Statistical calculator for analysis.

How: Enter inputs and compute results.

ŷ
STATISTICSRegression & Modeling

Linear Regression — Simple Regression Analysis

ŷ = b₀ + b₁x. R², SE, t-tests, ANOVA, CI and prediction intervals. Scatter, residuals, Q-Q diagnostics.

Real-World Scenarios — Click to Load

xy
regression_results.txt
CALCULATED
$ linear_regression --data="5 pairs"
Equation
ŷ = 0.3000 + 1.7000x
0.9897
Adj R²
0.9863
F-statistic
289.0000
SE_regression
0.3162
t(b₁)
17.0000
p-value (slope)
0.0004
df
3
Share:
Linear Regression Result
ŷ = 0.3000 + 1.7000x
R² = 0.9897
Adj R² = 0.9863F = 289.000p = 0.0004
numbervibe.com/calculators/statistics/linear-regression-calculator

ANOVA Table

SourceSSdfMSFp-value
Regression28.9000128.9000289.00000.0004
Residual0.300030.1000
Total29.20004

Prediction at x₀ = 6

ŷ = 10.5000

95% CI for mean: [9.4523, 11.5477]

95% Prediction interval: [9.0524, 11.9476]

Calculation Breakdown

DATA SUMMARY
n (sample size)
5
x̄ (mean of x)
3.0000
Σxᵢ/n = 15.00/5
ȳ (mean of y)
5.4000
Σyᵢ/n
REGRESSION
Σ(xᵢ−x̄)²
10.0000
b₁ (slope)
1.7000
Σ(xᵢ−x̄)(yᵢ−ȳ) / Σ(xᵢ−x̄)²
b₀ (intercept)
0.3000
ȳ − b₁x̄
Equation
ŷ = 0.3000 + 1.7000x
0.9897
1 − SS_res/SS_tot
Adj R²
0.9863
1 − (1−R²)(n−1)/(n−2)
ANOVA
SS_reg
28.9000
SS_res
0.3000
SS_tot
29.2000
F-statistic
289.0000
MS_reg/MS_res
p-value (F)
0.0004
DIAGNOSTICS
SE_regression
0.3162
SE(b₁)
0.1000
SE_reg / √Σ(xᵢ−x̄)²
t(b₁)
17.0000
b₁/SE(b₁)
p-value (b₁)
0.0004

Scatter + Regression Line + CI/PI Bands

Residuals vs Fitted

Q-Q Plot of Residuals

For educational and informational purposes only. Verify with a qualified professional.

Key Takeaways

  • Model: ŷ = b₀ + b₁x. b₁ = Σ(xᵢ−x̄)(yᵢ−ȳ) / Σ(xᵢ−x̄)², b₀ = ȳ − b₁x̄.
  • R²: 1 − SS_res/SS_tot. Proportion of variance explained.
  • Adjusted R²: 1 − (1−R²)(n−1)/(n−2). Penalizes extra predictors.
  • SE_regression: √(SS_res/(n−2)).
  • t-test for b₁: t = b₁/SE(b₁), df = n−2. Tests H₀: β₁ = 0.
  • ANOVA: F = MS_reg/MS_res. SS_reg = b₁²Σ(xᵢ−x̄)².
  • CI for mean: ŷ₀ ± t × SE × √(1/n + (x₀−x̄)²/Σ(xᵢ−x̄)²).
  • Prediction interval: Wider; includes √(1 + 1/n + …) for new observation.

Did You Know?

📊Least squares minimizes Σ(yᵢ − ŷᵢ)². The regression line always passes through (x̄, ȳ).Source: NIST Handbook
📈R² = r² for simple linear regression, where r is the Pearson correlation coefficient.Source: Penn State STAT 501
🔬Residuals should be roughly normal and homoscedastic for valid inference.Source: OpenIntro Statistics
📐Prediction intervals are always wider than confidence intervals for the mean response.Source: Rice Virtual Lab
⚖️ANOVA F-test for regression tests whether the model explains significant variance beyond chance.Source: NIST Handbook
📉Q-Q plot: if points follow the diagonal line, residuals are approximately normal.Source: Penn State STAT 501

Expert Tips

Check Linearity First

Always plot your data before fitting. If the scatter shows a curve, consider polynomial regression or transformations (log, sqrt).

Residual Diagnostics

Residuals vs fitted: random scatter = good. Funnel shape = heteroscedasticity. Curve = nonlinearity. Q-Q plot checks normality.

CI vs PI

Use CI when estimating the mean y at x₀. Use PI when predicting a single new observation. PI is always wider.

Avoid Extrapolation

Predicting outside the x-range is risky. The linear relationship may not hold. Use our Quadratic Regression for curved data.

When to Use Linear Regression

ScenarioUse Linear Regression?Alternative
Linear relationship, normal residuals✅ Yes
Curved relationship❌ NoPolynomial or exponential regression
Multiple predictors⚠️ Use multiple regressionR, Python, SPSS
Outliers present⚠️ Check influenceRobust regression, remove outliers
Heteroscedastic residuals⚠️ CautionWeighted least squares
Binary/count outcome❌ NoLogistic regression, Poisson

Frequently Asked Questions

What is the difference between CI and prediction interval?

CI is for the mean response at x₀ (narrower). PI is for a new individual observation (wider, includes residual variability).

When is linear regression appropriate?

When the relationship is roughly linear, residuals are normal and homoscedastic, and observations are independent.

What does R² = 0.7 mean?

70% of the variance in y is explained by x. The remaining 30% is unexplained (residual).

How do I interpret the t-test for b₁?

Tests H₀: β₁ = 0. If p-value is below α, the slope is significantly different from zero — x helps predict y.

What if residuals are not normal?

For large n, inference is robust. For small n, consider transformations or nonparametric methods.

Can I reverse x and y?

Regression of y on x is NOT the same as regression of x on y. The slopes and interpretations differ. Choose based on which variable you want to predict.

What is the F-test in ANOVA?

Tests whether the model explains significant variance. F = MS_reg/MS_res. Equivalent to t² for slope in simple regression. Reject H₀: β₁=0 if p < α.

How do I interpret the intercept?

b₀ is the predicted y when x=0. Often not meaningful if x=0 is outside the data range. Focus on slope for interpretation.

Regression by the Numbers

n−2
Degrees of freedom (simple regression)
Variance explained (0 to 1)
1.96
Approx t* for 95% CI (large df)
3
Minimum pairs for regression

Disclaimer: This calculator is for educational purposes. For research, verify assumptions (linearity, normality, homoscedasticity, independence) and use established statistical software. Not professional statistical consulting advice.

👈 START HERE
⬅️Jump in and explore the concept!
AI

Related Calculators