4  Correlação Parcial

Considere um vetor \(\mathbf{v}\), formado por um subconjunto de \(y's\) que inclui \(y_1\) e \(y_2\), sendo denotado por \(\mathbf{y}\). O outro subconjunto de \(y's\) que inclui \(y_3\) e \(y_4\) é denotado por \(\mathbf{x}\).

\[ \mathbf{v} = \begin{bmatrix} \mathbf{y} \\ \mathbf{x} \end{bmatrix} \text{, em que } \mathbf{y} = \begin{bmatrix} y_1, ..., y_2 \end{bmatrix} \text{' e } \mathbf{x} = \begin{bmatrix} y_3, ..., y_4 \end{bmatrix} \text{'} \]

Vamos comparar o coeficiente de correlação parcial entre \(y_1\) e \(y_2\) (\(\rho_{12}\)) com o coeficiente de correlação parcial condicional de \(y_1\) e \(y_2\) dado \(y_3\) e \(y_4\) (\(\rho_{12.34}\)).

Para isso, utilizaremos a seguinte matriz de variâncias e covariâncias:

\[ \mathbf{\Sigma} = \begin{bmatrix} 9 & 0 & 3 & 3 \\ 0 & 1 & -1 & 2 \\ 3 & -1 & 6 & -3 \\ 3 & 2 & -3 & 7 \\ \end{bmatrix} \text{.} \]

Primeiramente, calcularemos a correlação linear entre as variáveis \(y_1\) e \(y_2\), ou seja, \(\rho_{12}\) (vide Seção 1.3).

Com a matriz de variâncias e covariâncias salva no objeto Sigma, calculamos a raiz quadrada da diagonal de Sigma, ou seja, a raiz quadrada das variâncias (D).

Sigma <- matrix(
  c(9, 0, 3, 3, 0, 1, -1, 2, 3, -1, 6, -3, 3, 2, -3, 7), 
  nrow = 4, byrow = TRUE
)
Sigma
     [,1] [,2] [,3] [,4]
[1,]    9    0    3    3
[2,]    0    1   -1    2
[3,]    3   -1    6   -3
[4,]    3    2   -3    7
D <- sqrt(diag(Sigma))
D
[1] 3.000000 1.000000 2.449490 2.645751

Com a raiz quadrada das variâncias (D), calculamos os coeficientes de correlação por meio da seguinte expressão:

\[\mathbf{\rho} = \mathbf{D}_{\sigma}^{-1} \mathbf{\Sigma} \mathbf{D}_{\sigma}^{-1}\]

Ro <- solve(diag(D)) %*% Sigma %*% solve(diag(D))
Ro
          [,1]       [,2]       [,3]       [,4]
[1,] 1.0000000  0.0000000  0.4082483  0.3779645
[2,] 0.0000000  1.0000000 -0.4082483  0.7559289
[3,] 0.4082483 -0.4082483  1.0000000 -0.4629100
[4,] 0.3779645  0.7559289 -0.4629100  1.0000000

Assim, verificamos que as variáveis \(y_1\) e \(y_2\) são não correlacionadas (\(\rho_{12} = \rho_{21} = 0\)).

options nocenter ps=1000;
proc iml;
reset fuzz;

Sigma = {9  0  3  3, 
         0  1 -1  2, 
         3 -1  6 -3, 
         3  2 -3  7};
D = sqrt(diag(Sigma));
Ro = inv(D)*Sigma*inv(D);
print Sigma '     ' Ro[format=6.2];

Para calcular o coeficiente de correlação parcial entre \(y_1\) e \(y_2\) dada a ocorrência de \(y_3\) e \(y_4\) (\(\rho_{12.34}\)), particionaremos \(\Sigma\) da seguinte maneira:

\[ \mathbf{\Sigma}_{yy} = \begin{bmatrix} 9 & 0 \\ 0 & 1 \end{bmatrix} \text{ , } \mathbf{\Sigma}_{xx} = \begin{bmatrix} 6 & -3 \\ -3 & 7 \end{bmatrix} ,\mathbf{\Sigma}_{yx} = \begin{bmatrix} 3 & 3 \\ -1 & 2 \end{bmatrix} \]

Para particionar \(\mathbf{\Sigma}\), utilizaremos o Teorema 2 3.1.3.

