Example 1

This example computes partial covariances, scaled from a nine-variable correlation matrix originally given by Emmett (1949). The first three rows and columns contain the independent variables and the final six rows and columns contain the dependent variables.

import com.imsl.stat.PartialCovariances;
import com.imsl.math.PrintMatrix;

public class PartialCovariancesEx1 {

    static public void main(String arg[]) throws Exception {
        double sigma[][] = {
            {6.300, 3.050, 1.933, 3.365, 1.317, 2.293, 2.586, 1.242, 4.363},
            {3.050, 5.400, 2.170, 3.346, 1.473, 2.303, 2.274, 0.750, 4.077},
            {1.933, 2.170, 3.800, 1.970, 0.798, 1.062, 1.576, 0.487, 2.673},
            {3.365, 3.346, 1.970, 8.100, 2.983, 4.828, 2.255, 0.925, 3.910},
            {1.317, 1.473, 0.798, 2.983, 2.300, 2.209, 1.039, 0.258, 1.687},
            {2.293, 2.303, 1.062, 4.828, 2.209, 4.600, 1.427, 0.768, 2.754},
            {2.586, 2.274, 1.576, 2.255, 1.039, 1.427, 3.200, 0.785, 3.309},
            {1.242, 0.750, 0.487, 0.925, 0.258, 0.768, 0.785, 1.300, 1.458},
            {4.363, 4.077, 2.673, 3.910, 1.687, 2.754, 3.309, 1.458, 7.400}
        };
        int nIndependent = 3, df = 30;

        PartialCovariances pcov
                = new PartialCovariances(nIndependent, sigma, df);

        double covar[][] = pcov.getPartialCovarianceMatrix();
        new PrintMatrix("Partial Covariances").print(covar);

        int pdf = pcov.getPartialDegreesOfFreedom();
        System.out.println("Partial Degrees of Freedom " + pdf);
        System.out.println();

        double pvalues[][] = pcov.getPValues();
        new PrintMatrix("p Values").print(pvalues);
    }
}

Output

        Partial Covariances
   0   1  2    3       4      5    
0   0  0  0  -0      0      0      
1   0  0  0   0      0      0      
2   0  0  0   0      0      0      
3  -0  0  0   5.495  1.895  3.084  
4   0  0  0   1.895  1.841  1.476  
5   0  0  0   3.084  1.476  3.403  

Partial Degrees of Freedom 27

            p Values
   0  1  2    3      4      5    
0  0  0  0  0      0      0      
1  0  0  0  0      0      0      
2  0  0  0  0      0      0      
3  0  0  0  0      0.001  0      
4  0  0  0  0.001  0      0.001  
5  0  0  0  0      0.001  0      

Link to Java source.