Linear Regression Calculator
Free linear regression calculator. Slope, intercept, R², SE, t-tests, ANOVA, confidence and predicti
Why This Statistical Analysis Matters
Why: Statistical calculator for analysis.
How: Enter inputs and compute results.
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
| x | y | |
|---|---|---|
ANOVA Table
| Source | SS | df | MS | F | p-value |
|---|---|---|---|---|---|
| Regression | 28.9000 | 1 | 28.9000 | 289.0000 | 0.0004 |
| Residual | 0.3000 | 3 | 0.1000 | — | — |
| Total | 29.2000 | 4 | — | — | — |
Prediction at x₀ = 6
ŷ = 10.5000
95% CI for mean: [9.4523, 11.5477]
95% Prediction interval: [9.0524, 11.9476]
Calculation Breakdown
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?
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
| Scenario | Use Linear Regression? | Alternative |
|---|---|---|
| Linear relationship, normal residuals | ✅ Yes | — |
| Curved relationship | ❌ No | Polynomial or exponential regression |
| Multiple predictors | ⚠️ Use multiple regression | R, Python, SPSS |
| Outliers present | ⚠️ Check influence | Robust regression, remove outliers |
| Heteroscedastic residuals | ⚠️ Caution | Weighted least squares |
| Binary/count outcome | ❌ No | Logistic 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
Official Data Sources
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.
Related Calculators
Cubic Regression Calculator
Fit a cubic polynomial y = ax³ + bx² + cx + d to data using least squares. R², prediction, residuals, and comparison with linear and quadratic fits.
StatisticsPolynomial Regression Calculator
Fit polynomial of degree 1–6 to data. Compare models with R², adjusted R², AIC/BIC. Visualize fits and residuals.
StatisticsQuadratic Regression Calculator
Fit y = ax² + bx + c to data using least squares. Vertex, axis of symmetry, R², comparison with linear fit, residuals, F-test.
StatisticsConfidence Interval Calculator
Calculate confidence intervals for means, proportions, and differences. Z-intervals, t-intervals, and sample size planning.
StatisticsF-statistic Calculator
Computes F-statistic and p-value for ANOVA, regression F-test, and variance ratio tests. Includes F-distribution visualization.
StatisticsPower Analysis Calculator
Compute statistical power, required sample size, or minimum detectable effect size for t-tests, proportions, ANOVA, and correlation.
Statistics