Main Content

pcacov

Principal component analysis on covariance matrix

Description

coeff = pcacov(V) performs principal component analysis on the square covariance matrix V and returns the principal component coefficients, also known as loadings.

pcacov does not standardize V to have unit variances. To perform principal component analysis on standardized variables, use the correlation matrix R = V./(SD*SD'), where SD = sqrt(diag(V)), in place of V. To perform principal component analysis directly on the data matrix, use pca.

example

[coeff,latent] = pcacov(V) also returns a vector containing the principal component variances, meaning the eigenvalues of V.

example

[coeff,latent,explained] = pcacov(V) also returns a vector containing the percentage of the total variance explained by each principal component.

example

Examples

collapse all

Create a covariance matrix from the hald dataset.

load hald
covx = cov(ingredients);

Perform principal component analysis on the covx variable.

[coeff,latent,explained] = pcacov(covx)
coeff = 4×4

   -0.0678   -0.6460    0.5673    0.5062
   -0.6785   -0.0200   -0.5440    0.4933
    0.0290    0.7553    0.4036    0.5156
    0.7309   -0.1085   -0.4684    0.4844

latent = 4×1

  517.7969
   67.4964
   12.4054
    0.2372

explained = 4×1

   86.5974
   11.2882
    2.0747
    0.0397

The first component explains over 85% of the total variance. The first two components explain nearly 98% of the total variance.

Input Arguments

collapse all

Covariance matrix, specified as a square, symmetric, positive semidefinite matrix.

Data Types: single | double

Output Arguments

collapse all

Principal component coefficients, returned as a matrix the same size as V. Each column of coeff contains coefficients for one principal component. The columns are in order of decreasing component variance.

Principal component variances, returned as a vector with length equal to size(coeff,1). The vector latent contains the eigenvalues of V.

Percentage of the total variance explained by each principal component, returned as a vector the same size as latent. The entries in explained range from 0 (none of the variance is explained) to 100 (all of the variance is explained).

References

[1] Jackson, J. E. A User's Guide to Principal Components. Hoboken, NJ: John Wiley and Sons, 1991.

[2] Jolliffe, I. T. Principal Component Analysis. 2nd ed. New York: Springer-Verlag, 2002.

[3] Krzanowski, W. J. Principles of Multivariate Analysis: A User's Perspective. New York: Oxford University Press, 1988.

[4] Seber, G. A. F. Multivariate Observations, Wiley, 1984.

Extended Capabilities

Version History

Introduced before R2006a

Go to top of page

Help us improve MathWorks products


Are you currently using (or are interested in using) Design of Experiments (DOE) methods?
Yes
No