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.
using System;
using PartialCovariances = Imsl.Stat.PartialCovariances;
using PrintMatrix = Imsl.Math.PrintMatrix;
using PrintMatrixFormat = Imsl.Math.PrintMatrixFormat;

public class PartialCovariancesEx1
{

   static public void Main(String[] arg)
   {
      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;
      int df = 30;

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

      double[,] covar = pcov.GetPartialCovarianceMatrix();
      PrintMatrixFormat pmf = new PrintMatrixFormat();
      pmf.NumberFormat = "0.0000";
      new PrintMatrix("Partial Covariances").Print(pmf,covar);

      int pdf = pcov.PartialDegreesOfFreedom;
      Console.Out.WriteLine("Partial Degrees of Freedom " + pdf);
      Console.Out.WriteLine();

      double[,] pvalues = pcov.GetPValues();
      new PrintMatrix("p Values").Print(pmf,pvalues);
   }
}

Output

                Partial Covariances
     0       1       2       3       4       5     
0  0.0000  0.0000  0.0000  0.0000  0.0000  0.0000  
1  0.0000  0.0000  0.0000  0.0000  0.0000  0.0000  
2  0.0000  0.0000  0.0000  0.0000  0.0000  0.0000  
3  0.0000  0.0000  0.0000  5.4953  1.8955  3.0836  
4  0.0000  0.0000  0.0000  1.8955  1.8407  1.4764  
5  0.0000  0.0000  0.0000  3.0836  1.4764  3.4026  

Partial Degrees of Freedom 27

                     p Values
     0       1       2       3       4       5     
0  0.0000  0.0000  0.0000  0.0000  0.0000  0.0000  
1  0.0000  0.0000  0.0000  0.0000  0.0000  0.0000  
2  0.0000  0.0000  0.0000  0.0000  0.0000  0.0000  
3  0.0000  0.0000  0.0000  0.0000  0.0008  0.0000  
4  0.0000  0.0000  0.0000  0.0008  0.0000  0.0009  
5  0.0000  0.0000  0.0000  0.0000  0.0009  0.0000  


Link to C# source.