naginterfaces.library.correg.corrmat_partial¶
- naginterfaces.library.correg.corrmat_partial(ny, nx, isz, r)[source]¶
corrmat_partial
computes a partial correlation/variance-covariance matrix from a correlation or variance-covariance matrix computed bycorrmat()
.For full information please refer to the NAG Library document for g02by
https://support.nag.com/numeric/nl/nagdoc_30.2/flhtml/g02/g02byf.html
- Parameters
- nyint
The number of variables, , for which partial correlation coefficients are to be computed.
- nxint
The number of variables, , which are to be considered as fixed.
- iszint, array-like, shape
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.
- rfloat, array-like, shape
The variance-covariance or correlation matrix for the variables as given by
corrmat()
. 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.
- Returns
- pfloat, ndarray, shape
The strict upper triangle of contains the strict upper triangular part of the partial correlation matrix. The lower triangle contains the lower triangle of the partial variance-covariance matrix if the matrix given in is a variance-covariance matrix. If the matrix given in is a partial correlation matrix then the variance-covariance matrix is for standardized variables.
- Raises
- NagValueError
- (errno )
On entry, , and .
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, values of are greater than zero and .
Constraint: exactly values of must be greater than zero.
- (errno )
On entry, values of are less than zero and .
Constraint: exactly values of must be less than zero.
- (errno )
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 .
- (errno )
On entry, the correlation matrix of the independent variables is singular.
Try removing some of the variables by setting the appropriate element of .
- (errno )
On entry, an element of the partial correlation matrix is greater than .
Constraint: must be positive definite.
- (errno )
On entry, a diagonal element of the partial covariance matrix is zero.
Constraint: must be positive definite.
- (errno )
On entry, a diagonal element of the partial covariance matrix is zero and an element of the partial correlation matrix is greater than .
Constraint: must be positive definite.
- Notes
In the NAG Library the traditional C interface for this routine uses a different algorithmic base. Please contact NAG if you have any questions about compatibility.
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