A primeira partição (\(\mathbf{\Sigma}_{yy}\)) fica:

Ay <- matrix(c(1, 0, 0, 0, 0, 1, 0, 0), nrow = 2, byrow = TRUE)
Ay
     [,1] [,2] [,3] [,4]
[1,]    1    0    0    0
[2,]    0    1    0    0
Sigma_yy <- Ay %*% Sigma %*% t(Ay)
Sigma_yy
     [,1] [,2]
[1,]    9    0
[2,]    0    1

Note que esta partição corresponde ao \(\rho_{12} = 0\):

Dyy <- sqrt(diag(Sigma_yy))
Dyy
[1] 3 1
Ro_yy <- solve(diag(Dyy)) %*% Sigma_yy %*% solve(diag(Dyy))
Ro_yy
     [,1] [,2]
[1,]    1    0
[2,]    0    1

Para a partição \(\mathbf{\Sigma}_{xx}\) temos:

Ax <- matrix(c(0, 0, 1, 0, 0, 0, 0, 1), nrow = 2, byrow = TRUE)
Ax
     [,1] [,2] [,3] [,4]
[1,]    0    0    1    0
[2,]    0    0    0    1
Sigma_xx <- Ax %*% Sigma %*% t(Ax)
Sigma_xx
     [,1] [,2]
[1,]    6   -3
[2,]   -3    7

Por fim, a partição \(\mathbf{\Sigma}_{yx}\):

Sigma_yx <- Ay %*% Sigma %*% t(Ax)
Sigma_yx
     [,1] [,2]
[1,]    3    3
[2,]   -1    2

Usando o Teorema 4 3.2.1, obtemos a matriz de covariâncias condicionais de \(y_1\) e \(y_2\) dado \(y_3\) e \(y_4\):

\[cov(y \mid x) = \mathbf{\Sigma}_{yy} - \mathbf{\Sigma}_{yx} \mathbf{\Sigma}_{xx}^{-1} \mathbf{\Sigma}_{xy}\]

cov_ydx <- Sigma_yy - Sigma_yx %*% solve(Sigma_xx) %*% t(Sigma_yx)
cov_ydx
           [,1]       [,2]
[1,]  3.8181818 -0.7272727
[2,] -0.7272727  0.4242424

Note que \(\mathbf{\Sigma}\) é uma matriz simétrica, logo \(\mathbf{\Sigma}_{yx} = \mathbf{\Sigma}'_{xy} \iff \mathbf{\Sigma}_{xy} = \mathbf{\Sigma}'_{yx}\).

Assim, podemos calcular o coeficiente de correlação parcial \(\rho_{12.34}\):

D <- sqrt(diag(cov_ydx))
D
[1] 1.9540168 0.6513389
Ro_ydx <- solve(diag(D)) %*% cov_ydx %*% solve(diag(D))
Ro_ydx
           [,1]       [,2]
[1,]  1.0000000 -0.5714286
[2,] -0.5714286  1.0000000

Portanto, conhecendo os valores de \(y_3\) e \(y_4\), a correlação parcial entre \(y_1\) e \(y_2\) é negativa (\(\rho_{12.34} = -0,571\)) e diferente da correlação linear simples (\(\rho_{12} = 0\)).

Ro_yy
     [,1] [,2]
[1,]    1    0
[2,]    0    1
Ro_ydx
           [,1]       [,2]
[1,]  1.0000000 -0.5714286
[2,] -0.5714286  1.0000000
Ay = {1 0 0 0, 0 1 0 0};
Sigma_yy = Ay*Sigma*t(Ay);
Dyy = sqrt(diag(Sigma_yy));
Ro_yy = inv(Dyy)*Sigma_yy*inv(Dyy);

Ax = {0 0 1 0, 0 0 0 1};
Sigma_xx = Ax*Sigma*t(Ax);

Sigma_yx = Ay*Sigma*t(Ax);

cov_ydx = Sigma_yy-Sigma_yx*inv(Sigma_xx)*t(Sigma_yx);
D = sqrt(diag(cov_ydx));
Ro_ydx = inv(D)*cov_ydx*inv(D);

print Ro_yy[format=8.2] '    ' Ro_ydx[format=8.3];