question: public static synchronized double partialCorrelation ( TetradMatrix submatrix ) { try { TetradMatrix inverse = submatrix . inverse ( ) ; double a = - 1.0 * inverse . get ( 0 , 1 ) ; double v0 = inverse . get ( 0 , 0 ) ; double v1 = inverse . get ( 1 , 1 ) ; double b = Math . sqrt ( v0 * v1 ) ; return a / b ; } catch ( Exception e ) { e . printStackTrace ( ) ; return Double . NaN ; } }
target:  Assumes that the given covariance matrix was extracted in such a way that the order of the variables (in either direction) is X, Y, Z1, ..., Zn, where the partial correlation one wants is correlation(X, Y | Z1,...,Zn). This may be extracted using DataUtils.submatrix().