How to use this calculator
Measure the linear association of the first two variables after linearly controlling for every remaining column.
- Enter Rows x y controls, Total variables per row including x and y. Match the units shown beside each field and review the result together with the assumptions below.
- Read the worked example below to check the expected input format and result.
- Compare another scenario by changing one input at a time. Use Reset to return to the starting values.
Partial Pearson correlation with control variables explained
The worked data contain eight complete rows with x and y first and one control column last. With p=3, the model adjusts the x–y association for that third variable and uses five residual degrees of freedom.
A numerical walkthrough
Rows x y controls = 1,3,2,2,4,1,3,5,4,4,5,2,5,8,5,6,7,3,7,10,6,8,9,4; Total variables per row including x and y = 3.
- Partial correlation first two variables: 0.94284137
- Two-sided t-reference p-value: 0.00145455
- Degrees of freedom: 5
The example has eight rows and three columns, so the third column is the single control. The resulting test has five degrees of freedom, not the six used by an unadjusted correlation test.
The model behind the numbers
rxy·Z=−Ω12/√(Ω11Ω22), Ω=S⁻¹; t=r√[(n−p)/(1−r²)], df=n−p.
Compute a sample covariance matrix across complete rows and invert it. The precision-matrix identity gives the correlation between residuals after regressing each target variable on the controls. With p total variables, p−2 are controls.
What to enter
x— Rows x y controls- Complete rows with target x first, target y second, and all control variables afterward. The same column order repeats in every row. Use comma-separated values in the stated order.
p— Total variables per row including x and y- Total columns per row, including both targets. Therefore p−2 columns are controls. Enter a whole number.
Interpreting the result
More rows than variables, nonsingular covariance, independent complete observations, and appropriate normal linear-model assumptions for the t-reference. Adjustment describes conditional linear association and does not guarantee removal of confounding or causation.
Reading the outputs
The coefficient remains dimensionless. Its p-value tests zero partial correlation under the specified model; it does not assess whether the control set is substantively correct.
Frequently asked questions
Does column order matter?
The first two are the targets; all later columns are controls. Reordering only the controls leaves the result unchanged.
Can controls be categorical?
Only after an appropriate numeric design encoding; raw category codes can impose unintended linear spacing.
Can partial correlation prove a direct effect?
No. Causal interpretation needs a justified design and assumptions beyond this calculation.
How do I use the Partial Pearson correlation with control variables calculator?
Enter Rows x y controls, Total variables per row including x and y. Match the units shown beside each field and review the result together with the assumptions below.
What is a worked example of Partial Pearson correlation with control variables?
Rows x y controls = 1,3,2,2,4,1,3,5,4,4,5,2,5,8,5,6,7,3,7,10,6,8,9,4; Total variables per row including x and y = 3. Partial correlation first two variables: 0.94284137 Two-sided t-reference p-value: 0.00145455 Degrees of freedom: 5 The example has eight rows and three columns, so the third column is the single control. The resulting test has five degrees of freedom, not the six used by an unadjusted correlation test.
Method reference: Statsmodels multivariate test definitions.
Read our calculation methodology.