ForHosting KIT · Math

Partial correlation calculator

If x and y correlate at 0.8, x and z at 0.5 and y and z at 0.4, the partial correlation of x and y controlling for z is about 0.76: most of their link survives once z is set aside. Free in your browser.

  • Free
  • Runs in your browser
  • No sign-up
  • Your data stays on your device
Use it from WebAPIEmailTelegramApp soon
If you enter
R xy
0.8
R xz
0.5
R yz
0.4
You get
Partial r
0.755928946
Numerator
0.6
Denominator
0.7937253933

Partial correlation answers a question ordinary Pearson r cannot: how strongly do x and y move together after the linear influence of a third variable z has been removed?

What partial correlation tells you

An ordinary Pearson correlation measures how closely two variables move together, but it cannot tell whether part of that movement comes from a third variable pulling both of them. Partial correlation removes the linear influence of that third variable, z, and measures what is left between x and y. A large positive value means x and y still rise together after the adjustment, a large negative value means they move in opposite directions, and a value near zero means the link you saw was largely explained by z. The result stays between minus one and plus one.

How it is calculated, and what to watch for

You only need the three pairwise correlations, for example from a correlation matrix or a published paper. Multiply the correlation of x with z by the correlation of y with z, subtract that from the correlation of x with y, and divide by the square root of one minus each controlling correlation squared. With 0.8, 0.5 and 0.4 the numerator is 0.6 and the result about 0.76. If either controlling correlation is exactly 1 or minus 1 the division fails, so no number is given. And remember that setting z aside is a statistical adjustment, not proof of cause.

What partial correlation measures and the classical formula

Pearson’s product-moment correlation r measures linear association between two variables, but it does not separate shared movement that is driven by a third variable. The result still lies in the closed interval from minus one to plus one whenever the denominator is positive. A large positive partial means x and y still move together after linear adjustment for z; a large negative partial means they move in opposite directions after that adjustment; a value near zero means any observed association was largely explained by z.

Use dedicated Pearson tools when you start from observations, and use this page when the three pairwise r values are already known and you need a reproducible partial for reports, answer keys, or automated checks.

Must the three values come from the same sample?

Yes for a coherent matrix: the formula assumes a valid joint correlation structure.

Is partial correlation the same as Pearson r?

No. Pearson r is the simple pairwise association. Partial correlation removes the linear association with a control variable z before measuring the remaining association of x and y.

What is the formula for partial correlation?

Subtract the product of the x–z and y–z correlations from the x–y correlation, then divide by the square root of one minus each of those two controlling correlations squared, multiplied together.

What if a controlling correlation is 1 or minus 1?

Then the denominator is zero and the partial correlation is undefined. The calculator rejects that case instead of inventing a number, so you are never handed a result that has no meaning.

Does a partial correlation prove that z is a confounder?

No. Removing the linear part of z is a statistical adjustment, not proof that z is a confounder or that any causal path exists. Treat the result as a description of your data.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/stat/partial-correlation

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/stat/partial-correlation \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"r_xy":0.8,"r_xz":0.5,"r_yz":0.4}'
{
  "r_xy": 0.8,
  "r_xz": 0.5,
  "r_yz": 0.4
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "stat.partial_correlation",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

Researchers, students, and analysts often hold three pairwise correlations from a matrix, a paper, or a spreadsheet and need r_xy.z without rebuilding the raw data. This partial correlation calculator accepts the three pairwise coefficients r_xy, r_xz, and r_yz, applies the classical first-order formula, and returns the partial correlation together with the numerator, denominator, and formula string for audit. When the controlling correlations are perfect in magnitude the denominator is zero and the partial is undefined; those cases fail with invalid_input instead of inventing a number.

What partial correlation measures and the classical formula

Partial correlation of x and y controlling for z, written r_xy.z, is the correlation between the residuals of x on z and the residuals of y on z under linear least squares. When only the three pairwise correlations are available, the same value is obtained from the closed-form identity r_xy.z equals (r_xy minus r_xz times r_yz) divided by the square root of (one minus r_xz squared) times (one minus r_yz squared). This endpoint does not re-estimate coefficients from raw series: it assumes you already have valid pairwise Pearson correlations in the unit interval and focuses on the algebraic step that many worksheets leave to hand calculation. It also does not claim causal control; removing the linear component of z is a statistical adjustment, not proof that z is a confounder or that a causal path has been blocked.

Input contract, response shape, and when the denominator vanishes

POST a JSON body with three required finite numbers, each in the closed interval from minus one to plus one: r_xy (correlation of x and y), r_xz (correlation of x and z), and r_yz (correlation of y and z). Aliases rxy or xy, rxz or xz, and ryz or yz are accepted so compact forms and spreadsheets can reuse the same contract. Missing fields, non-finite values, and values outside the unit interval fail with invalid_input naming the field; those failures are not billed. The critical algebraic guard is the denominator: the product under the square root is zero when the absolute value of r_xz equals one or the absolute value of r_yz equals one, because then x or y is a perfect linear function of z and residual variance collapses. On success the body echoes the three inputs, returns partial_r rounded to twelve decimal places for stable goldens, returns numerator and denominator for audit, and includes a short formula string restating the identity. Example: r_xy equals zero point eight, r_xz equals zero point five, and r_yz equals zero point four yields a positive partial near zero point seven six, showing residual association after adjusting for z.

Where a partial correlation calculator earns its keep

Classrooms introduce partial correlation when contrasting simple association with association after holding a third variable constant, and students need a deterministic oracle that matches the textbook formula on arbitrary three-tuples. Product and data teams sometimes receive only a correlation matrix from a privacy-preserving pipeline and still want first-order partials among selected triples without reconstructing individuals. Keep requests small, assert the rounded partial in tests, and you get reproducible first-order partial correlation for homework, documentation widgets, and edge workers without standing up a full multivariate statistics stack for three numbers. Exam generators and LMS plugins mark items that start from a correlation matrix rather than raw scores; calling this parse endpoint avoids embedding fragile spreadsheet formulas that silently fail when |r_xz| hits one. Social science and epidemiology notes often quote only pairwise r values from prior work and ask for r_xy.z as a sensitivity check before collecting new microdata. Research software tests pin partial_r for known matrix slices so refactors of larger multivariate modules cannot drift.

Homework and matrix exercises

Check r_xy.z from three textbook pairwise correlations and confirm the partial matches the residual-correlation definition.

LMS and exam auto-grading

Score correlation-matrix items with a deterministic oracle that rejects perfect |r_xz| or |r_yz| as undefined.

CI fixtures from a correlation matrix

Pin partial_r for known triples in automated tests without re-deriving residual correlations by hand.

How do I compute partial correlation of x and y controlling for z?

Send finite r_xy, r_xz, and r_yz each in [-1, 1]. The API returns r_xy.z = (r_xy − r_xz·r_yz) / √((1 − r_xz²)(1 − r_yz²)) as partial_r.

What happens when the denominator is zero?

If |r_xz|=1 or |r_yz|=1 the residual variance of x or y after z is zero, so partial correlation is undefined. The task fails with invalid_input and is not billed.

What does the partial correlation calculator cost?

The browser tool is free. API requests use prepaid KIT balance at $0.002 per successful call; invalid input is not billed.

Read the full KIT documentation →