{"uid":"cap_xguUjp3MgbhW19vpfg3GG","slug":"correlation-regression-analysis-c4e9bb2e","name":"Correlation & Regression Analysis","description":"Pearson and Spearman correlation of two lists with p-values, plus the least-squares line, R squared and an optional prediction.","url":"https://math-stats.x402tookit.com/correlation?utm_source=zero.xyz","method":"GET","headers":{},"bodySchema":{"type":"object","$schema":"https://json-schema.org/draft/2020-12/schema","required":["input"],"properties":{"input":{"type":"object","required":["type","method"],"properties":{"type":{"type":"string","const":"http"},"method":{"enum":["GET"],"type":"string"},"queryParams":{"type":"object","required":["x","y"],"properties":{"x":{"type":"string","description":"First list of numbers"},"y":{"type":"string","description":"Second list, same length"},"predictAt":{"type":"number","description":"Optional x value to predict y for"}}}},"additionalProperties":false},"output":{"type":"object","required":["type"],"properties":{"type":{"type":"string"},"example":{"type":"object","properties":{"n":{"type":["null","number"]},"asOf":{"type":["null","string"]},"meanX":{"type":["null","number"]},"meanY":{"type":["null","number"]},"slope":{"type":["null","number"]},"source":{"type":["null","string"]},"reasons":{"type":["array","null"],"items":{"type":"string"}},"summary":{"type":["null","string"]},"verdict":{"type":["null","string"]},"degraded":{"type":["boolean","null"]},"pearsonP":{"type":["null","number"]},"pearsonR":{"type":["null","number"]},"rSquared":{"type":["null","number"]},"intercept":{"type":["null","number"]},"spearmanP":{"type":["null","number"]},"disclaimer":{"type":["null","string"]},"notChecked":{"type":["array","null"],"items":{"type":"string"}},"prediction":{"type":["null","object"],"properties":{"x":{"type":["null","number"]},"y":{"type":["null","number"]},"extrapolating":{"type":["boolean","null"]}}},"spearmanRho":{"type":["null","number"]},"residualStandardError":{"type":["null","number"]}}}}}}},"responseSchema":null,"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.02","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.02/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.02","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.02","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_Xd_9QBEO_uHi63zuoQ83K","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.02","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Computes Pearson and Spearman correlations with p-values, fits a least-squares regression line, returns R-squared, and optionally predicts a y-value for a given x.","exampleAgentPrompt":"Can you compute the Pearson and Spearman correlations between these two lists — x: 1,2,3,4,5 and y: 2.1,3.9,6.2,7.8,10.1 — and also predict what y would be at x=6?","exampleUseCases":[{"title":"Ad spend vs revenue correlation","prompt":"I have monthly ad spend figures: 500,800,1200,1500,2000 and corresponding revenue: 4200,5800,7500,9100,12000. Can you calculate both Pearson and Spearman correlations with p-values, fit a regression line, and tell me what revenue to expect at an ad spend of 2500?"},{"title":"Checking if temperature affects sales","prompt":"I want to know if daily temperature is correlated with ice cream sales. My temps in Fahrenheit are: 65,70,75,80,85,90 and sales units are: 120,145,165,200,230,275. Can you run Pearson and Spearman correlation tests and show me the R-squared and regression line?"},{"title":"Student study hours vs exam score regression","prompt":"Here are study hours for 7 students: 1,2,3,4,5,6,7 and their exam scores: 55,60,65,70,80,85,92. Can you find the correlation between hours studied and scores, and predict what score a student who studies 8 hours would likely get?"}],"resultDescription":"Returns Pearson r and its p-value, Spearman rho and its p-value, sample size n, mean of x, mean of y, regression slope and intercept, R-squared, residual standard error, and optionally a prediction object with the input x, predicted y, and whether the prediction is extrapolating beyond the data range. Also includes a summary string and any relevant disclaimer.","failureModes":["Mismatched list lengths for x and y — returns error requiring equal-length inputs","Non-numeric values in x or y strings — parsing failure","Insufficient data points (e.g. n<3) — correlation undefined or degenerate","x or y parameters missing entirely — 400 bad request","All x values identical — slope undefined, regression cannot be computed","Payment not included or insufficient — 402 Payment Required"],"whenToPreferThis":"Choose this endpoint when you need both Pearson and Spearman correlation in one call along with a fitted regression line and optional prediction. It is more comprehensive than a simple correlation call, covering parametric and rank-based correlation simultaneously with significance testing. Prefer it over a t-test endpoint when the research question is about the strength and direction of a linear relationship between two continuous variables rather than a difference in means.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-10-29T13:12:41.046Z","isFirstParty":false,"canonicalSlug":"correlation-regression-analysis-c4e9bb2e"}