How to use the pca calculator
- Paste a table with one case per line and 2 to 8 numeric columns. Tick the box if the first line holds column names.
- Choose the correlation matrix when columns use different units or scales, or the covariance matrix to keep original units.
- Read the variance share of the first two components, the full table of eigenvalues and the loadings.
- Use the scores for the first cases, or download all scores as CSV for a scatter plot of PC1 against PC2.
Formula
Z = centered data (each column also divided by its standard deviation for the correlation version)
C = Z' Z / (n - 1), a p x p symmetric matrix
C v = lambda v (eigenvalues lambda, unit eigenvectors v, found with Jacobi rotations)
Variance explained by component j = lambda_j / sum of all lambda
Score of a case on component j = its row of Z multiplied by v_j
The eigenvalues add up to the trace of C: p for the correlation matrix, or the sum of the column variances for the covariance matrix. Each component is signed so its largest loading is positive.
Ten cases and three measurements
The default table has columns Size, Weight and Age for 10 cases. On the correlation matrix the eigenvalues are 2.8347, 0.1081 and 0.0572, which add up to 3. The components explain 94.49%, 3.60% and 1.91% of the variance.
PC1 loads 0.5739 on Size, 0.5825 on Weight and -0.5756 on Age, so it contrasts big, heavy cases with older ones. The first case scores 1.3502 on PC1 and 0.0204 on PC2. On the covariance matrix the first component explains 94.75%, and the first two together 98.06%.
What the components are
Principal component analysis rotates the data to new axes that are uncorrelated and ordered by how much variation they carry. The first component is the direction along which the cases are most spread out, the second is the most spread out direction at right angles to the first, and so on. Often the first two components hold most of the variation, and a scatter plot of their scores shows the structure of a many-column table in two dimensions.
The loadings tell you how the original columns combine into each component. Large loadings of the same sign mean the columns move together along that axis, and opposite signs mean they trade off.
Correlation or covariance
With columns in different units, such as height in centimeters and income in dollars, the covariance version lets the column with the biggest numbers dominate. Standardizing first, which is what the correlation matrix does, gives each column an equal say. When all columns share a unit and size matters, the covariance version keeps that information.
For a straight-line relationship between two columns use the linear regression calculator, and for matrix arithmetic see the matrix calculator. The components describe the table you enter and do not show causes. Use the descriptive statistics page to inspect each column first.
Assumptions and limits
- The columns are numeric and measured for every case, with no blanks.
- Relationships between columns are roughly straight-line, which is what the correlation and covariance capture.
- A column with no variation is not allowed in the correlation version, because it cannot be standardized.
- Signs of components are arbitrary; here the largest loading is made positive so results are reproducible.
Frequently asked questions
How many components should I keep?
There is no single rule. People look at where the cumulative share levels off, keep components with eigenvalues above the average, or keep as many as the purpose needs. This page reports the full table so you can decide.
Why do my results differ from a spreadsheet add-in?
Differences usually come from the matrix used (correlation or covariance), from dividing by n instead of n - 1, or from component signs. Eigenvalues and shares should agree when the same matrix and divisor are used.
Can a component be negative in variance?
No. Eigenvalues of a covariance or correlation matrix are never below zero. Tiny negative values that appear in some software are rounding noise, and this page shows them as zero.
Does it work with more than 8 columns?
The page is limited to 8 columns and 2,000 cases so the table, loadings and scores stay readable. For wider tables use a statistics package.