{
    "name": "Spearman Correlation Calculator",
    "url": "https://calculators.geekmidst.com/calculators/spearman-correlation-calculator",
    "markdown": "https://calculators.geekmidst.com/calculators/spearman-correlation-calculator.md",
    "category": "Statistics & probability",
    "description": "Compute Spearman’s rank correlation ρ from paired data, with average ranks for ties, Σd² and a two- or one-sided p-value from the t approximation.",
    "summary": "Spearman’s ρ is Pearson’s correlation applied to ranks. It measures whether y tends to rise (or fall) as x rises, whether or not the relation is a straight line.",
    "also_called": [
        "Spearman’s rho calculator",
        "Rank correlation calculator"
    ],
    "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",
            "type": "textarea",
            "default": "35, 23, 47, 17, 10, 43, 9, 6, 28"
        },
        {
            "name": "y",
            "label": "Y values (same order)",
            "type": "textarea",
            "default": "30, 33, 45, 23, 8, 49, 12, 4, 31"
        },
        {
            "name": "tail",
            "label": "Alternative hypothesis",
            "type": "select",
            "default": "two",
            "options": {
                "two": "Two-sided: ρ ≠ 0",
                "greater": "One-sided: ρ > 0",
                "less": "One-sided: ρ < 0"
            }
        }
    ],
    "outputs": [
        {
            "key": "rho",
            "label": "Spearman’s ρ",
            "format": "number"
        },
        {
            "key": "n",
            "label": "Pairs (n)",
            "format": "integer"
        },
        {
            "key": "sum_d2",
            "label": "Σd² (squared rank differences)",
            "format": "number"
        },
        {
            "key": "t",
            "label": "t statistic (n − 2 df)",
            "format": "text"
        },
        {
            "key": "p_value",
            "label": "p-value",
            "format": "number"
        },
        {
            "key": "p_text",
            "label": "p-value, sidedness and method",
            "format": "text"
        },
        {
            "key": "ties",
            "label": "Ties present",
            "format": "text"
        }
    ],
    "formula": {
        "text": "ρ = Pearson r of the ranks (ties get average ranks); without ties ρ = 1 − 6Σd² ÷ (n(n² − 1));  t = ρ·√((n − 2) ÷ (1 − ρ²))",
        "variables": {
            "d": "difference between the x-rank and y-rank of a pair",
            "n": "number of pairs"
        }
    },
    "worked_example": {
        "inputs": {
            "x": "35, 23, 47, 17, 10, 43, 9, 6, 28",
            "y": "30, 33, 45, 23, 8, 49, 12, 4, 31",
            "tail": "two"
        },
        "steps": [
            "Rank each list from smallest to largest; the rank differences squared add to Σd² = 12.",
            "ρ = 1 − 6 × 12 ÷ (9 × 80) = 1 − 0.1 = 0.9.",
            "t = 0.9 × √(7 ÷ 0.19) = 5.46 with 7 df, two-sided p ≈ 0.0009."
        ],
        "result": "The nine pairs have a very strong monotonic association, ρ = 0.90, significant at the 1% level."
    },
    "interpretation": "ρ near ±1 means the order of y closely follows the order of x. Spearman is robust to outliers and works for ordinal data such as ratings or rankings, at the cost of ignoring how far apart the values are.",
    "assumptions": [
        "Pairs are independent and at least ordinal.",
        "The p-value uses the t approximation with n − 2 degrees of freedom, against the null hypothesis ρ = 0."
    ],
    "limitations": [
        "For fewer than about 10 pairs, exact permutation tables give a more accurate p-value.",
        "The short formula with Σd² is only exact without ties; this calculator always uses Pearson on ranks."
    ],
    "rules": null,
    "faqs": [
        {
            "question": "When should I use Spearman instead of Pearson?",
            "answer": "When the relation is monotonic but curved, when there are outliers, or when the data are ranks or ordinal scores."
        },
        {
            "question": "How are ties ranked?",
            "answer": "Tied values share the average of the ranks they occupy. Two values tied for 2nd and 3rd both get 2.5."
        }
    ],
    "sources": [],
    "related": [
        {
            "name": "Pearson Correlation Calculator",
            "url": "https://calculators.geekmidst.com/calculators/pearson-correlation-calculator"
        },
        {
            "name": "R-Squared Calculator",
            "url": "https://calculators.geekmidst.com/calculators/regression-r-squared-calculator"
        },
        {
            "name": "Statistics Calculator",
            "url": "https://calculators.geekmidst.com/calculators/statistics-calculator"
        }
    ],
    "disclaimer": null,
    "publisher": "GM¹X CalcVerse"
}