partialcorr
statistics: rho = partialcorr (x)
statistics: rho = partialcorr (x, z)
statistics: rho = partialcorr (x, y, z)
statistics: [rho, pval] = partialcorr (…)
statistics: […] = partialcorr (…, Name, Value)
Linear or rank partial correlation coefficients.
rho = partialcorr (x) returns the sample linear partial
correlation coefficients between pairs of variables in the -by-
matrix x, controlling for the remaining columns of x. Each element
rho(i,j) is the partial correlation between x(:,i)
and x(:,j), adjusted for the other columns. rho
is a symmetric -by- matrix with ones on the diagonal.
rho = partialcorr (x, z) controls instead for the
variables in the -by- matrix z, returning the
-by- partial correlations among the columns of x.
rho = partialcorr (x, y, z) returns the
-by- matrix of partial correlations between the columns of
the -by- matrix x and the -by- matrix
y, controlling for z. Element rho(i,j) is the partial
correlation between x(:,i) and y(:,j).
[rho, pval] = partialcorr (…) also returns pval,
a matrix of p-values for testing the hypothesis of no partial correlation
against the alternative selected by 'Tail'.
The following Name/Value pairs are accepted:
'Type''Pearson' (default) for linear partial correlation, or
'Spearman' for rank partial correlation (computed on the ranks of the
data). 'Kendall' is not supported and raises an error, as in
MATLAB.'Rows''all' (default) uses all rows regardless of missing values (any
NaN yields a NaN result); 'complete' uses only the rows
with no missing values across all supplied variables; 'pairwise' uses,
for each computed coefficient, the rows with no missing values among just the
variables involved in that coefficient.'Tail''both' (default, nonzero
correlation), 'right' (greater than zero), or 'left' (less than
zero).The partial correlation is computed by regressing each of the two variables on the controlling variables (with an intercept) and correlating the residuals. The p-value uses a Student’s statistic with degrees of freedom, where is the number of controlling variables and the number of observations used.
See also: partialcorri, corr, corrcoef, tiedrank
Source Code: partialcorr
Partial correlations among four variables, each pair adjusted for the other two.
x = [0.42 1.30 -0.85 0.11; 1.15 -0.47 0.33 1.82; -0.98 0.55 1.21 -0.34; ...
0.63 2.10 -0.19 0.48; 1.88 -1.02 0.74 0.05; -0.31 0.86 -1.44 1.29; ...
0.77 0.14 0.58 -0.71; -1.52 1.77 0.02 0.94; 0.29 -0.63 1.36 0.37];
rho = partialcorr (x)
rho = 1.0000 -0.6532 -0.3840 -0.2238 -0.6532 1.0000 -0.6728 -0.3237 -0.3840 -0.6728 1.0000 -0.5119 -0.2238 -0.3237 -0.5119 1.0000