Great question! When performing the Fisher-Z conditional independence test repeatedly on different subsets of variables, you often need to invert submatrices of the correlation matrix. Directly inverting these submatrices repeatedly can be computationally expensive, especially if done naively.
Problem restatement:
- You have a correlation matrix ( R ) of size ( p \times p ).
- You want to test conditional independence between variables (X_i) and (X_j) given a conditioning set (S).
- This involves inverting the submatrix ( R_{[i,j,S],[i,j,S]} ).
- You do this many times for different (i, j, S).
Goal:
Speed up repeated inversions of submatrices of ( R ).
Key idea: Use the inverse of the full correlation matrix and Schur complements
1. Precompute the inverse of the full correlation matrix
If ( R ) is positive definite (which it should be for a correlation matrix), compute once:
[
R^{-1} = \Omega
]
This is the precision matrix.
2. Extract conditional covariances/partial correlations from the precision matrix
The Fisher-Z test for conditional independence between (X_i) and (X_j) given (S) can be done using the partial correlation:
[
\rho_{ij \mid S} = -\frac{\Omega_{ij}}{\sqrt{\Omega_{ii} \Omega_{jj}}}
]
where (\Omega = R^{-1}) is the precision matrix after conditioning on all other variables.
- If (S) is the full set of variables except (i,j), then (\rho_{ij \mid S}) is directly computed from (\Omega).
- But if (S) is a subset, you need the inverse of the submatrix (R_{[i,j,S],[i,j,S]}).
3. Using block matrix inversion / Schur complements for subsets
Suppose you want to invert a submatrix (R_{A,A}) where (A = {i,j} \cup S).
If you have the inverse of the full matrix (R^{-1}), you can use the Schur complement to get the inverse of submatrices efficiently.
Schur complement approach:
Partition the full matrix (R) as:
[
R = \begin{bmatrix}
R_{A,A} & R_{A,B} \
R_{B,A} & R_{B,B}
\end{bmatrix}
]
where (B) is the complement of (A).
Then the inverse of (R_{A,A}) can be expressed as:
[
R_{A,A}^{-1} = \left( R_{A,A} - R_{A,B} R_{B,B}^{-1} R_{B,A} \right)^{-1}
]
But this still requires inverting (R_{B,B}).
However, if you have (\Omega = R^{-1}), you can extract (R_{A,A}^{-1}) from (\Omega) by:
[
R_{A,A}^{-1} = \Omega_{A,A} - \Omega_{A,B} \Omega_{B,B}^{-1} \Omega_{B,A}
]
This is the inverse of the submatrix (R_{A,A}) expressed in terms of blocks of (\Omega).
4. Practical approach: Use the inverse of the full matrix and matrix inversion lemma
- Compute (\Omega = R^{-1}) once.
- For each subset (A), extract the relevant blocks (\Omega_{A,A}, \Omega_{A,B}, \Omega_{B,A}, \Omega_{B,B}).
- Compute (R_{A,A}^{-1}) using the formula above.
This avoids inverting (R_{A,A}) from scratch.
5. Alternative: Use the Woodbury matrix identity or matrix inversion lemma
If you are adding or removing a small number of variables from the conditioning set, you can update the inverse of the submatrix incrementally rather than recomputing it from scratch.
Summary of recommendations:
- Precompute the full inverse (R^{-1}) once.
- Use the block matrix inversion formula or Schur complements to get inverses of submatrices efficiently.
- If conditioning sets differ by only a few variables, use incremental updates (Woodbury identity).
- Alternatively, compute partial correlations directly from the precision matrix when conditioning on all other variables.
Additional notes:
- For large (p), computing the full inverse once is (O(p^3)), but then each submatrix inverse extraction is cheaper.
- If (p) is very large and conditioning sets are small, consider sparse matrix techniques or approximate methods.
- Numerical stability: ensure (R) is well-conditioned before inversion.
If you want, I can provide example code snippets in Python (NumPy/SciPy) to illustrate these ideas! Would you like that?