The function may be called by the names: g03aac or nag_mv_prin_comp.
Let be an data matrix of observations on variables and let the variance-covariance matrix of be . A vector of length is found such that:
is maximized subject to
The variable is known as the first principal component and gives the linear combination of the variables that gives the maximum variation. A second principal component, , is found such that:
is maximized subject to
This gives the linear combination of variables that is orthogonal to the first principal component that gives the maximum variation. Further principal components are derived in a similar way.
The vectors , are the eigenvectors of the matrix and associated with each eigenvector is the eigenvalue, . The value of gives the proportion of variation explained by the th principal component. Alternatively, the 's can be considered as the right singular vectors in a singular value decomposition with singular values of the data matrix centred about its mean and scaled by , . This latter approach is used in g03aac, with
where is a diagonal matrix with elements , is the matrix with columns and is an matrix with , which gives the principal component scores.
Principal component analysis is often used to reduce the dimension of a dataset, replacing a large number of correlated variables with a smaller number of orthogonal variables that still contain most of the information in the original dataset.
The choice of the number of dimensions required is usually based on the amount of variation accounted for by the leading principal components. If principal components are selected, then a test of the equality of the remaining eigenvalues is
which has, asymptotically, a distribution with degrees of freedom.
Equality of the remaining eigenvalues indicates that if any more principal components are to be considered then they all should be considered.
Instead of the variance-covariance matrix the correlation matrix, the sums of squares and cross-products matrix or a standardized sums of squares and cross-products matrix may be used. In the last case is replaced by for a diagonal matrix with positive elements. If the correlation matrix is used, the approximation for the statistic given above is not valid.
The principal component scores, , are the values of the principal component variables for the observations. These can be standardized so that the variance of these scores for each principal component is or equal to the corresponding eigenvalue.
Weights can be used with the analysis, in which case the matrix is first centred about the weighted means then each row is scaled by an amount , where is the weight for the th observation.
Chatfield C and Collins A J (1980) Introduction to Multivariate Analysis Chapman and Hall
Cooley W C and Lohnes P R (1971) Multivariate Data Analysis Wiley
Hammarling S (1985) The singular value decomposition in multivariate statistics SIGNUM Newsl.20(3) 2–25
Kendall M G and Stuart A (1979) The Advanced Theory of Statistics (3 Volumes) (4th Edition) Griffin
Morrison D F (1967) Multivariate Statistical Methods McGraw–Hill
1: – Nag_PrinCompMatInput
On entry: indicates for which type of matrix the principal component analysis is to be carried out.
It is for the correlation matrix.
It is for the standardized matrix, with standardizations given by s.
It is for the sums of squares and cross-products matrix.
It is for the variance-covariance matrix.
, , or .
2: – Nag_PrinCompScoresInput
On entry: specifies the type of principal component scores to be used.
The principal component scores are standardized so that , i.e., .
The principal component scores are unstandardized, i.e., .
The principal component scores are standardized so that they have unit variance.
The principal component scores are standardized so that they have variance equal to the corresponding eigenvalue.
, , or .
3: – IntegerInput
On entry: the number of observations, .
4: – IntegerInput
On entry: the number of variables in the data matrix, .
5: – const doubleInput
On entry: must contain the th observation for the th variable, for and .
6: – IntegerInput
On entry: the stride separating matrix column elements in the array x.
7: – const IntegerInput
On entry: indicates whether or not the th variable is to be included in the analysis. If , then the variable contained in the th column of x is included in the principal component analysis, for .
An internal error has occurred in this function. Check the function call
and any array sizes. If the call is correct then please contact NAG for
On entry, .
Constraint: when referenced, all elements of wt must be non-negative.
With weighted data, the effective number of observations given by the sum of weights , while the number of variables included in the analysis, .
Constraint: effective number of observations .
The singular value decomposition has failed to converge. This is an unlikely error exit.
The number of variables, nvar in the analysis , while the number of variables included in the analysis via array .
Constraint: these two numbers must be the same.
On entry, the standardization element , while the variable to be included .
Constraint: when a variable is to be included, the standardization element must be positive.
All eigenvalues/singular values are zero. This will be caused by all the variables being constant.
As g03aac uses a singular value decomposition of the data matrix, it will be less affected by ill-conditioned problems than traditional methods using the eigenvalue decomposition of the variance-covariance matrix.
8Parallelism and Performance
g03aac is not threaded in any implementation.
A dataset is taken from Cooley and Lohnes (1971), it consists of ten observations on three variables. The unweighted principal components based on the variance-covariance matrix are computed and unstandardized principal component scores requested.