Skip to Main Content Skip to Search
Product Documentation

partialcorr - Linear or rank partial correlation coefficients

Syntax

RHO = partialcorr(X)
RHO = partialcorr(X,Z)
RHO = partialcorr(X,Y,Z)
[RHO,PVAL] = partialcorr(...)
[...] = partialcorr(...,param1,val1,param2,val2,...)

Description

RHO = partialcorr(X) returns the sample linear partial correlation coefficients between pairs of variables in X, controlling for the remaining variables in X. X is an n-by-p matrix, with rows corresponding to observations, and columns corresponding to variables. RHO is a symmetric p-by-p matrix, where the (i,j)-th entry is the sample linear partial correlation between the i-th and j-th columns in X.

RHO = partialcorr(X,Z) returns the sample linear partial correlation coefficients between pairs of variables in X controlling for the variables in Z. X is an n-by-p matrix, and Z is an n-by-q matrix with rows corresponding to observations, and columns corresponding to variables. The output, RHO, is a symmetric p-by-p matrix.

RHO = partialcorr(X,Y,Z) returns the sample linear partial correlation coefficients between pairs of variables between X and Y, controlling for the variables in Z. X is an n-by-p1 matrix, Y an n-by-p2 matrix, and Z is an n-by-q matrix, with rows corresponding to observations, and columns corresponding to variables. RHO is a p1-by-p2 matrix, where the (i, j)th entry is the sample linear partial correlation between the ith column in X and the jth column in Y.

If the covariance matrix of [X,Z] is

then the partial correlation matrix of X, controlling for Z, can be defined formally as a normalized version of the covariance matrix Sxy = S11 – (S12S22–1S12T)

[RHO,PVAL] = partialcorr(...) also returns PVAL, a matrix of p-values for testing the hypothesis of no partial correlation against the alternative that there is a nonzero partial correlation. Each element of PVAL is the p value for the corresponding element of RHO. If PVAL(I,J) is small, say less than 0.05, then the partial correlation, RHO(I,J), is significantly different from zero.

[...] = partialcorr(...,param1,val1,param2,val2,...) specifies additional parameters and their values. Valid parameter/value pars are listed in the following table.

ParameterValues
'type'
  • 'Pearson' — To compute Pearson (linear) partial correlations. This is the default.

  • 'Spearman' — To compute Spearman (rank) partial correlations.

'rows'
  • 'all' — To use all rows regardless of missing (NaN) values. This is the default.

  • 'complete' — To use only rows with no missing values.

  • 'pairwise' — To compute RHO(I,J) using rows with no missing values in column I or J.

'tail'

The alternative hypothesis against which to compute p-values for testing the hypothesis of no partial correlation.

  • 'both' (the default) — the correlation is not zero.

  • 'right' — the correlation is greater than zero.

  • 'left' — the correlation is less than zero.

A 'pairwise' value for the rows parameter can produce a RHO that is not positive definite. A 'complete' value always produces a positive definite RHO, but when data is missing, the estimates will be based on fewer observations, in general.

partialcorr computes p-values for linear and rank partial correlations using a Student's t distribution for a transformation of the correlation. This is exact for linear partial correlation when X and Z are normal, but is a large-sample approximation otherwise.

See Also

corr | corrcoef | tiedrank

  


 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS