NAG FL Interface
g02byf (corrmat_partial)
1
Purpose
g02byf computes a partial correlation/variance-covariance matrix from a correlation or variance-covariance matrix computed by
g02bxf.
2
Specification
Fortran Interface
Integer, Intent (In) |
:: |
m, ny, nx, isz(m), ldr, ldp |
Integer, Intent (Inout) |
:: |
ifail |
Real (Kind=nag_wp), Intent (In) |
:: |
r(ldr,m) |
Real (Kind=nag_wp), Intent (Inout) |
:: |
p(ldp,ny) |
Real (Kind=nag_wp), Intent (Out) |
:: |
wk(ny*nx+nx*(nx+1)/2) |
|
C Header Interface
#include <nag.h>
void |
g02byf_ (const Integer *m, const Integer *ny, const Integer *nx, const Integer isz[], const double r[], const Integer *ldr, double p[], const Integer *ldp, double wk[], Integer *ifail) |
|
C++ Header Interface
#include <nag.h> extern "C" {
void |
g02byf_ (const Integer &m, const Integer &ny, const Integer &nx, const Integer isz[], const double r[], const Integer &ldr, double p[], const Integer &ldp, double wk[], Integer &ifail) |
}
|
The routine may be called by the names g02byf or nagf_correg_corrmat_partial.
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,
,
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.
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:
– Integer
Input
-
On entry: the number of variables in the variance-covariance/correlation matrix given in
r.
Constraint:
.
-
2:
– Integer
Input
-
On entry: the number of variables, , for which partial correlation coefficients are to be computed.
Constraint:
.
-
3:
– Integer
Input
-
On entry: the number of variables, , which are to be considered as fixed.
-
4:
– Integer array
Input
-
On entry: 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 .
-
5:
– Real (Kind=nag_wp) array
Input
-
On entry: the variance-covariance or correlation matrix for the
m variables as given by
g02bxf. 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 routine.
-
6:
– Integer
Input
-
On entry: the first dimension of the array
r as declared in the (sub)program from which
g02byf is called.
Constraint:
.
-
7:
– Real (Kind=nag_wp) array
Output
-
On exit: 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.
-
8:
– Integer
Input
-
On entry: the first dimension of the array
p as declared in the (sub)program from which
g02byf is called.
Constraint:
.
-
9:
– Real (Kind=nag_wp) array
Workspace
-
-
10:
– Integer
Input/Output
-
On entry:
ifail must be set to
,
. If you are unfamiliar with this argument you should refer to
Section 4 in the Introduction to the NAG Library FL Interface for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value
is recommended. If the output of error messages is undesirable, then the value
is recommended. Otherwise, if you are not familiar with this argument, the recommended value is
.
When the value is used it is essential to test the value of ifail on exit.
On exit:
unless the routine detects an error or a warning has been flagged (see
Section 6).
6
Error Indicators and Warnings
If on entry
or
, explanatory error messages are output on the current error message unit (as defined by
x04aaf).
Errors or warnings detected by the routine:
-
On entry, .
Constraint: .
On entry, and .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, , and .
Constraint: .
On entry, .
Constraint: .
-
On entry,
values of
isz are greater than zero and
.
Constraint: exactly
nx values of
isz must be greater than zero.
On entry,
values of
isz are less than zero and
.
Constraint: exactly
ny values of
isz must be less than zero.
-
On entry, the correlation matrix of the independent variables is singular.
Try removing some of the variables by setting the appropriate element of .
On entry, the square root of the correlation matrix of the independent variables is singular.
Try removing some of the variables by setting the appropriate element of .
-
On entry, a diagonal element of the partial covariance matrix is zero.
Constraint:
r must be positive definite.
On entry, a diagonal element of the partial covariance matrix is zero and an element of the partial correlation matrix is greater than
.
Constraint:
r must be positive definite.
On entry, an element of the partial correlation matrix is greater than
.
Constraint:
r must be positive definite.
An unexpected error has been triggered by this routine. Please
contact
NAG.
See
Section 7 in the Introduction to the NAG Library FL Interface for further information.
Your licence key may have expired or may not have been installed correctly.
See
Section 8 in the Introduction to the NAG Library FL Interface for further information.
Dynamic memory allocation failed.
See
Section 9 in the Introduction to the NAG Library FL Interface for further information.
7
Accuracy
g02byf 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
f07gdf.
8
Parallelism and Performance
g02byf is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
g02byf makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the
X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the
Users' Note for your implementation for any additional implementation-specific information.
Models that represent the linear associations given by partial correlations can be fitted using the multiple regression routine
g02daf.
10
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
g02bxf and the partial correlation between deaths and smoke given sulphur dioxide is computed using
g02byf. Both correlation matrices are printed using the routine
x04caf.
10.1
Program Text
10.2
Program Data
10.3
Program Results