Logo

statsmodels.sandbox.tools.tools_pca.pca

statsmodels.sandbox.tools.tools_pca.pca(data, keepdim=0, normalize=0, demean=True)[source]

principal components with eigenvector decomposition similar to princomp in matlab

Parameters:

data : ndarray, 2d

data with observations by rows and variables in columns

keepdim : integer

number of eigenvectors to keep if keepdim is zero, then all eigenvectors are included

normalize : boolean

if true, then eigenvectors are normalized by sqrt of eigenvalues

demean : boolean

if true, then the column mean is subtracted from the data

Returns:

xreduced : ndarray, 2d, (nobs, nvars)

projection of the data x on the kept eigenvectors

factors : ndarray, 2d, (nobs, nfactors)

factor matrix, given by np.dot(x, evecs)

evals : ndarray, 2d, (nobs, nfactors)

eigenvalues

evecs : ndarray, 2d, (nobs, nfactors)

eigenvectors, normalized if normalize is true

See also

pcasvd
principal component analysis using svd

Previous topic

statsmodels.sandbox.sysreg.Sem2SLS.whiten

Next topic

statsmodels.sandbox.tools.tools_pca.pcasvd

This Page