NAG CL Interface
g02byc (corrmat_​partial)

1 Purpose

g02byc computes a partial correlation/variance-covariance matrix from a correlation or variance-covariance matrix computed by g02bxc.

2 Specification

#include <nag.h>
void  g02byc (Integer m, Integer ny, Integer nx, const Integer sz[], const double r[], Integer tdr, double p[], Integer tdp, NagError *fail)
The function may be called by the names: g02byc, nag_correg_corrmat_partial or nag_partial_corr.

3 Description

Partial correlation can be used to explore the association between pairs of random variables in the presence of other variables. For three variables, y 1 , y 2 and x 3 the partial correlation coefficient between y 1 and y 2 given x 3 is computed as:
r 12 - r 13 r 23 1 - r 13 2 1 - r 23 2 ,  
where r ij is the product-moment correlation coefficient between variables with subscripts i and j . The partial correlation coefficient is a measure of the linear association between y 1 and y 2 having eliminated the effect due to both y 1 and y 2 being linearly associated with x 3 . That is, it is a measure of association between y 1 and y 2 conditional upon fixed values of x 3 . Like the full correlation coefficients the partial correlation coefficient takes a value in the range -1,1 with the value 0 indicating no association.
In general, let a set of variables be partitioned into two groups Y and X with n y variables in Y and n x variables in X and let the variance-covariance matrix of all n y + n x variables be partitioned into,
Σ xx Σ xy Σ yx Σ yy  
The variance-covariance of Y conditional on fixed values of the X variables is given by:
Σ yx = Σ yy - Σ yx Σ xx -1 Σ xy  
The partial correlation matrix is then computed by standardizing Σ yx ,
diag Σ yx - 1 2 Σ yx diag Σ yx - 1 2 .  
To test the hypothesis that a partial correlation is zero under the assumption that the data has an approximately Normal distribution a test similar to the test for the full correlation coefficient can be used. If r is the computed partial correlation coefficient then the appropriate t statistic is
r n-n x - 2 1 - r 2  
which has approximately a Student's t -distribution with n-n x - 2 degrees of freedom, where n is the number of observations from which the full correlation coefficients were computed.

4 References

Krzanowski W J (1990) Principles of Multivariate Analysis Oxford University Press
Morrison D F (1967) Multivariate Statistical Methods McGraw–Hill
Osborn J F (1979) Statistical Exercises in Medical Research Blackwell
Snedecor G W and Cochran W G (1967) Statistical Methods Iowa State University Press

5 Arguments

1: m Integer Input
On entry: the number of variables in the variance-covariance/correlation matrix given in r.
Constraint: m3 .
2: ny Integer Input
On entry: the number of Y variables, n y , for which partial correlation coefficients are to be computed.
Constraint: ny2 .
3: nx Integer Input
On entry: the number of X variables, n x , which are to be considered as fixed.
Constraints:
  • nx1 ;
  • ny + nx m .
4: sz[m] const Integer Input
On entry: indicates which variables belong to set X and Y .
sz i < 0
The i th variable is a Y variable, for i=1,2,,m.
sz i > 0
The i th variable is a X variable.
sz i = 0
The i th variable is not included in the computations.
Constraints:
  • exactly ny elements of sz must be < 0 ,
  • exactly nx elements of sz must be > 0 .
5: r[m×tdr] const double Input
Note: the i,jth element of the matrix R is stored in r[i-1×tdr+j-1].
On entry: the variance-covariance or correlation matrix for the m variables as given by g02bxc. Only the upper triangle need be given.
the matrix must be a full rank variance-covariance or correlation matrix and so be positive definite. This condition is not directly checked by the function.
6: tdr Integer Input
On entry: the stride separating matrix column elements in the array r.
Constraint: tdrm .
7: p[ny×tdp] double Output
Note: the i,jth element of the matrix P is stored in p[i-1×tdp+j-1].
On exit: the strict upper triangle of p contains the strict upper triangular part of the n y by n y partial correlation matrix. The lower triangle contains the lower triangle of the n y by n y partial variance-covariance matrix if the matrix given in r is a variance-covariance matrix. If the matrix given in r is a correlation matrix then the variance-covariance matrix is for standardized variables.
8: tdp Integer Input
On entry: the stride separating matrix column elements in the array p.
Constraint: tdpny .
9: fail NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

6 Error Indicators and Warnings

NE_2_INT_ARG_LT
On entry, tdp=value while ny=value . These arguments must satisfy tdpny .
On entry, tdr=value while m=value . These arguments must satisfy tdrm .
NE_3_INT_ARG_CONS
On entry, ny=value , nx=value and m=value . These arguments must satisfy ny + nx m .
NE_ALLOC_FAIL
Dynamic memory allocation failed.
NE_BAD_NX_SET
On entry, nx=value and there are not exactly nx values of sz<0 .
NE_BAD_NY_SET
On entry, ny=value and there are not exactly ny values of sz<0 .
Number of values of sz < 0 = value.
NE_COR_MAT_POSDEF
Either a diagonal element of the partial variance-covariance matrix is zero and/or a computed partial correlation coefficient is greater than 1. Both indicate that the matrix input in r was not positive definite.
NE_COR_MAT_RANK
On entry, either the variance-covariance matrix or the correlation matrix is not of full rank. Try removing some of the nx variables by setting the appropriate elements of sz to zero.
NE_INT_ARG_LT
On entry, m=value.
Constraint: m3.
On entry, nx=value.
Constraint: nx1.
On entry, ny=value.
Constraint: ny2.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.

7 Accuracy

g02byc computes the partial variance-covariance matrix, Σ yx , by computing the Cholesky factorization of Σ xx . If Σ xx is not of full rank the computation will fail.

8 Parallelism and Performance

g02byc is not threaded in any implementation.

9 Further Comments

Models that represent the linear associations given by partial correlations can be fitted using the multiple regression function g02dac.

10 Example

Data, given by Osborn (1979), on the number of deaths, smoke mg / m 3 and sulphur dioxide (parts/million) during an intense period of fog is input. The correlations are computed using g02bxc and the partial correlation between deaths and smoke given sulphur dioxide is computed using g02byc.

10.1 Program Text

Program Text (g02byce.c)

10.2 Program Data

Program Data (g02byce.d)

10.3 Program Results

Program Results (g02byce.r)