package com.imsl.test.example.stat; import java.text.*; import com.imsl.stat.*; import com.imsl.math.*; /** *

Compute the factors on 9 variables by the method of maximum likelihood.

* *

This example illustrates the use of the FactorAnalysis class. * The following data were originally analyzed by Emmett(1949). There are \(211\) * observations on \(9\) variables. Following Lawley and Maxwell (1971), three * factors are obtained by the method of maximum likelihood.

* * @see Code * @see Output */ public class FactorAnalysisEx2 { public static void main(String args[]) throws Exception { double[][] cov = { {1.0, 0.523, 0.395, 0.471, 0.346, 0.426, 0.576, 0.434, 0.639}, {0.523, 1.0, 0.479, 0.506, 0.418, 0.462, 0.547, 0.283, 0.645}, {0.395, 0.479, 1.0, 0.355, 0.27, 0.254, 0.452, 0.219, 0.504}, {0.471, 0.506, 0.355, 1.0, 0.691, 0.791, 0.443, 0.285, 0.505}, {0.346, 0.418, 0.27, 0.691, 1.0, 0.679, 0.383, 0.149, 0.409}, {0.426, 0.462, 0.254, 0.791, 0.679, 1.0, 0.372, 0.314, 0.472}, {0.576, 0.547, 0.452, 0.443, 0.383, 0.372, 1.0, 0.385, 0.68}, {0.434, 0.283, 0.219, 0.285, 0.149, 0.314, 0.385, 1.0, 0.47}, {0.639, 0.645, 0.504, 0.505, 0.409, 0.472, 0.68, 0.47, 1.0} }; FactorAnalysis fl = new FactorAnalysis(cov, FactorAnalysis.VARIANCE_COVARIANCE_MATRIX, 3); fl.setConvergenceCriterion1(.000001); fl.setConvergenceCriterion2(.01); fl.setFactorLoadingEstimationMethod(FactorAnalysis.MAXIMUM_LIKELIHOOD); fl.setVarianceEstimationMethod(0); fl.setMaxStep(10); fl.setDegreesOfFreedom(210); NumberFormat nf = NumberFormat.getInstance(); nf.setMinimumFractionDigits(4); PrintMatrixFormat pmf = new PrintMatrixFormat(); pmf.setNumberFormat(nf); new PrintMatrix("Unique Error Variances").print(pmf, fl.getVariances()); new PrintMatrix("Unrotated Factor Loadings").print(pmf, fl.getFactorLoadings()); new PrintMatrix("Eigenvalues").print(pmf, fl.getValues()); new PrintMatrix("Statistics").print(pmf, fl.getStatistics()); } }