About PCA on Two Variables
This page runs standardised PCA on two variables, the smallest case, where the whole analysis fits in a 2 by 2 matrix. It is free, needs no sign-up and runs in your browser, so nothing you enter is uploaded.
For two standardised variables the correlation matrix has ones on the diagonal and the correlation r off it. Its eigenvalues are 1 + r and 1 - r, and its eigenvectors are always the diagonals (1, 1) and (1, -1) scaled to length 1, whatever r is. So the first component is the average of the two variables and the second is their difference.
The ten-point example has a correlation of about 0.93, so the first component explains about 96.3% of the variance. If the correlation were 0, both components would explain half and the data would show no preferred direction.
How to use PCA on Two Variables
- Pick a sample dataset, or paste your own CSV with a header row and at least two numeric columns.
- Decide on standardising. Turn it on when the columns are in different units, off when they share one.
- Read the variance explained by PC1 and the scree chart to see how many components matter.
- Choose which two components to plot, if you have more than two, and look at the projection.
- Open the covariance matrix, eigenvector and loading tables to see how each variable contributes to each component.
- Copy the component scores to use in a spreadsheet or another tool.
Features
- Covariance matrix, or correlation matrix when columns are standardised.
- Eigenvalues and eigenvectors by the Jacobi rotation method, sorted from largest to smallest.
- Explained and cumulative variance as a chart and a table.
- A projection scatter on any two components, coloured by a text column when one is present.
- Eigenvector and loading tables, with a stable sign convention.
- Component scores for every row, copyable as tab-separated text.
- Up to 5,000 rows and 30 numeric columns, with iris, a two-variable example and a marks table built in.
Worked examples
Ten points of x and y, standardised gives eigenvalues 1.9259 and 0.0741
These are 1 + r and 1 - r, so r = 0.9259. PC1 explains 96.3%.
Privacy: how it works
- Your table is parsed and analysed in your browser tab. Nothing is sent to Ulkaa or anyone else.
Tips
- A common rule of thumb is to keep enough components to explain 90 to 95% of the variance. The note under the result card tells you how many that is.
- Look for an elbow in the scree chart: components after it add little.
- Large loadings of the same sign mean the variables move together on that component; opposite signs mean a contrast between them.
- Remove ID columns and anything that is not a measurement before running PCA.
Frequently asked questions
Is it really free?
Yes. There is no price, no trial and no credit card. Ulkaa Tool does the work with your own device, so there is no server bill to pass on to you.
Do I need an account?
No. There is no sign-up and no login. Open the page and use it. An Ulkaa account is not needed for anything on this tool.
Does it run in my browser?
Yes. Your table are processed by code running in your browser tab, on your own device.
Is my data uploaded?
No. Your table are never sent to Ulkaa or to anyone else. You can check this yourself by watching the Network tab in your browser developer tools while you use the tool.
What are the eigenvalues of a 2 by 2 correlation matrix?
1 plus r and 1 minus r, where r is the correlation between the two variables.
Why is the first component the average of the two variables?
For equal variances the direction of greatest spread is along the diagonal, which weights both variables equally when r is positive.
More PCA Visualizer pages
- PCA VisualizerPaste numeric columns and see the covariance matrix, eigenvectors, explained variance and a 2D projection.
- PCA Covariance Matrix CalculatorSee the covariance matrix that PCA starts from, with its eigenvalues and eigenvector.
- Eigenvalue and Eigenvector Calculator for PCAGet the eigenvalues and unit eigenvectors of the covariance matrix of your data.
- PCA Explained Variance CalculatorSee how much variance each principal component explains, and how many you need.
- PCA With StandardizationRun PCA on standardised columns, so every variable has the same weight.
- PCA: PC2 vs PC3 PlotChoose any two components for the scatter, here the second and third.