IMSL Statistics Reference Guide > Correlation and Covariance > PARTIAL_COV Function (PV-WAVE Advantage)
  

PARTIAL_COV Function (PV-WAVE Advantage)
Computes partial covariances or partial correlations from the covariance or correlation matrix.
Usage
result = PARTIAL_COV(n_independent, n_dependent, x)
Input Parameters
n_independent—Number of “independent” variables to be used in the partial covariances/correlations. The partial covariances/correlations are the covariances/correlations between the dependent variables after removing the linear effect of the independent variables.
n_dependent—Number of variables for which partial covariances/correlations are desired (the number of “dependent” variables).
x—The n by n covariance or correlation matrix, where n = n_independent + n_dependent. The rows/columns must be ordered such that the first n_independent rows/columns contain the independent variables, and the last n_dependent rows/columns contain the dependent variables. Array x must always be square symmetric.
Returned Value
result—Array of size n_dependent by n_dependent containing the partial covariances (the default) or partial correlations (set keyword Corr).
Input Keywords
Double—If present and nonzero, double precision is used.
Indices—An array containing values indicating the status of the variable as in Indices:
 
Table 4-1: Indices
Indices(i)
Variable is...
1
not used in analysis
0
dependent variable
1
independent variable
Default: The first n_independent elements of Indices are equal to 1, and the last n_dependent elements are equal to 0.
Cov—If present and nonzero, then partial covariances are calculated. (Default) Keywords Cov and Corr can not be used together.
Corr—If present and nonzero, then partial correlations are calculated. Keywords Cov and Corr can not be used together.
Input/Output Keywords
Df—On input, an integer indicating the number of degrees of freedom associated with input array x. If the number of degrees of freedom in x varies from element to element, then a conservative choice for Df is the minimum degrees of freedom for all elements in x.
Upon output, named variable into which the number of degrees of freedom in the test that the partial covariances/correlations are zero is stored. This value will usually be Df n_independent, but will be greater than this value if the independent variables are computationally linearly related. Keywords Df and Pvals must be used together.
Output Keywords
Pvals—Named variable into which an array of size n_dependent by n_dependent containing the p-values for testing the null hypothesis that the associated partial covariance/correlation is zero is stored. It is assumed that the observations from which x was computed flows a multivariate normal distribution and that each element in x has Df degrees of freedom. Keywords Df and Pvals must be used together.
Discussion
Function PARTIAL_COV computed partial covariances or partial correlations from an input covariance or correlation matrix. If the “independent” variables (the linear “effect” of the independent variables is removed in computing the partial covariances/correlations) are linearly related to one another, PARTIAL_COV detects the linearity and eliminates one or more of the independent variables from the list of independent variables. The number of variables eliminated, if any, can be determined from keyword Df.
Given a covariance or correlation matrix Σ partitioned as:
function PARTIAL_COV computed the partial covariances (of the standardized variables if Σ is a correlation matrix) as:
If partial correlations are desired, these are computed as:
where diag denotes the matrix containing the diagonal of its argument along its diagonal with zeros off the diagonal. If Σ11 is singular, then as many variables as required are deleted from Σ11 (and Σ12) in order to eliminate the linear dependencies. The computations then proceed as above.
The p-value for a partial covariance tests the null hypothesis H0: σij|1 = 0, where σij|1 is the (i, j) element in matrix Σ22|1. The p-value for a partial correlation tests the null hypothesis H0: ρij|1 = 0, where ρij|1 is the (i, j) element in matrix P22|1. The p-values are returned in Pvals. If the degrees of freedom for x, Df, is not known, the resulting p-values may be useful for comparison, but they should not be used as an approximation to the actual probabilities.
Example 1
The following example computes partial covariances, scaled from a nine-variable correlation matrix originally given by Emmett (1949). The first three rows and columns contain the independent variables and the final six rows and columns contain the dependent variables.
x  =  TRANSPOSE([ [6.300, 3.050, 1.933, 3.365, 1.317, 2.293, $
   2.586, 1.242, 4.363], [3.050, 5.400, 2.170, 3.346, 1.473, $
   2.303, 2.274, 0.750, 4.077], [1.933, 2.170, 3.800, 1.970, $
   0.798, 1.062, 1.576, 0.487, 2.673], [3.365, 3.346, 1.970, $
   8.100, 2.983, 4.828, 2.255, 0.925, 3.910], [1.317, 1.473, $
   0.798, 2.983, 2.300, 2.209, 1.039, 0.258, 1.687], [2.293, $
   2.303, 1.062, 4.828, 2.209, 4.600, 1.427, 0.768, 2.754], $
   [2.586, 2.274, 1.576, 2.255, 1.039, 1.427, 3.200, 0.785, $
   3.309], [1.242, 0.750, 0.487, 0.925, 0.258, 0.768, 0.785, $
   1.300, 1.458], [4.363, 4.077, 2.673, 3.910, 1.687, 2.754, $
   3.309, 1.458, 7.400]])
