{
    "name": "Linear Regression Slope Calculator",
    "url": "https://calculators.geekmidst.com/calculators/linear-regression-slope-calculator",
    "markdown": "https://calculators.geekmidst.com/calculators/linear-regression-slope-calculator.md",
    "category": "Statistics & probability",
    "description": "Fit a least-squares line to x and y data and get the slope with its standard error, t statistic, two-sided p-value and confidence interval.",
    "summary": "The slope of the least-squares line says how much y changes, on average, for each one-unit increase in x. Its standard error and interval show how precisely the data pin it down.",
    "also_called": [
        "Least-squares slope calculator",
        "Line of best fit slope"
    ],
    "applies_to": "Worldwide",
    "last_updated": "2026-10-29",
    "computation": "Results are computed in the visitor’s browser on the HTML page. This API describes the calculator; it does not compute results.",
    "inputs": [
        {
            "name": "x",
            "label": "X values (predictor)",
            "type": "textarea",
            "default": "1, 2, 3, 4, 5"
        },
        {
            "name": "y",
            "label": "Y values (response, same order)",
            "type": "textarea",
            "default": "2, 4, 5, 4, 5"
        },
        {
            "name": "confidence",
            "label": "Confidence level",
            "type": "number",
            "default": "95",
            "unit": "%"
        }
    ],
    "outputs": [
        {
            "key": "slope",
            "label": "Slope (b₁)",
            "format": "number"
        },
        {
            "key": "se",
            "label": "Standard error of the slope",
            "format": "number"
        },
        {
            "key": "t",
            "label": "t statistic (n − 2 df)",
            "format": "text"
        },
        {
            "key": "p_value",
            "label": "p-value (two-sided)",
            "format": "number"
        },
        {
            "key": "p_text",
            "label": "p-value and hypothesis",
            "format": "text"
        },
        {
            "key": "ci",
            "label": "Confidence interval for the slope",
            "format": "text"
        },
        {
            "key": "intercept",
            "label": "Intercept (b₀)",
            "format": "number"
        },
        {
            "key": "equation",
            "label": "Fitted line",
            "format": "text"
        },
        {
            "key": "n",
            "label": "Pairs (n)",
            "format": "integer"
        }
    ],
    "formula": {
        "text": "b₁ = Sxy ÷ Sxx;  b₀ = ȳ − b₁x̄;  s² = SSE ÷ (n − 2);  SE(b₁) = √(s² ÷ Sxx);  t = b₁ ÷ SE;  CI = b₁ ± t*·SE",
        "variables": {
            "Sxy": "Σ(x − x̄)(y − ȳ)",
            "Sxx": "Σ(x − x̄)²",
            "SSE": "sum of squared residuals",
            "t*": "two-sided t critical value with n − 2 df"
        }
    },
    "worked_example": {
        "inputs": {
            "x": "1, 2, 3, 4, 5",
            "y": "2, 4, 5, 4, 5",
            "confidence": "95"
        },
        "steps": [
            "Sxy = 6 and Sxx = 10, so b₁ = 0.6; b₀ = 4 − 0.6 × 3 = 2.2.",
            "Residuals −0.8, 0.6, 1, −0.6, −0.2 give SSE = 2.4 and s² = 2.4 ÷ 3 = 0.8.",
            "SE = √(0.8 ÷ 10) = 0.2828; t = 2.121 with 3 df, two-sided p = 0.124; 95% CI = 0.6 ± 3.182 × 0.2828."
        ],
        "result": "Each extra unit of x adds 0.6 to y on average, but with five points the 95% interval (−0.30 to 1.50) still includes zero."
    },
    "interpretation": "The slope is in units of y per unit of x. A confidence interval that excludes 0 corresponds to a two-sided p-value below 1 − confidence. A significant slope shows association in this range of x; do not extrapolate far beyond the data.",
    "assumptions": [
        "Ordinary least squares: the relation is linear, residuals are independent with constant variance and roughly normal.",
        "x is measured without important error.",
        "The test is two-sided, H₀: slope = 0."
    ],
    "limitations": [
        "Outliers and high-leverage points can dominate the fit; check a residual plot.",
        "One predictor only; multiple regression needs a matrix method."
    ],
    "rules": null,
    "faqs": [
        {
            "question": "How is the slope related to the correlation?",
            "answer": "b₁ = r × (s_y ÷ s_x). The slope keeps the units; r is unit-free."
        },
        {
            "question": "Why use n − 2 degrees of freedom?",
            "answer": "Two parameters (slope and intercept) are estimated from the data before measuring the scatter around the line."
        }
    ],
    "sources": [],
    "related": [
        {
            "name": "Linear Regression Intercept Calculator",
            "url": "https://calculators.geekmidst.com/calculators/linear-regression-intercept-calculator"
        },
        {
            "name": "R-Squared Calculator",
            "url": "https://calculators.geekmidst.com/calculators/regression-r-squared-calculator"
        },
        {
            "name": "Pearson Correlation Calculator",
            "url": "https://calculators.geekmidst.com/calculators/pearson-correlation-calculator"
        },
        {
            "name": "P-value Calculator",
            "url": "https://calculators.geekmidst.com/calculators/p-value-calculator"
        }
    ],
    "disclaimer": null,
    "publisher": "GM¹X CalcVerse"
}