hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_correg_corrmat_partial (g02by)

Purpose

nag_correg_corrmat_partial (g02by) computes a partial correlation/variance-covariance matrix from a correlation or variance-covariance matrix computed by nag_correg_corrmat (g02bx).

Syntax

[p, ifail] = g02by(ny, nx, isz, r, 'm', m)
[p, ifail] = nag_correg_corrmat_partial(ny, nx, isz, r, 'm', m)

Description

Partial correlation can be used to explore the association between pairs of random variables in the presence of other variables. For three variables, y1y1, y2y2 and x3x3, the partial correlation coefficient between y1y1 and y2y2 given x3x3 is computed as:
(r12r13r23)/(sqrt((1r132)(1r232))),
r12-r13r23 (1-r132)(1-r232) ,
where rijrij is the product-moment correlation coefficient between variables with subscripts ii and jj. The partial correlation coefficient is a measure of the linear association between y1y1 and y2y2 having eliminated the effect due to both y1y1 and y2y2 being linearly associated with x3x3. That is, it is a measure of association between y1y1 and y2y2 conditional upon fixed values of x3x3. Like the full correlation coefficients the partial correlation coefficient takes a value in the range (1,1-1,1) with the value 00 indicating no association.
In general, let a set of variables be partitioned into two groups YY and XX with nyny variables in YY and nxnx variables in XX and let the variance-covariance matrix of all ny + nxny+nx variables be partitioned into,
[ Σxx Σxy Σyx Σyy ]
.
[ Σxx Σxy Σyx Σyy ] .
The variance-covariance of YY conditional on fixed values of the XX variables is given by:
Σyx = ΣyyΣyxΣxx1Σxy.
Σyx=Σyy-ΣyxΣxx -1Σxy.
The partial correlation matrix is then computed by standardizing ΣyxΣyx,
diag(Σyx)(1/2)Σyxdiag(Σyx)(1/2).
diag(Σyx) -12Σyxdiag(Σyx) -12.
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 rr is the computed partial correlation coefficient then the appropriate tt statistic is
r×sqrt((nnx2)/(1r2)),
rn-nx-2 1-r2 ,
which has approximately a Student's tt-distribution with nnx2n-nx-2 degrees of freedom, where nn is the number of observations from which the full correlation coefficients were computed.

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

Parameters

Compulsory Input Parameters

1:     ny – int64int32nag_int scalar
The number of YY variables, nyny, for which partial correlation coefficients are to be computed.
Constraint: ny2ny2.
2:     nx – int64int32nag_int scalar
The number of XX variables, nxnx, which are to be considered as fixed.
Constraints:
  • nx1nx1;
  • ny + nxmny+nxm.
3:     isz(m) – int64int32nag_int array
m, the dimension of the array, must satisfy the constraint m3m3.
Indicates which variables belong to set XX and YY.
isz(i) < 0iszi<0
The iith variable is a YY variable, for i = 1,2,,mi=1,2,,m.
isz(i) > 0iszi>0
The iith variable is a XX variable.
isz(i) = 0iszi=0
The iith variable is not included in the computations.
Constraints:
  • exactly ny elements of isz must be < 0<0;
  • exactly nx elements of isz must be > 0>0.
4:     r(ldr,m) – double array
ldr, the first dimension of the array, must satisfy the constraint ldrmldrm.
The variance-covariance or correlation matrix for the m variables as given by nag_correg_corrmat (g02bx). Only the upper triangle need be given.
Note:  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.

Optional Input Parameters

1:     m – int64int32nag_int scalar
Default: The dimension of the array isz and the first dimension of the array r and the second dimension of the array r. (An error is raised if these dimensions are not equal.)
The number of variables in the variance-covariance/correlation matrix given in r.
Constraint: m3m3.

Input Parameters Omitted from the MATLAB Interface

ldr ldp wk

Output Parameters

1:     p(ldp,ny) – double array
ldpnyldpny.
The strict upper triangle of p contains the strict upper triangular part of the nyny by nyny partial correlation matrix. The lower triangle contains the lower triangle of the nyny by nyny partial variance-covariance matrix if the matrix given in r is a variance-covariance matrix. If the matrix given in r is a partial correlation matrix then the variance-covariance matrix is for standardized variables.
2:     ifail – int64int32nag_int scalar
ifail = 0ifail=0 unless the function detects an error (see [Error Indicators and Warnings]).

Error Indicators and Warnings

Errors or warnings detected by the function:
  ifail = 1ifail=1
On entry,m < 3m<3,
orny < 2ny<2,
ornx < 1nx<1,
orny + nx > mny+nx>m,
orldr < mldr<m,
orldp < nyldp<ny.
  ifail = 2ifail=2
On entry,there are not exactly ny elements of isz < 0isz<0,
orthere are not exactly nx elements of isz > 0isz>0.
  ifail = 3ifail=3
On entry, the variance-covariance/correlation matrix of the XX variables, ΣxxΣxx, is not of full rank. Try removing some of the XX variables by setting the appropriate element of isz = 0isz=0.
  ifail = 4ifail=4
Either a diagonal element of the partial variance-covariance matrix, ΣyxΣyx, is zero and/or a computed partial correlation coefficient is greater than one. Both indicate that the matrix input in r was not positive definite.

Accuracy

nag_correg_corrmat_partial (g02by) computes the partial variance-covariance matrix, ΣyxΣyx, by computing the Cholesky factorization of ΣxxΣxx. If ΣxxΣxx is not of full rank the computation will fail. For a statement on the accuracy of the Cholesky factorization see nag_lapack_dpptrf (f07gd).

Further Comments

Models that represent the linear associations given by partial correlations can be fitted using the multiple regression function nag_correg_linregm_fit (g02da).

Example

function nag_correg_corrmat_partial_example
ny = int64(2);
nx = int64(1);
isz = [int64(-1);-1;1];
r = [17053.69523809524, 152.8584285714286, 45.94742857142857;
     152.8584285714286, 2.397368571428571, 0.6475057142857144;
     45.94742857142857, 0.6475057142857144, 0.1793171428571428];
[p, ifail] = nag_correg_corrmat_partial(ny, nx, isz, r)
 

p =

   1.0e+03 *

    5.2803   -0.0007
   -0.0131    0.0001


ifail =

                    0


function g02by_example
ny = int64(2);
nx = int64(1);
isz = [int64(-1);-1;1];
r = [17053.69523809524, 152.8584285714286, 45.94742857142857;
     152.8584285714286, 2.397368571428571, 0.6475057142857144;
     45.94742857142857, 0.6475057142857144, 0.1793171428571428];
[p, ifail] = g02by(ny, nx, isz, r)
 

p =

   1.0e+03 *

    5.2803   -0.0007
   -0.0131    0.0001


ifail =

                    0



PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2013