Linear Regression (slope, intercept, R^2)
Least-squares fitted line (slope, intercept), R^2, residual standard error, the slope t-test with a two-tailed p-value.
Example
You enter
- X values (comma or whitespace separated) 1, 2, 3, 4, 5
- Y values (same count, paired with X) 2, 4, 5, 4, 5
- Predict y at x (optional) 6
- Significance level (alpha) 0.05
You get
- Fitted line 0.6
- Intercept 2.2
- R² (coefficient of determination) 0.6
- Residual standard error 0.894427
- Prediction 5.8
Details, formula, and sources
Least-squares fitted line (slope, intercept), R^2, residual standard error, the slope t-test with a two-tailed p-value, and an optional prediction at a given x, for paired x / y series. Per OpenIntro Statistics Ch. 8.
Least squares: slope = sum((x - xbar)(y - ybar)) / sum((x - xbar)^2); intercept = ybar - slope * xbar. R^2 = r^2. Residual sum of squares RSS = Syy - slope * Sxy; residual standard error = sqrt(RSS / (n - 2)). Slope t-test for slope = 0: t = slope / (RSE / sqrt(Sxx)) on n - 2 df, two-tailed p = 2 * (1 - tcdf(|t|, n - 2)). Prediction y-hat = intercept + slope * x.
OpenIntro Statistics 4th ed. Chapter 8 (introduction to linear regression) by name; the Student-t CDF via the regularized incomplete beta function per Numerical Recipes in C 2nd ed. §6.4.
OpenIntro Statistics free at openintro.org; Numerical Recipes chapters free at numerical.recipes.
Estimate only. Readability formulas and similar metrics are derived from a representative population and have known edge-case noise. The classroom teacher governs final text selection, grade placement, and assessment decisions.
Field names used by the API: x_values, y_values, predict_x, alpha, slope, intercept, r2, rse, predicted_y
- Degrees of freedom n - 2 (slope and intercept estimated)OpenIntro Statistics Ch. 8
- Residual standard error sqrt(RSS / (n - 2))ordinary least squares
- Slope standard error RSE / sqrt(Sxx)OpenIntro Statistics Ch. 8