Principal Component Analysis (PCA) Calculator

Paste a table of numeric variables and get the principal components: means and standard deviations, the correlation or covariance matrix, eigenvalues with retention rules, loadings, a biplot and scores you can download.

Funziona nel tuo browser. I tuoi file non lasciano mai il dispositivo. Scopri come verificarlo

…

Come si usa

  1. 1
    Add your data

    Paste a table with a header row, import a CSV file, or load the USArrests example.

  2. 2
    Choose the scaling

    Pick the correlation matrix for mixed units or the covariance matrix for one shared unit.

  3. 3
    Decide what to keep

    Read the eigenvalues, the scree plot and the retention rules.

  4. 4
    Interpret

    Study the loadings and contributions, flipping signs if that reads more naturally.

  5. 5
    Plot

    Draw a biplot of any two components with or without row labels.

  6. 6
    Export

    Download scores, loadings and eigenvalues as CSV, or print the report.

Informazioni su questo strumento

Principal component analysis rewrites a set of correlated variables as a smaller set of new, uncorrelated variables called components. The first component is the direction in the data with the largest variance, the second is the largest remaining direction at right angles to the first, and so on. When variables move together, as test scores in related subjects or several measures of the same process often do, two or three components can carry most of the information in five or ten columns. This calculator takes a pasted or imported table with a header row and an optional label column, drops rows with missing values, and runs the whole analysis in your browser. You choose whether to standardise each variable first, which means working on the correlation matrix and is right when the columns are in different units, or only to centre them and work on the covariance matrix. The eigenvalues come from a Jacobi eigen-decomposition and are shown with their share of the total variance, a cumulative share, and three retention rules: Kaiser's eigenvalue-above-one rule, the broken-stick model and an 80% cumulative target. Loadings are given both as eigenvector coefficients and as correlations with the components, together with each variable's percentage contribution and cos² quality. A scree plot, a biplot of any two components and a table of scores for every row complete the output.

The steps behind the numbers

First each column is centred on its mean and, for correlation PCA, divided by its sample standard deviation. Next the matrix C = ZᵀZ ÷ (n − 1) is formed. Its eigenvalues are the variances of the components and add up to the trace, which equals the number of variables when the data are standardised. The unit eigenvectors are the coefficients, and each row's score on a component is the sum of its standardised values times those coefficients. The steps tab prints the means, standard deviations, the matrix and the score working for any row you pick, so the result can be copied into a report or checked by hand.

Worked example

The sample is R's USArrests data: murder, assault and rape arrests per 100,000 residents and the percentage urban population for the 50 US states in 1973. On the correlation matrix the eigenvalues are 2.4802, 0.9898, 0.3566 and 0.1734, so the standard deviations are 1.5749, 0.9949, 0.5971 and 0.4164, exactly as prcomp reports. PC1 explains 62.0% of the variance and PC1 and PC2 together 86.75%. Kaiser's rule keeps one component and two are needed to pass 80%. The PC1 coefficients are 0.536 for murder, 0.583 for assault, 0.278 for urban population and 0.543 for rape, so PC1 is an overall crime level; PC2 is dominated by urban population at 0.873. Alabama's standardised values are 1.2426, 0.7828, −0.5209 and −0.0034, which give a PC1 score of 0.976, while Florida scores 2.983.

Limits

PCA finds directions of variance, not causes, and it is not factor analysis: there is no rotation or error model. Results depend strongly on scaling, so use correlation PCA unless every column shares one unit. Signs of components are arbitrary, which is why R may print the same component with every sign flipped. Outliers can pull a component towards themselves, so look at the biplot before trusting the loadings.

Esempio svolto

USArrests, standardised: eigenvalues 2.4802, 0.9898, 0.3566, 0.1734; PC1 explains 62.0%, PC1 + PC2 86.75%.

In breve

Domande frequenti

Should I use the correlation or the covariance matrix?

Use the correlation matrix when the variables are measured in different units or on very different scales, as in USArrests where assault counts are in the hundreds. Use the covariance matrix only when all columns share one unit and their raw spread is meaningful.

How many components should I keep?

There is no single rule. The tool shows Kaiser's rule (eigenvalue above 1 for standardised data), the broken-stick model and the number needed for 80% of the variance. Combine them with the elbow in the scree plot and with whether the components make sense.

Why are my loadings the opposite sign to R or SPSS?

An eigenvector and its negative describe the same direction, so software picks a sign arbitrarily. This tool makes the largest coefficient of each component positive; press the ± button above a column to flip it and match another program.

What is the difference between coefficients and loadings?

Coefficients are the unit eigenvector entries used to compute scores. Loadings multiply them by the square root of the eigenvalue; with standardised data a loading is the correlation between the variable and the component.

What happens to missing values?

Any row with a blank or non-numeric value in a numeric column is left out, and the tool lists the rows it dropped. Columns that are mostly text are skipped as labels or categories.

Can I use the scores in another program?

Yes. Download the scores, loadings and eigenvalues as separate CSV files and open them in a spreadsheet, R or Python. The printable report holds the summary tables and the plots.

Completamente gratisNessun costo, nessuna registrazione
I file restano privatiTutto funziona nel tuo browser
Facile nella tua linguaDisponibile in molte lingue