Study and Productivity

Principal Component Analysis Step by Step, Without Code

What PCA does, when to standardise, how many components to keep, and how to read loadings, scores and a biplot, with the USArrests data as an example.

Saizul Amin
Saizul Amin19 Nov 2026 · 4 min read
Principal Component Analysis Step by Step, Without Code

Principal component analysis, usually shortened to PCA, is one of the first techniques people meet when a spreadsheet has too many related columns to look at sensibly. It is used in psychology questionnaires, chemistry spectra, finance, ecology and quality control. This article explains what it does in plain terms and how to run and read one with the free PCA Calculator, which works in your browser without any code.

The idea in one paragraph

Imagine a cloud of points in several dimensions, one dimension per variable. PCA rotates the axes so that the first new axis points along the direction in which the cloud is most stretched, the second along the next most stretched direction at right angles to the first, and so on. Each new axis is a principal component, a weighted sum of the original variables. Because the components are uncorrelated and ordered by variance, the first two or three often capture most of what is going on.

Step 1: decide whether to standardise

If your variables are in different units, such as kilograms, years and pounds, the one with the biggest numbers will dominate the analysis simply because its variance is largest. Standardising each column to mean zero and standard deviation one removes that effect. This is called PCA on the correlation matrix and is the safe default.

If every column is in the same unit and the raw spread matters, for example absorbance at several wavelengths, you can work on the covariance matrix instead. The difference can be dramatic: on the USArrests data, the covariance version is almost entirely about assaults, because assault counts are in the hundreds while the other variables are in single or double figures.

Step 2: look at the eigenvalues

The calculator forms the correlation or covariance matrix and finds its eigenvalues and eigenvectors. Each eigenvalue is the variance of one component, and together they add up to the total variance. With standardised data that total equals the number of variables, so an eigenvalue above 1 means the component carries more than one variable's worth of information.

For USArrests, the four eigenvalues are 2.4802, 0.9898, 0.3566 and 0.1734. The first component explains 62.0% of the variance, and the first two together 86.75%. These are the same values R reports with prcomp and the scale option switched on.

Step 3: choose how many components to keep

There is no single correct rule, so the tool shows three. Kaiser's rule keeps components with eigenvalues above 1. The broken-stick rule keeps components that explain more than they would if the variance were split at random. A cumulative target keeps as many as needed to reach, say, 80%. On USArrests, Kaiser keeps one component, the broken stick keeps one, and 80% needs two.

The scree plot draws the eigenvalues in order. Look for the elbow where the line flattens: components after it are mostly noise. In practice many analysts keep the components that pass these checks and that can be interpreted.

Step 4: interpret the loadings

Each component is defined by its coefficients, one per variable. Large coefficients, positive or negative, show which variables drive the component. In USArrests the first component has similar weights on murder, assault and rape and a smaller one on urban population, so it reads as an overall crime level. The second component is dominated by urban population, so it separates urban from rural states.

The tool also gives loadings scaled by the square root of the eigenvalue. With standardised data these are correlations between each variable and each component, which are easier to explain to a non-specialist. Contribution percentages and cos² values show how much each variable adds to a component and how well the component represents it.

Do not worry if your signs are the opposite of another program's. A component and its negative describe the same axis. The calculator makes the largest coefficient positive and lets you flip any component.

Step 5: plot the scores

A score is where each row lands on a component. The biplot shows the scores of two components as points and the variables as arrows. Points far along an arrow are high on that variable, and arrows pointing the same way represent correlated variables. In USArrests, Florida sits far out along the crime direction, with a first component score of about 2.98.

Things to watch

PCA is sensitive to outliers, because a single extreme row can pull a component towards itself. Check the biplot for points far from the rest before you interpret the loadings. PCA also assumes that straight-line relationships are what matter, and it is not the same as factor analysis, which models measurement error and often rotates its factors.

Missing values need care. The calculator drops any row with a gap and tells you which ones; if many rows go, consider why the data are missing before carrying on.

Taking the results further

You can download the scores, loadings and eigenvalues as CSV files and use the scores in a regression or a cluster analysis, or print a report with the tables and plots for an assignment. Because everything runs in the browser, your data never leaves your computer.

Completely freeNo cost, no sign-up
Files stay privateEverything runs in your browser
Easy in your languageAvailable in many languages