Definition (sample conditional variance, sample partial correlation)

Let $(W_i, Z_i)_{i=1}^n$ be iid copies of $(W, Z)$, with $W\in \R^m, Z \in \R^n$. Form the matrices $\mathbf{W} = \pmat{W_1^T \\ \vdots \\ W_n^T}, \mathbf{Z} = \pmat{Z_1^T \\ \vdots \\Z_n^T}$.

The sample conditional variance of $W$ given $Z$ is $$ \begin{align*} \hat Ω = \frac{1}{n}((I - P) \mathbf{W})^T ((I - P) \mathbf{W}) = \frac{1}{n}\mathbf{W}^T (I-P) \mathbf{W} \end{align*} $$ where $P$ is the projection matrix onto the columns space of $\pmat{\v 1 & \mathbf{Z}}$.

The sample partial correlation of $W^{(j)}$ and $W^{(k)}$ given $Z$ is $$ \begin{align*} \hat ρ_{W^{(j)}, W^{(k)}\mid Z} = \frac{\hat Ω_{jk}}{\sqrt{\hat Ω_{jj} \hat Ω_{kk}}} = \frac{((I - P)\mathbf{W}^{(j)})^T ((I-P) \mathbf{W}^{(k)})}{\|(I-P)\mathbf{W}^{(j)}\| \|(I - P) \mathbf{W}^{(k)}\|}. \end{align*} $$

If $(W,Z)$ is jointly Gaussian, then $\hat Ω$ is the maximum likelihood estimator of $\var(W\mid Z)$ and $\hat ρ_{W^{(j)}, W^{(k)}\mid Z}$ is the maximum likelihood estimator of $ρ_{W^{(j)},W^{(k)}\mid Z}$. (Proof)