|
IDL Analyst Reference Guide: Multivariate Analysis |
|
The IMSL_PRINC_COMP function computes principal components.
| Note This routine requires an IDL Analyst license. For more information, contact your ITT Visual Information Solutions sales or technical support representative. |
Result = IMSL_PRINC_COMP(covariances [, /COV_MATRIX]
[, /CORR_MATRIX] [, CORRELATIONS=variable] [, CUM_PERCENT=variable] [, DF=variable] [, /DOUBLE] [, EIGENVECTORS=variable] [, STDEV=variable] )
One-dimensional array containing the eigenvalues of covariances ordered from largest to smallest.
Two-dimensional square matrix containing the covariance or correlation matrix.
If present and nonzero, treats the input matrix covariances as a covariance matrix. Keywords Cov_Matrix and Corr_Matrix cannot be used together. Default: Cov_Matrix = 1
If present and nonzero, treats the input matrix covariances as a correlation matrix.
Named variable into which the one-dimensional array of length containing the correlations of the principal components (the columns) with the observed/standardized variables (the rows) is stored. If Cov_Matrix is present and nonzero, the correlations are with the observed variables; otherwise, the correlations are with the standardized variables (to a variance of 1.0). In the principal component model for factor analysis, matrix Correlations is the matrix of unrotated factor loadings.
Named variable into which the one-dimensional array containing the cumulative percent of the total variances explained by each principal component is stored.
Named variable into which the number of degrees of freedom in covariances is stored. Keywords Df and Stdev must be used together.
If present and nonzero, double precision is used.
Named variable into which the two-dimensional array containing the eigenvectors of covariances, stored columnwise, is stored. Each vector is normalized to have Euclidean length equal to the value 1. Also, the sign of each vector is set so that the largest component in magnitude (the first of the largest if ties exist) is made positive.
Named variable into which the one-dimensional array containing the estimated asymptotic standard errors of the eigenvalues is stored. Keywords Df and Stdev must be used together.
The IMSL_PRINC_COMP function finds the principal components of a set of variables from a sample covariance or correlation matrix. The characteristic roots, characteristic vectors, standard errors for the characteristic roots, and the correlations of the principal component scores with the original variables are computed. Principal components obtained from correlation matrices are the same as principal components obtained from standardized variables (to unit variance).
The principal component scores are the elements of the vector y = GTx, where G is the matrix whose columns are the characteristic vectors (eigenvectors) of the sample covariance (or correlation) matrix and x is the vector of observed (or standardized) random variables. The variances of the principal component scores are the characteristic roots (eigenvalues) of the covariance (correlation) matrix.
Asymptotic variances for the characteristic roots were first obtained by Girschick (1939) and are given more recently by Kendall et al. (1983, p. 331). These variances are computed either for covariance matrices or for correlation matrices.
The correlations of the principal components with the observed (or standardized) variables are given in the matrix correlations. When the principal components are obtained from a correlation matrix, Correlations is the same as the matrix of unrotated factor loadings obtained for the principal components model for factor analysis.
In this example, principal components are computed for a nine-variable covariance matrix.
covariances = $ [[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]] values = IMSL_PRINC_COMP(covariances) PM, values, Title = 'Eigenvalues:' Eigenvalues: 4.67692 1.26397 0.844450 0.555027 0.447076 0.429125 0.310241 0.277006 0.196197
In this example, principal components are computed for a nine-variable correlation matrix. This example uses the same data as the first example.
values = IMSL_PRINC_COMP(covariances, /CORR_MATRIX, $ EIGENVECTORS = ev, $ STDEV = stdev, $ DF = 100, $ CUM_PERCENT = cp, $ CORRELATIONS = a) PM, [[values],[ev]], TITLE = 'Eigenvalue Eigenvector:', $ FORMAT = '(f7.2, 2x, 9f7.2)' Eigenvalue Eigenvector: 4.68 0.35 -0.24 0.14 -0.33 -0.11 0.80 0.17 -0.12 -0.05 1.26 0.35 -0.11 -0.28 -0.22 0.77 -0.20 0.14 -0.30 -0.01 0.84 0.28 -0.27 -0.56 0.69 -0.15 0.15 0.01 -0.04 -0.10 0.56 0.37 0.40 0.04 0.12 0.00 0.12 -0.40 -0.12 0.71 0.45 0.31 0.50 -0.07 -0.02 -0.28 -0.18 0.73 0.01 0.00 0.43 0.35 0.46 0.18 0.11 0.12 0.07 -0.37 0.09 -0.68 0.31 0.35 -0.27 -0.07 -0.35 -0.52 -0.44 -0.29 -0.34 -0.11 0.28 0.24 -0.32 0.74 0.43 0.09 -0.20 0.19 -0.16 0.05 0.20 0.38 -0.25 -0.01 -0.15 0.05 -0.15 -0.03 0.85 0.12 PM, a, Title = 'Matrix A:', FORMAT = '(9f7.2)' Matrix A: 0.75 -0.26 0.13 -0.25 -0.07 0.52 0.10 -0.07 -0.02 0.76 -0.12 -0.26 -0.16 0.51 -0.13 0.08 -0.16 -0.00 0.60 -0.30 -0.51 0.52 -0.10 0.10 0.01 -0.02 -0.04 0.79 0.45 0.04 0.09 0.00 0.08 -0.22 -0.06 0.31 0.68 0.56 -0.07 -0.02 -0.19 -0.12 0.41 0.00 0.00 0.75 0.51 0.17 0.08 0.08 0.05 -0.21 0.05 -0.30 0.75 -0.31 -0.07 -0.26 -0.35 -0.29 -0.16 -0.18 -0.05 0.52 -0.36 0.68 0.32 0.06 -0.13 0.10 -0.09 0.02 0.83 -0.28 -0.01 -0.11 0.03 -0.10 -0.01 0.45 0.05 PM, [[values], [stdev], [cp]], Title = 'Eigenvalue STD PCT', $ FORMAT = '(3(3x,F5.2))' Eigenvalue STD PCT 4.68 0.65 0.52 1.26 0.18 0.66 0.84 0.10 0.75 0.56 0.09 0.82 0.45 0.09 0.87 0.43 0.09 0.91 0.31 0.09 0.95 0.28 0.10 0.98 0.20 0.11 1.00
STAT_100_DF—Because the number of degrees of freedom in Covariances and Df is less than or equal to zero, 100 degrees of freedom will be used.
STAT_COV_NOT_NONNEG_DEF—Keyword Eigenvectors(#) = #. One or more eigenvalues much less than zero are computed. The matrix Covariances is not nonnegative definite. In order to continue computations of Eigenvectors and Correlations, these eigenvalues are treated as zero.
STAT_FAILED_TO_CONVERGE—Iteration for the eigenvalue failed to converge in 100 iterations before deflating.
IDL Online Help (March 06, 2007)