>  Docs Center  >  IDL Reference  >  Advanced Math and Stats  >  IMSL_PARTIAL_COV

IMSL_PARTIAL_COV

IMSL_PARTIAL_COV

The IMSL_PARTIAL_COV function computes partial covariances or partial correlations from the covariance or correlation matrix.

This routine requires an IDL Advanced Math and Stats license. For more information, contact your sales or technical support representative.

The IMSL_PARTIAL_COV function 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, IMSL_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:

IMSL_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: sij|1 = 0, where sij|1 is the (i, j) element in matrix S22|1. The p-value for a partial correlation tests the null hypothesis H0: rij|1 = 0, where rij|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.

Examples


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	=	IMSL_PARTIAL_COV(3, 6, x)
PM, pcov, FORMAT = '(6F10.3)', Title = 'Partial Covariances'

IDL prints:

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	=	IMSL_PARTIAL_COV(3, 6, x, Indices = indices, Df = df, $
  Pvals = pvals, /Corr)
PRINT, 'Degrees Of Freedom: ', df
PM, pcov, FORMAT = '(6F10.3)', Title = 'Partial Correlations'
PM, pvals, FORMAT = '(6F10.4)', Title = 'P values'

IDL Prints:

Errors


Warning Errors

STAT_NO_HYP_TESTS: The 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_1: The input matrix “x” is incorrectly specified. A computed correlation is greater than 1 for variables # and #.

STAT_INVALID_PARTIAL: A computed partial correlation for variables # and # is greater than 1. The input matrix “x” is not positive semi-definite.

Syntax


Result = IMSL_PARTIAL_COV(N_Independent, N_Dependent, X [, /DOUBLE] [, /CORR] [, /COV] [, DF=integer] [, INDICES=array] [, /PVALS=variable])

Return Value


Array of size N_Dependent by N_Dependent containing the partial covariances (the default) or partial correlations (set keyword CORR).

Arguments


N_Dependent

Number of variables for which partial covariances/correlations are desired (the number of “dependent” variables).

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.

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.

Keywords


DOUBLE (optional)

If present and nonzero, double precision is used.

CORR (optional)

If present and nonzero, then partial correlations are calculated. The keywords COV and CORR can not be used together.

COV (optional)

If present and nonzero, then partial covariances are calculated. (Default) The keywords COV and CORR can not be used together.

DF (optional)

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. The keywords DF and PVALS must be used together.

INDICES (optional)

An array containing values indicating the status of the variable, as follows:

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.

PVALS (optional)

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. The keywords DF and PVALS must be used together.

Version History


6.4

Introduced



© 2019 Harris Geospatial Solutions, Inc. |  Legal
My Account    |    Store    |    Contact Us