Fit Y by X (Ctrl+F)¶

When to use it¶
Univariate linear regression of a continuous Y on a single continuous X (simple linear regression). Use when X is the only predictor and you want the fit line, CI/PI bands, ANOVA decomposition, and parameter estimates in one report. Continuous modeling type for both Y and X. Multivariate Y / X are not used; if a By zone is filled, the launch switches to a t-test-by-group path instead of the scatter report.
GUI workflow¶
- Press
Fit Y by X (Ctrl+F)— Launch Dialog opens with Fit Y by X active. - Roles:
Y, Response *(single, required),X, Factor *(single, required),By(multiple, optional),Weight,Freq(optional). - Assign Y and X via the picker (activated role zone), one column per zone.
Bygroups the data; with aByassignment the launch runs a t-test comparison instead of the scatter report. - Run opens the floating report window.
Floating report window¶
- Scatter / Fit (brushable) — points (unselected/background, selected/accent), the fitted line, and 95% CI (green) and 95% PI (purple) bands when CI/PI is enabled. t-critical uses an approx 95% value of 2.0 for moderate n. Drag to brush-select; click to clear; hidden rows omitted.
- Summary of Fit — n, R², Residual SD, Slope, Intercept.
- ANOVA — single row for Regression (Source, SS, DF=1, MS, F) and Residual (Source, SS, DF=n-2, MS, —).
- Parameter Estimates — Term, Estimate, SE, t, p (intercept and slope from the OLS fit).
Header ... menu: Toggle CI/PI (flips the CI/PI bands immediately), Save Residuals, Save Script to Table, Export SVG, Export JSON. Hidden rows are omitted everywhere.
Mathematical formulation¶
Ordinary least squares, intercept + slope:
Fitted values \(\hat{y}_i = \hat{\beta}_0 + \hat{\beta}_1 x_i\); residuals \(e_i = y_i - \hat{y}_i\).
ANOVA decomposition:
with \(MS_{\text{reg}} = SSR/1\) and \(MS_{\text{res}} = RSS/(n-2)\).
Confidence band and prediction band at an x:
\(R^2 = SSR/TSS\); Adjusted \(R^2 = 1 - (1 - R^2)(n-1)/(n-p-1)\) with \(p = 1\).
The OLS fit uses QR/SVD-based stability from leap_stats::ols::fit_ols (basis Linear).
CLI parity — exact flags¶
Fit Y by X (Ctrl+F) — Launch Dialog → Run.
leap fit-ols data.csv --y <col> --x <col1,col2> [--selected <ids>] [--json]
JSON output includes n_total, n_used, exclusion counts, coefficients (estimate / SE / t / p_value), R², adjusted R², residual SD, RSS/TSS, F-stat/p-value, df, rank, diagnostics (fitted / raw / leverage / standardized / studentized residuals + Cook's distance, plus Q-Q points), and profiler slices (per-predictor grid points with x / predicted_y / 95% CI / PI / in_range, or an error).