pcov  =  PARTIAL_COV(3, 6, x)
PM, pcov, Format = '(6F10.3)', Title = 'Partial Covariances'
 
; This results in the following output:
; Partial Covariances
;  0.000     0.000     0.000     0.000     0.000     0.000
;  0.000     0.000     0.000     0.000     0.000     0.000
;  0.000     0.000     0.000     0.000     0.000     0.000
;  0.000     0.000     0.000     5.495     1.895     3.084
;  0.000     0.000     0.000     1.895     1.841     1.476
;  0.000     0.000     0.000     3.084     1.476     3.403
Example 2
The following example computes partial correlations from a 9 variable correlation matrix originally given by Emmett (1949). The partial correlations between the remaining variables, after adjusting for variables 1, 3, and 9, are computed.
x = TRANSPOSE([ $
   [1.0, 0.523, 0.395, 0.471, 0.346, 0.426, 0.576, 0.434, $
   0.639], [0.523, 1.0, 0.479, 0.506, 0.418, 0.462, 0.547, $
   0.283, 0.645], [0.395, 0.479, 1.0, 0.355, 0.27, 0.254, $
   0.452, 0.219, 0.504], [0.471, 0.506, 0.355, 1.0, 0.691, $
   0.791, 0.443, 0.285, 0.505], [0.346, 0.418, 0.27, 0.691, $
   1.0, 0.679, 0.383, 0.149, 0.409], [0.426, 0.462, 0.254, $
   0.791, 0.679, 1.0, 0.372, 0.314, 0.472], [0.576, 0.547, $
   0.452, 0.443, 0.383, 0.372, 1.0, 0.385, 0.68], [0.434, $
   0.283, 0.219, 0.285, 0.149, 0.314, 0.385, 1.0, 0.47], $
   [0.639, 0.645, 0.504, 0.505, 0.409, 0.472, 0.68, 0.47, 1.0]])
df  =  30
indices  =  [1, 0, 1, 0, 0, 0, 0, 0, 1]
pcov  =  PARTIAL_COV(3, 6, x, Indices = indices, Df = df, $
   Pvals = pvals, /Corr)
PRINT, 'Degrees Of Freedom: ', df
; PV-WAVE prints: Degrees Of Freedom:           27
PM, pcov, Format = '(6F10.3)', Title = 'Partial Correlations'
; PV-WAVE prints the following:
; Partial Correlations
;   1.000     0.224     0.194     0.211     0.125    -0.061
;   0.224     1.000     0.605     0.720     0.092     0.025
;   0.194     0.605     1.000     0.598     0.123    -0.077
;   0.211     0.720     0.598     1.000     0.035     0.086
;   0.125     0.092     0.123     0.035     1.000     0.062
;   -0.061     0.025    -0.077     0.086     0.062     1.000
PM, pvals, Format = '(6F10.4)', Title = 'P values'
; PV-WAVE prints the following:
; P values
;   0.0000    0.2525    0.3232    0.2801    0.5249    0.7576
;   0.2525    0.0000    0.0006    0.0000    0.6417    0.9000
;   0.3232    0.0006    0.0000    0.0007    0.5328    0.6982
;   0.2801    0.0000    0.0007    0.0000    0.8602    0.6650
;   0.5249    0.6417    0.5328    0.8602    0.0000    0.7532
;   0.7576    0.9000    0.6982    0.6650    0.7532    0.0000
Warning Errors
STAT_NO_HYP_TESTSThe input matrix “x” has # degrees of freedom, and the rank of the dependent variables is #. There are not enough degrees of freedom for hypothesis testing. The elements of “Pvals” are set to NaN (not a number).
Fatal Errors
STAT_INVALID_MATRIX_1The input matrix “x” is incorrectly specified. A com­puted correlation is greater than 1 for variables # and #.
STAT_INVALID_PARTIALA computed partial correlation for variables
# and # is greater than 1. The input matrix “x” is not positive semi-definite.

Version 2017.0
Copyright © 2017, Rogue Wave Software, Inc. All Rights Reserved.