PDF version (NAG web site
, 64-bit version, 64-bit version)
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
Description
Partial correlation can be used to explore the association between pairs of random variables in the presence of other variables. For three variables,
,
and
, the partial correlation coefficient between
and
given
is computed as:
where
is the product-moment correlation coefficient between variables with subscripts
and
. The partial correlation coefficient is a measure of the linear association between
and
having eliminated the effect due to both
and
being linearly associated with
. That is, it is a measure of association between
and
conditional upon fixed values of
. Like the full correlation coefficients the partial correlation coefficient takes a value in the range (
) with the value
indicating no association.
In general, let a set of variables be partitioned into two groups
and
with
variables in
and
variables in
and let the variance-covariance matrix of all
variables be partitioned into,
The variance-covariance of
conditional on fixed values of the
variables is given by:
The partial correlation matrix is then computed by standardizing
,
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
is the computed partial correlation coefficient then the appropriate
statistic is
which has approximately a Student's
-distribution with
degrees of freedom, where
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:
– int64int32nag_int scalar
-
The number of variables, , for which partial correlation coefficients are to be computed.
Constraint:
.
- 2:
– int64int32nag_int scalar
-
The number of variables, , which are to be considered as fixed.
- 3:
– int64int32nag_int array
-
Indicates which variables belong to set
and
.
- The
th variable is a variable, for .
- The th variable is a variable.
- The th variable is not included in the computations.
Constraints:
- exactly ny elements of isz must be ;
- exactly nx elements of isz must be .
- 4:
– double array
-
ldr, the first dimension of the array, must satisfy the constraint
.
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:
– 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:
.
Output Parameters
- 1:
– double array
-
The strict upper triangle of
p contains the strict upper triangular part of the
by
partial correlation matrix. The lower triangle contains the lower triangle of the
by
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:
– int64int32nag_int scalar
unless the function detects an error (see
Error Indicators and Warnings).
Error Indicators and Warnings
Errors or warnings detected by the function:
-
-
On entry, | , |
or | , |
or | , |
or | , |
or | , |
or | . |
-
-
On entry, | there are not exactly ny elements of , |
or | there are not exactly nx elements of . |
-
-
On entry, the variance-covariance/correlation matrix of the variables, , is not of full rank. Try removing some of the variables by setting the appropriate element of .
-
-
Either a diagonal element of the partial variance-covariance matrix,
, 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.
-
An unexpected error has been triggered by this routine. Please
contact
NAG.
-
Your licence key may have expired or may not have been installed correctly.
-
Dynamic memory allocation failed.
Accuracy
nag_correg_corrmat_partial (g02by) computes the partial variance-covariance matrix,
, by computing the Cholesky factorization of
. If
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
Data, given by
Osborn (1979), on the number of deaths, smoke (
) and sulphur dioxide (parts/million) during an intense period of fog is input. The correlations are computed using
nag_correg_corrmat (g02bx) and the partial correlation between deaths and smoke given sulphur dioxide is computed using
nag_correg_corrmat_partial (g02by). Both correlation matrices are printed using the function
nag_file_print_matrix_real_gen (x04ca).
Open in the MATLAB editor:
g02by_example
function g02by_example
fprintf('g02by example results\n\n');
x = [ 112 0.30 0.09;
140 0.49 0.16;
143 0.61 0.22;
120 0.49 0.14;
196 2.64 0.75;
294 3.45 0.86;
513 4.46 1.34;
518 4.46 1.34;
430 1.22 0.47;
274 1.22 0.47;
255 0.32 0.22;
236 0.29 0.23;
256 0.50 0.26;
222 0.32 0.16;
213 0.32 0.16];
[xbar, std, v, r, ifail] = g02bx(x);
nx = int64(1);
ny = int64(2);
isz = [int64(-1); -1; 1];
[p, ifail] = g02by(ny, nx, isz, r);
mtitle = 'Correlation matrix:';
matrix = 'Upper';
diag = 'Non-unit';
[ifail] = x04ca( ...
matrix, diag, r, mtitle);
fprintf('\n');
mtitle = 'Partial Correlation matrix:';
diag = 'Unit';
[ifail] = x04ca( ...
matrix, diag, p, mtitle);
g02by example results
Correlation matrix:
1 2 3
1 1.0000 0.7560 0.8309
2 1.0000 0.9876
3 1.0000
Partial Correlation matrix:
1 2
1 1.0000 -0.7381
2 1.0000
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015