statsmodels.multivariate.pca.pca

statsmodels.multivariate.pca.pca(data, ncomp=None, standardize=True, demean=True, normalize=True, gls=False, weights=None, method='svd')[source]

Principal Component Analysis

Parameters
dataarray

Variables in columns, observations in rows.

ncompint, optional

Number of components to return. If None, returns the as many as the smaller to the number of rows or columns of data.

standardize: bool, optional

Flag indicating to use standardized data with mean 0 and unit variance. standardized being True implies demean.

demeanbool, optional

Flag indicating whether to demean data before computing principal components. demean is ignored if standardize is True.

normalizebool , optional

Indicates whether th normalize the factors to have unit inner product. If False, the loadings will have unit inner product.

weightsarray, optional

Series weights to use after transforming data according to standardize or demean when computing the principal components.

glsbool, optional

Flag indicating to implement a two-step GLS estimator where in the first step principal components are used to estimate residuals, and then the inverse residual variance is used as a set of weights to estimate the final principal components

methodstr, optional

Determines the linear algebra routine uses. ‘eig’, the default, uses an eigenvalue decomposition. ‘svd’ uses a singular value decomposition.

Returns
factorsarray or DataFrame

nobs by ncomp array of of principal components (also known as scores)

loadingsarray or DataFrame

ncomp by nvar array of principal component loadings for constructing the factors

projectionarray or DataFrame

nobs by var array containing the projection of the data onto the ncomp estimated factors

rsquarearray or Series

ncomp array where the element in the ith position is the R-square of including the fist i principal components. The values are calculated on the transformed data, not the original data.

icarray or DataFrame

ncomp by 3 array containing the Bai and Ng (2003) Information criteria. Each column is a different criteria, and each row represents the number of included factors.

eigenvalsarray or Series

nvar array of eigenvalues

eigenvecsarray or DataFrame

nvar by nvar array of eigenvectors

Notes

This is a simple function wrapper around the PCA class. See PCA for more information and additional methods.