Linear Regression Calculator
Enter aligned predictor X and response Y percentage-point returns to fit the ordinary-least-squares line Y = intercept + slope × X. The calculator exposes residuals, R-squared, residual standard error and Student-t coefficient intervals without calling the coefficients alpha or beta or creating forecasts and recommendations.
Enter predictor X and response Y
Direction matters: the fitted line estimates response Y from predictor X for the entered paired sample.
Two-sided confidence from 50% through 99.9%.
Enter 5 to 500 values without percent signs; one complete aligned observation per row.
The Y row count and order must match X exactly.
OLS coefficient and residual arithmetic
Entered Return Relationship Diagnostics 1.0.0.
On smaller screens, scroll horizontally to inspect the complete audit table.
| Row | Predictor X | Response Y | Fitted Y | Residual | Squared residual |
|---|
How the ordinary-least-squares fit is calculated
intercept = ȳ − slope × x̄
residual SE = √[Σ(Y − fittedY)² ÷ (n − 2)]
coefficient interval = estimate ± t1−α/2,n−2 × SE
The response direction is fixed: Y is fitted on X. The slope divides the centered X–Y cross-sum by the centered X sum of squares, and the intercept places the fitted line through the two sample means.
Each row’s fitted response is intercept plus slope times X. Subtracting fitted Y from entered Y gives a residual; squared residuals sum to SSE. Dividing SSE by n minus two and taking the square root gives residual standard error.
Slope and intercept standard errors follow the simple-OLS equations. The selected two-sided confidence level supplies a Student-t critical value with n minus two degrees of freedom. R-squared describes in-sample linear fit and is not a forecast score.
Worked example from the audited fixture
The audited fixture has 10 aligned return pairs with mean X = 0.25, mean Y = 0.26, SXX = 9.705 and SXY = 6.34.
- The fitted line is Y = 0.09668212 + 0.65327151 × X. Residual standard error is 0.14241604 percentage points, Pearson correlation is 0.98096917 and R-squared is 0.96230050.
- At 95% confidence with 8 residual degrees of freedom, the slope interval is 0.54785194 to 0.75869107 and the intercept interval is −0.01046275 to 0.20382699 percentage points. These are conditional coefficient intervals, not future-return ranges.
Reproduce it: select “Load audited example” above. The governed engine retains full precision and rounds only the visible interface.
How to interpret the result
- The slope is the fitted change in response Y percentage points for one percentage-point change in predictor X within the entered sample.
- The intercept is fitted Y when X equals zero. It is meaningful only when zero is relevant to the entered X scale and model.
- R-squared is the fraction of entered Y variation represented by this one fitted linear relation; it does not measure causal importance or out-of-sample accuracy.
- Residual standard error describes the in-sample vertical residual scale in Y percentage points.
- Coefficient intervals describe estimator uncertainty under assumptions and do not recommend a hedge ratio, allocation or trade.
Assumptions and limits
- Enter 5 to 500 aligned equal-frequency predictor X and response Y returns under consistent source and cost conventions.
- OLS coefficient intervals require a linear conditional mean, independent errors, constant residual variance and approximately normal errors for nominal small-sample coverage.
- Outliers, leverage points, serial dependence, volatility clustering, omitted variables and regime changes can materially distort the fit and interval.
- Swapping X and Y changes the regression because ordinary least squares is directional.
- The page performs no prediction interval, extrapolation, rolling stability test, cross-validation or out-of-sample evaluation.
- No alpha, beta, causality, predictive edge, hedge recommendation, forecast, grade, signal or position instruction is generated.
Which relationship diagnostic answers which question?
Pearson correlation, partial correlation, directional regression and a historical multi-pair matrix describe different evidence. The comparison keeps direction, control variables, uncertainty and source boundaries visible instead of presenting one coefficient as a universal dependence or strategy-validation score.
| Tool | Evidence entered | Primary output | Main boundary |
|---|---|---|---|
| Correlation Confidence Interval | Two aligned series | Symmetric Pearson coefficient plus Fisher limits | No causal, stable-dependence or forecast verdict. |
| Partial Correlation | X, Y and one control Z | Residual X–Y linear association after controlling Z | One linear control does not remove all confounding. |
| Linear Regression | Predictor X and response Y | Directional slope, intercept, residual scale and coefficient intervals | No alpha/beta label, extrapolation or hedge advice. |
| Historical Correlation Matrix | Governed multi-pair market history | Many pairwise historical coefficients | Source window and currency coverage differ from manual inference. |
Frequently asked questions
- It always fits response return Y on predictor return X as fitted Y equals intercept plus slope times X.
- The slope is the centered X-Y cross-product sum divided by the centered X sum of squares; the intercept places the line through both sample means.
- It is the square root of squared Y residuals divided by n minus two and remains in response-Y percentage points.
- Slope and intercept standard errors are multiplied by a two-sided Student-t critical value with n minus two residual degrees of freedom.
- It describes the fraction of entered Y variation represented by this one in-sample linear fit; it is not causal importance or out-of-sample accuracy.
- No. The page does not impose CAPM, excess-return or market-benchmark conventions and therefore does not label the generic coefficients alpha or beta.
- No. The fit omits position values, trading costs, stability tests, execution and suitability and creates no recommended position or hedge.
- No. It produces no prediction interval, extrapolation, future-performance probability, predictive-edge verdict, forecast, grade, signal or recommendation.
Sources and methodology
- NIST — Linear Fit — Published least-squares fit outputs, residual standard deviation and diagnostic boundaries.
- NIST — Regression Confidence Intervals — Published Student-t coverage-factor boundary and repeated-sampling interpretation.
Version 1.0.0 was locked only after the formulas and assumptions were checked against the cited NIST material. Canonical fixtures were independently recomputed with SciPy 1.13.1 before comparison with the browser engine. The calculator performs arithmetic locally and does not upload the entered observations.
Continue the regression and benchmark review
Verify the paired return evidence before interpreting relationships
Reconcile the exact statement window, sampling frequency, timestamps, missing rows, realized P&L, spread, commission, financing, currency conversion and preprocessing across every series. Correct relationship arithmetic cannot repair mismatched, selected or cost-inconsistent evidence.
Risk and affiliate disclosure: Leveraged forex and CFD trading can result in substantial losses. These are affiliate links, so ForexMT4Indicators.com may receive compensation if you register or trade through them, at no additional cost to you. Availability and terms vary by jurisdiction and broker entity.

