{"success":true,"version":"v1","request":{"tool":"get_calculator_schema","calculator_id":"spearman-correlation"},"result":{"entity_type":"calculator","id":"spearman-correlation","calculator_id":"spearman-correlation","canonical_url":"https://tttkmbb.com/statistics/spearman-correlation","name":"Spearman Rank Correlation Calculator","title":"Spearman's Rank Correlation Calculator – ρ with Tie-Corrected Ranks and t-Test p-Value","category":"statistics","category_name":"Statistics & Probability","tool_name":"calculate_spearman_correlation","featured_mcp_tool":false,"description":"Computes Spearman's rank correlation coefficient ρ between two paired lists (Pearson correlation of average ranks, so ties are handled), the t-approximation test statistic and its two-sided p-value, with a strength interpretation.","use_when":"You want to measure a monotonic (not necessarily linear) association, the data are ordinal or ranked, or outliers make Pearson's r unreliable.","do_not_use_when":"You need the linear correlation, covariance or a fitted line (use correlation or linear-regression), or the sample is very small (n < 5 gives unreliable p-values with the t approximation).","inputs":[{"name":"x_values","label":"x values","type":"number_list","required":true,"description":"Independent (explanatory) variable, one number per observation.","example":[1,2,3,4,5]},{"name":"y_values","label":"y values","type":"number_list","required":true,"description":"Dependent (response) variable, in the same order as x_values.","example":[2,4,5,4,5]}],"outputs":[{"name":"sample_size","label":"Number of pairs (n)","type":"integer","decimals":4,"description":"Number of (x, y) pairs."},{"name":"spearman_rho","label":"Spearman's ρ","type":"number","decimals":4,"description":"Rank correlation between −1 and 1."},{"name":"t_statistic","label":"t","type":"number","decimals":4,"description":"ρ · √((n − 2) / (1 − ρ²)), approximately t-distributed with n − 2 df under H0: ρ = 0."},{"name":"degrees_of_freedom","label":"Degrees of freedom","type":"integer","decimals":4,"description":"n − 2."},{"name":"p_value","label":"p-value (two-sided)","type":"number","decimals":6,"description":"P(|T_{n−2}| ≥ |t|); omitted when |ρ| = 1."},{"name":"has_ties","label":"Ties present","type":"boolean","decimals":4,"description":"true when either variable contains repeated values (average ranks were used)."},{"name":"interpretation","label":"Interpretation","type":"string","decimals":4,"description":"Strength (very weak < 0.2, weak < 0.4, moderate < 0.6, strong < 0.8, very strong ≥ 0.8 in |ρ|) and direction of the monotonic association."}],"input_schema":{"type":"object","properties":{"x_values":{"description":"Independent (explanatory) variable, one number per observation.","type":"array","items":{"type":"number"},"minItems":3,"examples":[[1,2,3,4,5]]},"y_values":{"description":"Dependent (response) variable, in the same order as x_values.","type":"array","items":{"type":"number"},"minItems":3,"examples":[[2,4,5,4,5]]}},"additionalProperties":false,"required":["x_values","y_values"]},"output_schema":{"type":"object","properties":{"sample_size":{"description":"Number of (x, y) pairs.","type":"integer"},"spearman_rho":{"description":"Rank correlation between −1 and 1.","type":"number"},"t_statistic":{"description":"ρ · √((n − 2) / (1 − ρ²)), approximately t-distributed with n − 2 df under H0: ρ = 0.","type":"number"},"degrees_of_freedom":{"description":"n − 2.","type":"integer"},"p_value":{"description":"P(|T_{n−2}| ≥ |t|); omitted when |ρ| = 1.","type":"number"},"has_ties":{"description":"true when either variable contains repeated values (average ranks were used).","type":"boolean"},"interpretation":{"description":"Strength (very weak < 0.2, weak < 0.4, moderate < 0.6, strong < 0.8, very strong ≥ 0.8 in |ρ|) and direction of the monotonic association.","type":"string"}}},"formula":"ρ = Pearson r of rank(x) and rank(y), ties receiving the mean of the ranks they occupy (equals 1 − 6Σd² / (n(n² − 1)) when there are no ties); t = ρ√((n − 2)/(1 − ρ²)), df = n − 2","method":"The t approximation for the p-value is adequate for n of about 10 or more; exact permutation tables are preferable for smaller samples. ρ is undefined when all x or all y values are equal.","sources":[{"name":"Wikipedia – Spearman's rank correlation coefficient","url":"https://en.wikipedia.org/wiki/Spearman%27s_rank_correlation_coefficient","type":"reference","retrieved_at":"2026-09-24"},{"name":"Spearman C (1904) The proof and measurement of association between two things, Am J Psychol 15:72-101","url":"https://doi.org/10.2307/1412159","type":"peer_reviewed","retrieved_at":"2026-09-24"}],"freshness":{"type":"static","max_age_seconds":null,"note":"Deterministic formula with fixed constants; results never go stale. Inputs supplied by the caller determine the output."},"examples":[{"name":"IQ vs hours of TV per week, n = 10 (Wikipedia example)","inputs":{"x_values":[106,100,86,101,99,103,97,113,112,110],"y_values":[7,27,2,50,28,29,20,12,6,17]},"expected":{"sample_size":10,"spearman_rho":-0.1758,"t_statistic":-0.505,"degrees_of_freedom":8,"p_value":0.627188,"has_ties":false,"interpretation":"Very weak negative monotonic correlation"},"url":"https://tttkmbb.com/api/v1/calculate/spearman-correlation?x_values=106%2C100%2C86%2C101%2C99%2C103%2C97%2C113%2C112%2C110&y_values=7%2C27%2C2%2C50%2C28%2C29%2C20%2C12%2C6%2C17"},{"name":"x = 1..5, y = 2, 4, 5, 4, 5 (ties in y)","inputs":{"x_values":[1,2,3,4,5],"y_values":[2,4,5,4,5]},"expected":{"spearman_rho":0.7379,"t_statistic":1.8935,"degrees_of_freedom":3,"p_value":0.154619,"has_ties":true},"url":"https://tttkmbb.com/api/v1/calculate/spearman-correlation?x_values=1%2C2%2C3%2C4%2C5&y_values=2%2C4%2C5%2C4%2C5"}],"faq":[{"q":"Spearman or Pearson?","a":"Pearson measures linear association of interval data; Spearman measures whether y tends to increase with x in any monotonic way, is robust to outliers and works for ordinal data."},{"q":"Why does my result differ from the 1 − 6Σd²/(n(n² − 1)) formula?","a":"That shortcut is exact only without ties. With ties this calculator uses the Pearson correlation of average ranks, which is the standard tie-corrected definition."}],"tags":["spearman correlation","rank correlation","spearman rho","monotonic correlation","nonparametric correlation"],"related":[{"calculator_id":"correlation","reason":"Pearson's linear correlation coefficient."},{"calculator_id":"linear-regression","reason":"Fit a line when the relationship is linear."}],"links":{"html":"https://tttkmbb.com/statistics/spearman-correlation","markdown":"https://tttkmbb.com/statistics/spearman-correlation.md","json":"https://tttkmbb.com/statistics/spearman-correlation.json","api":"https://tttkmbb.com/api/v1/calculate/spearman-correlation","schema":"https://tttkmbb.com/api/v1/calculators/spearman-correlation","openapi":"https://tttkmbb.com/openapi.json","mcp":"https://tttkmbb.com/mcp"},"version":"v1","updated_at":"2026-09-24"},"timestamp":"2026-09-24T01:58:13Z"}