package com.imsl.test.example.stat;
import java.text.*;
import com.imsl.stat.*;
import com.imsl.math.*;
/**
*
Computes the principal components on a 9 variable correlation matrix.
* This example illustrates the use of the FactorAnalysis
* class for a nine-variable matrix. The following data were originally analyzed
* by Emmett(1949). There are \(211\) observations on \(9\) variables.
* The PRINCIPAL_COMPONENT_MODEL
* is selected and the input matrix type selected is a CORRELATION_MATRIX
.
*
*
*
* @see Code
* @see Output
*/
public class FactorAnalysisEx1 {
public static void main(String args[]) throws Exception {
double[][] corr = {
{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 pc = new FactorAnalysis(corr,
FactorAnalysis.CORRELATION_MATRIX, 9);
pc.setFactorLoadingEstimationMethod(
FactorAnalysis.PRINCIPAL_COMPONENT_MODEL);
pc.setDegreesOfFreedom(100);
NumberFormat nf = NumberFormat.getInstance();
nf.setMinimumFractionDigits(4);
PrintMatrixFormat pmf = new PrintMatrixFormat();
pmf.setNumberFormat(nf);
new PrintMatrix("Eigenvalues").print(pmf, pc.getValues());
new PrintMatrix("Percents").print(pmf, pc.getPercents());
new PrintMatrix("Standard Errors").print(pmf, pc.getStandardErrors());
new PrintMatrix("Eigenvectors").print(pmf, pc.getVectors());
new PrintMatrix("Unrotated Factor Loadings").print(pmf,
pc.getFactorLoadings());
}
}