Computes partial correlations or covariances from the covariance or correlation matrix.
COR — NVAR by NVAR correlation or covariance matrix. (Input)
NIND — Number of
“independent” variables to to be used in the partial correlations.
(Input)
If NIND is −1, the
independent variables are taken to be the NVAR
− NDEP variables not in
INDDEP. If NIND is zero, no
independent variables are used, and p-values for the input dependent (see
INDDEP)
correlations (or covariances) are computed. The partial correlations
(covariances) are the correlations (covariances) between the dependent variables
after removing the linear effect of the independent variables. NIND and NDEP cannot
simultaneously be − 1.
IND — Vector of
length NIND
containing the column (or row) numbers in COR of the independent
variables. (Input, if NIND > 0; not
referenced otherwise)
If NIND is negative or
zero, IND is not
used and can be dimensioned of length 1 in the calling program.
NDEP — Number of
variables for which partial correlations (covariances) are desired (the number
of “dependent” variables). (Input)
If NDEP is − 1, the
dependent variables are taken as the NVAR
− NIND variables not in
IND. NIND and NDEP cannot
simultaneously be − 1.
INDDEP — Vector of length NDEP containing the
indices of the dependent variables. (Input, if NDEP > 0; not
referenced otherwise)
If NDEP is 1, INDDEP is not used and
can be dimensioned of length 1 in the calling program.
PCOR — Matrix of size m by m
containing the partial correlations or partial covariances. (Output)
m = NDEP if NDEP > 0, and
m = NVAR
− NIND otherwise. If
NIND = 0, then
COR and PCOR can share the
same memory location.
NVAR — Number of
variables in COR.
(Input)
Default: NVAR
= size (COR,1).
LDCOR — Leading
dimension of COR
exactly as specified in the dimension statement in the calling program.
(Input)
Default: LDCOR
= size (COR,1).
NDF — Number of
degrees of freedom in COR.
(Input)
If the number of degrees of freedom in COR varies from
element to element, then a conservative choice for NDF is the minimum
degrees of freedom for all elements in COR. If NDF is not known, then
NDF ≤ 0 defaults to
NDF =
100.
Default: NDF
= 0.
ICOR — Partial
correlations/covariances option. (Input)
Default: ICOR
= 0.
ICOR Action
1 Partial correlations are desired.
0 Partial covariances are desired.
Partial correlations can be computed when either a correlation or a covariance matrix in input in COR. To compute partial covariances, COR must contain a covariance matrix.
LDPCOR — Leading
dimension of PCOR exactly as
specified in the dimension statement of the calling program.
(Input)
Default: LDPCOR
= size (PCOR,1).
NDFP — Number of
degrees of freedom in the test that the partial correlation (covariance) is
zero. (Output)
This will usually be NDF − NIND but will be
greater than this value if the variables in IND are
computationally linearly related.
PVAL — Matrix of
size m by m (see PCOR)
containing the p-values for testing the null hypothesis that the
associated partial correlation (covariance) is zero. (Output)
The p-values reported in PVAL assume that the
observations from which COR was computed
follow a multivariate normal distribution and that each element in COR has NDF degrees of
freedom.
LDPVAL — Leading
dimension of PVAL exactly as
specified in the dimension statement in the calling program.
(Input)
Default: LDPVAL
= size(PVAL,
1).
Generic: CALL PCORR (COR, NIND, IND, NDEP, INDDEP, PCOR [,…])
Specific: The specific interface names are S_PCORR and D_PCORR.
Single: CALL PCORR (NVAR, COR, LDCOR, NDF, ICOR, NIND, IND, NDEP, INDDEP, PCOR, LDPCOR, NDFP, PVAL, LDPVAL)
Double: The double precision name is DPCORR.
Routine PCORR computes partial correlations or partial covariances from an input correlation or covariance matrix. If the “independent” variables (the linear “effect” of the independent variables is removed in computing the partial correlations/covariances) are linearly related to one another, PCORR detects the linearity and eliminates one or more of the independent variables from the list of independent variables. The number of variables eliminated, if any, can be determined from argument NDFP.
Given a correlation or covariance matrix Σ partitioned as
Routine PCORR computes the partial covariances (of the standardized variables if Σ is a correlation matrix) as
If partial correlations are desired, these are computed as
where “diag” denotes the matrix containing the diagonal of
its argument along its diagonal with zeros off the diagonal. If Σ11is singular, then as
many variables as required are deleted from
Σ11 (and Σ12) in order to
eliminate the linear dependency(ies). The computations then proceed as
above.
The p-value for a partial correlation (covariance)
tests the null hypothesis
H0 : ρij|1 = 0 (H0 : σij|1 = 0), where ρij|1(σij|1) is the (i,
j) element in matrix P22|1 (Σ22|1). The
p-values are returned in PVAL.
If NDF
is not known, the p-values are computed as if each element in COR
had 100 degrees of freedom. When NDF
is not known, the resulting p-values may may be useful for comparison,
but they should not be used as an approximation to the actual probabilities.
1. Workspace may be explicitly provided, if desired, by use of P2ORR/DP2ORR. The reference is:
CALL P2ORR (NVAR, COR, LDCOR, NDF, ICOR, NIND, IND, NDEP, INDDEP, PCOR, LDPCOR, NDFP, PVAL, LDPVAL, SXY, SXX, LDSXX, IY, IX)
The additional arguments are as follows:
SXY — Work vector of length m * n.
SXX — Work vector of length n2.
LDSXX — The value of n.
IY — Work vector of length NVAR.
IX — Work vector of length NVAR.
2. Informational errors
Type Code
4 1 COR is incorrectly specified for two independent variables.
4 2 COR is incorrectly specified for an independent variable and a dependent variable.
4 3 COR is incorrectly specified for two dependent variables.
4 4 A computed partial correlation is greater than one.
The following example computes partial correlations from a 9 variable correlation matrix originally given by Emmett (1949). The partial correlations between the remaining variables, after adjusting for variables 1, 3, and 9, are computed. Note in the output that the row and column labels are column numbers, not variable numbers. The corresponding variable numbers would be 2, 4, 5, 6, 7, and 8, respectively.
! SPECIFICATIONS FOR PARAMETERS
USE PCORR_INT
USE UMACH_INT
USE WRRRN_INT
IMPLICIT NONE
INTEGER ICOR, LDCOR, LDP, LDPCOR, NDEP, NDF, NIND, NVAR
PARAMETER (ICOR=1, LDCOR=9, LDP=6, LDPCOR=6, NDEP=-1, NDF=30, &
NIND=3, NVAR=9)
!
INTEGER IND(NIND), INDDEP(1), NDFP, NOUT
REAL COR(LDCOR,NVAR), P(LDP,LDP), PCOR(LDPCOR,LDPCOR)
!
DATA IND/1, 3, 9/
!
DATA COR/1.000, 0.523, 0.395, 0.471, 0.346, 0.426, 0.576, 0.434, &
0.639, 0.523, 1.000, 0.479, 0.506, 0.418, 0.462, 0.547, &
0.283, 0.645, 0.395, 0.479, 1.000, 0.355, 0.270, 0.254, &
0.452, 0.219, 0.504, 0.471, 0.506, 0.355, 1.000, 0.691, &
0.791, 0.443, 0.285, 0.505, 0.346, 0.418, 0.270, 0.691, &
1.000, 0.679, 0.383, 0.149, 0.409, 0.426, 0.462, 0.254, &
0.791, 0.679, 1.000, 0.372, 0.314, 0.472, 0.576, 0.547, &
0.452, 0.443, 0.383, 0.372, 1.000, 0.385, 0.680, 0.434, &
0.283, 0.219, 0.285, 0.149, 0.314, 0.385, 1.000, 0.470, &
0.639, 0.645, 0.504, 0.505, 0.409, 0.472, 0.680, 0.470, &
1.000/
!
CALL PCORR (COR, NIND, IND, NDEP, INDDEP, PCOR, NDF=NDF, &
ICOR=ICOR, NDFP=NDFP, PVAL=P)
!
CALL UMACH (2, NOUT)
WRITE (NOUT,*) 'The degrees of freedom are ', NDFP
CALL WRRRN ('PCOR', PCOR)
CALL WRRRN ('P', P)
!
END
The degrees of freedom are 27
PCOR
1 2
3 4
5 6
1 1.000
0.224 0.194 0.211 0.125
-0.061
2 0.224 1.000 0.605
0.720 0.092 0.025
3 0.194
0.605 1.000 0.598 0.123
-0.077
4 0.211 0.720 0.598
1.000 0.035 0.086
5 0.125
0.092 0.123 0.035 1.000
0.062
6 -0.061 0.025 -0.077
0.086 0.062 1.000
P
1 2 3 4 5 6
1 0.0000 0.2525 0.3232 0.2801 0.5249 0.7576
2 0.2525 0.0000 0.0006 0.0000 0.6417 0.9000
3 0.3232 0.0006 0.0000 0.0007 0.5328 0.6982
4 0.2801 0.0000 0.0007 0.0000 0.8602 0.6650
5 0.5249 0.6417 0.5328 0.8602 0.0000 0.7532
6 0.7576 0.9000 0.6982 0.6650 0.7532 0.0000
PHONE: 713.784.3131 FAX:713.781.9260 |