Principal Component Analysis: PCA Calculator

Run PCA on pasted data: eigenvalues, explained variance, eigenvectors and loadings, scores, a scree plot with parallel analysis, and a biplot whose scaling convention is stated on the plot.

At a glance

Computes
Eigenvalues, vectors, loadings, scores, retention rules, a scree plot, and a biplot.
You supply
A numeric table, basis, missing-data choice, retained components, and plot convention.
Use when
You want fewer directions that preserve the main variation across numeric variables.
Not for
Learning what a principal component is before running one on data. Eigenvectors and PCA

Runs in your browser. Pasted data is never uploaded.

Paste a table and this page runs the decomposition: eigenvalues with their variance shares, the component vectors, the loadings, the scores, a scree plot with the retention rules applied to it, and a biplot drawn at equal aspect so the angles between the arrows mean what they appear to mean. Every convention it used is named on the page, because the sign of a component is arbitrary, the correlation basis and the covariance basis answer different questions, and three different scalings are all called the biplot. For what a principal component actually is, and why the directions come out where they do, the eigenvector explainer teaches it with four interactive figures and no data entry at all.

Tabs, commas, semicolons and pipes all work. Non-numeric columns are kept for labels and left out of the decomposition.

If the job is to parse the file and summarize each column, CSV/JSON column stats is the shorter route.

Load a sample
Variables
Basis
Missing data
Score scaling
1

Drag the cutoff on the scree plot or use this slider. Both drive the same value.

Results

The published USArrests example below is complete without JavaScript.

Observations
50 observations
Variables
4
Components
4
Retained variance
62.0%
Eigenvalues and explained variance
ComponentEigenvaluePercentCumulative percent
PC12.48024262.0%62.0%
PC20.98976524.7%86.8%
PC30.3565638.9%95.7%
PC40.1734304.3%100.0%

Eigenvalue by component, with cumulative variance

0.00.51.01.52.02.5Glorfeld p95, 1000 replicatesEigenvalue1234Cumulative variance00.250.500.751Kaiser criterion
Component retention
RuleComponents retainedWhat it assumes
Parallel analysis, Glorfeld p9511000 same-shape independent-normal samples
Kaiser1Eigenvalue above 1; correlation basis only
Cumulative variance2 / 3 / 380% / 90% / 95% targets
Broken stick1Leading shares above a randomly broken unit stick
Eigenvectors and loadings
VariablePC1 eigenvectorPC1 loading
Murder0.53589950.8439764
Assault0.58318360.9184432
UrbanPop0.27819090.4381168
Rape0.54343210.8558394
Loadings by magnitude
VariablePC1 loading
Murder0.8439764
Assault0.9184432
UrbanPop0.4381168
Rape0.8558394

Why the sign is arbitrary

Correlation biplot (column-metric preserving); PC1 62.0% and PC2 24.7% of variance

−101−2−101MurderAssaultUrbanPopRape

PC2 score against PC1 score

−2−101−3−2−10123
50 point labels are listed in the table below rather than on the plot.
Scores
LabelPC1
Alabama0.975660
Alaska1.930538
Arizona1.745443
Arkansas-0.139999
California2.498613
Colorado1.499341
Connecticut-1.344992
Delaware0.047230
Florida2.982760
Georgia1.622807
Hawaii-0.903484
Idaho-1.623319
Illinois1.365052
Indiana-0.500381
Iowa-2.230996
Kansas-0.788872
Kentucky-0.743313
Louisiana1.549091
Maine-2.372740
Maryland1.745647
Massachusetts-0.481280
Michigan2.087250
Minnesota-1.675670
Mississippi0.986479
Missouri0.689784
Montana-1.173538
Nebraska-1.252916
Nevada2.845505
New Hampshire-2.359956
New Jersey0.179741
New Mexico1.960124
New York1.665667
North Carolina1.112088
North Dakota-2.962152
Ohio-0.223694
Oklahoma-0.308649
Oregon0.058528
Pennsylvania-0.879487
Rhode Island-0.855091
South Carolina1.307450
South Dakota-1.967797
Tennessee0.989694
Texas1.341518
Utah-0.545032
Vermont-2.773256
Virginia-0.095367
Washington-0.214723
West Virginia-2.087393
Wisconsin-2.058812
Wyoming-0.623101

Diagnostics

No near-tied adjacent eigenvalues. No rows dropped; no cells imputed.

See a near tie happen

Export

Correlation basis or covariance basis

The two bases answer different questions. See both bases on one dataset.

PCA on the correlation basis is the eigendecomposition of the matrix that the correlation coefficient calculator computes one pair at a time. For two columns, use that calculator, and for one column at a time use descriptive statistics. PCA only says something once the columns are read together.

Vertical distance or perpendicular distance

Regression asks a directional question and minimizes vertical distance to the line. PCA asks a symmetric one and minimizes perpendicular distance. The two lines differ even on the same two columns.

Eigenvectors and loadings are two different columns

An eigenvector is a unit direction. A loading multiplies that direction by the square root of its eigenvalue.

The sign of a component is arbitrary

Flipping one component changes neither its eigenvalue nor the geometry.

How many components to keep

Parallel analysis compares each observed eigenvalue with a same-shape random-data band. Kaiser, cumulative variance and broken stick are shown as alternative rules.

Reading the biplot

The equal-aspect frame preserves the angles between arrows. Under correlation scaling, arrow inner products approximate correlations.

Fewer observations than variables

Centering leaves at most min(n - 1, p) components.

Reproduce this in R and in Python

fit <- prcomp(X, center = TRUE, scale. = TRUE)
fit = PCA().fit(Z)

Assumptions, limits, and privacy

PCA describes variance structure. It does not identify causes. Recalculation happens in your browser and requires JavaScript.

Sources

  1. Jolliffe and Cadima (2016), Principal component analysis: a review and recent developments. Philosophical Transactions of the Royal Society A. Retrieved .
  2. Horn (1965), A rationale and test for the number of factors in factor analysis. Psychometrika. Retrieved .
  3. Glorfeld (1995), An improvement on Horn's parallel analysis methodology. Educational and Psychological Measurement. Retrieved .
  4. McNeil (1977), Interactive Data Analysis: USArrests source record. Wiley. Retrieved .
  5. Fisher (1936), The use of multiple measurements in taxonomic problems. Annals of Eugenics; measurements collected by Anderson. Retrieved .
  6. UK food-consumption teaching table provenance note. Setosa lineage; widely republished teaching table, primary source unestablished. Retrieved .