package com.imsl.test.example.stat; import com.imsl.stat.PartialCovariances; import com.imsl.math.PrintMatrix; /** *
* Computes partial covariances after adjusting for specific variables.
* * This example computes partial correlations from a 9 variable correlation * matrix originally given by Emmett (1949). The partial correlations between * the remaining variables, after adjusting for variables 1, 3 and 9, are * computed. Note in the output that the row and column labels are numbers, not * variable numbers. The corresponding variable numbers would be 2, 4, 5, 6, 7 * and 8, respectively. * * @see Code * @see Output */ public class PartialCovariancesEx2 { static public void main(String arg[]) throws Exception { double sigma[][] = { {1.000, 0.523, 0.395, 0.471, 0.346, 0.426, 0.576, 0.434, 0.639}, {0.523, 1.000, 0.479, 0.506, 0.418, 0.462, 0.547, 0.283, 0.645}, {0.395, 0.479, 1.000, 0.355, 0.270, 0.254, 0.452, 0.219, 0.504}, {0.471, 0.506, 0.355, 1.000, 0.691, 0.791, 0.443, 0.285, 0.505}, {0.346, 0.418, 0.270, 0.691, 1.000, 0.679, 0.383, 0.149, 0.409}, {0.426, 0.462, 0.254, 0.791, 0.679, 1.000, 0.372, 0.314, 0.472}, {0.576, 0.547, 0.452, 0.443, 0.383, 0.372, 1.000, 0.385, 0.680}, {0.434, 0.283, 0.219, 0.285, 0.149, 0.314, 0.385, 1.000, 0.470}, {0.639, 0.645, 0.504, 0.505, 0.409, 0.472, 0.680, 0.470, 1.000} }; int xIndices[] = {1, 0, 1, 0, 0, 0, 0, 0, 1}; int df = 30; PartialCovariances pcov = new PartialCovariances(xIndices, sigma, df); double correl[][] = pcov.getPartialCorrelationMatrix(); new PrintMatrix("Partial Correlations").print(correl); double pValues[][] = pcov.getPValues(); new PrintMatrix("P-Values").print(pValues); } }