Partial Correlation Calculator

Check whether the correlation between two variables is a real relationship or caused by a third variable that affects both. The effect of the control variables is removed by regression, and the correlation of the residuals gives the partial correlation and its p-value.

1Data Table

Paste a table copied from Excel into a cell (Ctrl+V). Click a column header (A, B…) before pasting to use the first line as column names. Double-click a header to rename it, right-click to insert/delete rows and columns, and formulas such as =A1*2 work too.

2Partial Correlation Options

Select the variables whose effect to remove (control) (one or more):

How to run a partial correlation

  1. Copy X, Y and the control variable columns together with the header.
  2. Select Variable X and Variable Y, and one or more control variables whose effect to remove (they must not overlap with X or Y).
  3. Press Analyze and check the partial correlation, p-value, residual scatter plot and interpretation.

Worked example with sample data

The sample data are 24 months of monthly ice cream sales, drowning accidents and mean temperature (-1.5 to 28.5 °C).

Partial correlation of ice cream sales and drowning accidents controlling for temperature (residual scatter plot)
Partial correlation of ice cream sales and drowning accidents controlling for temperature (residual scatter plot)

The ordinary Pearson correlation of sales and drowning accidents is very strong at r=0.857 (p=9.1e-08). But both are even more strongly correlated with temperature (sales 0.961, accidents 0.917), so both may simply rise in hot months.

The partial correlation controlling for mean temperature is -0.2135 with a p-value of 0.3279, which is not statistically significant. Once the effect of temperature is removed, no relationship remains between sales and drowning accidents - the strong initial correlation was an apparent (spurious) correlation created by temperature.

The two axes of the result chart are the residuals after removing the part explained by temperature. The scattered points and the almost flat trendline (R² = 0.0456) show this conclusion visually.

How it is calculated

X and Y are each regressed on the control variables (plus a constant) by least squares, and the Pearson correlation of the two sets of residuals is the partial correlation. The p-value uses a t-test with the degrees of freedom reduced by the number of control variables k (n-2-k).

Only rows where every selected column is a number are used (listwise), and the number of pairs must be sufficiently larger than the number of control variables (n-2-k ≥ 1).

Residual scatter plot

The axes of the result chart are the 'residuals after control'. They show the relationship between what is left after removing the part explained by the control variables, so a flat trendline here means the apparent correlation was due to the control variables.

How to read the partial correlation

  • If the ordinary correlation is large but the partial correlation is small and not significant, the relationship is likely an apparent (spurious) correlation created by the control variables.
  • If the partial correlation is still significant after control, a relationship between X and Y remains apart from the control variables.
  • Judge the strength with the same cut-offs as ordinary correlation (0.1, 0.3, 0.5, 0.7), and record which variables were controlled.

Frequently asked questions

Is partial correlation the same as 'controlling for' a variable?

Yes. It is the correlation of X and Y with the control variables removed from both of them.

Can I add several control variables?

Yes. If you select several, they all go into the regression together. More data is needed accordingly.

Is it different from semi-partial correlation?

A semi-partial correlation removes the control variables from only one of the variables. This feature is the partial correlation, which removes them from both.

Other chart tools