Skip to main content
v2026.11,772 entries · CC-BY 4.0

Principal Component Analysis in Stata: pca and Postestimation

How to run principal component analysis in Stata: pca syntax, reading eigenvalues and loadings, screeplot retention rules, rotation with rotate, and saving component scores with predict.

Ask CASRAI · included with Regulatory Radar

Ask about Principal Component Analysis in Stata: pca and Postestimation

Ask CASRAI answers research-administration questions about this guide and cites the passages behind every claim — and says so when the corpus does not cover something, instead of guessing. It comes with a Regulatory Radar subscription at $29 a month, alongside the daily digest of regulatory changes and the dashboard of what changed.

150 questions a day, on this site, over the API, or inside your own tools through the CASRAI MCP server.

Everything CASRAI publishes — this page, the dictionary, the guides and the news — stays free to read, with no account and no card.

Written and maintained by CASRAI Editorial Board

Last updated

pca is Stata’s command for principal component analysis — it extracts components as linear combinations of your variables that maximize explained variance, prints eigenvalues and proportion-of-variance for every component, and hands off to a dedicated set of postestimation commands (screeplot, rotate, predict, loadingplot) for everything you actually need to decide and report. This page covers pca syntax, how to read its output, the eigenvalue/scree-plot retention decision, rotation with rotate, and predicting component scores with predict.

For the statistical logic of PCA itself — what a component is, what “explained variance” means, and how PCA differs from factor analysis conceptually — see CASRAI’s exploratory factor analysis guide, which covers extraction and rotation logic that carries over directly. If you work in SPSS instead, see PCA in SPSS. This page is the Stata-specific procedure.

Basic pca syntax

The command lists the variables to analyze; there’s no dependent/independent split, since PCA doesn’t model one variable in terms of others:

pca var1 var2 var3 var4 var5

By default pca runs on the correlation matrix, not the covariance matrix — each variable is implicitly standardized before extraction, which is almost always what you want when variables are measured on different scales (a mix of, say, a 1–5 rating and a raw count would otherwise let the count’s larger variance dominate the first component). Use the covariance option to run on the covariance matrix instead if your variables already share a common, meaningful scale:

pca var1 var2 var3 var4 var5, covariance

Two options control how many components pca reports:

  • components(#) — extract and report exactly that many components.
  • mineigen(#) — report only components with an eigenvalue above the threshold. The command’s own default is a near-zero cutoff (mineigen(1e-5)), which in practice means every component is listed unless you narrow it yourself — pca does not apply the “eigenvalue > 1” Kaiser rule automatically. Set it explicitly if you want that behavior at extraction time: mineigen(1).

Most workflows extract all components first (the plain pca varlist call), decide how many to retain from the eigenvalue table and scree plot below, then re-run with components(#) once the count is settled, so the retained-component output and any saved scores line up with a deliberate decision rather than a default cutoff.

Reading the output

pca prints one row per component: the eigenvalue, the difference from the next eigenvalue, the proportion of total variance it explains, and the cumulative proportion. A second table, the component loadings (technically an eigenvector matrix, scaled), shows how each original variable contributes to each retained component — a loading close to ±1 means that variable strongly drives the component; near 0 means it barely contributes. Unlike factor analysis, PCA loadings before rotation have no unique “best” interpretation beyond variance capture — that’s what rotation (below) is for.

Retention rules: the scree plot and its real limits

Run screeplot right after pca to plot eigenvalues against component number:

pca var1 var2 var3 var4 var5
screeplot

Add a reference line at eigenvalue 1 to apply the Kaiser criterion visually, plus bootstrap confidence intervals on each eigenvalue:

screeplot, yline(1) ci(het)

Three retention heuristics, none of them a rule with formal statistical backing on its own:

  • Kaiser criterion (eigenvalue > 1) — keep components whose eigenvalue exceeds 1, the variance of a single standardized variable. Simple and widely taught, but well-documented to over-retain with a large number of variables and under-retain with few.
  • The scree plot “elbow” — keep components before the curve visibly flattens. Genuinely useful as a second opinion but inherently subjective when the elbow isn’t sharp.
  • Cumulative variance explained — keep however many components clear a target (commonly 70–80%), read straight off pca‘s own cumulative-proportion column. Defensible as a stated, pre-registered threshold; arbitrary as a post-hoc justification chosen to fit a preferred component count.

None of these is available as a formal significance test inside pca itself. If you need a more rigorous retention method (parallel analysis, comparing observed eigenvalues against eigenvalues from randomly generated data of the same dimensions), that requires either a user-written command (e.g. paran, install via ssc install paran) or running the comparison manually — it is not built into base Stata’s pca.

Rotation: the rotate command

Unrotated PCA loadings are mathematically optimal for capturing variance but often hard to interpret substantively — most variables load at least moderately on the first component. Rotation redistributes the same explained variance across components to produce a simpler, more interpretable loading pattern, without changing the total variance explained. Run it as a postestimation command, immediately after pca:

pca var1 var2 var3 var4 var5, components(3)
rotate

rotate‘s default method is varimax — an orthogonal rotation that keeps the retained components uncorrelated with each other while maximizing the variance of squared loadings within each component (pushing loadings toward either 0 or ±1). For an oblique rotation that allows the components themselves to correlate, use promax:

rotate, promax

Promax takes a power parameter (rotate, promax(4); default is 3) — a higher power pushes loadings toward simpler structure at the cost of more correlation between the rotated components. Choosing orthogonal vs. oblique is a substantive decision, not just a technical one: if the underlying constructs your components represent are plausibly related to each other, an oblique rotation is the more honest model. After rotate, both the loading table and any subsequent loadingplot/scoreplot calls use the rotated results by default; add the norotated option to any postestimation command to see the original unrotated values instead.

Postestimation: predicting component scores

To save a case’s score on each retained component as a new variable — the standard next step if you’re using the components in further analysis (as predictors in a regression, for example) — use predict with the score option:

predict pc1 pc2 pc3, score

This creates three new variables, one per retained component, computed from the (rotated, if you ran rotate) loadings. loadingplot and scoreplot give the same information graphically — a loading plot shows each original variable positioned by its loading on two chosen components, and a score plot shows each observation positioned by its two component scores:

loadingplot
scoreplot

For sampling adequacy before you trust any of this, estat kmo after pca reports the Kaiser-Meyer-Olkin measure — a low overall KMO (conventionally below about 0.6) is a signal your variables don’t correlate strongly enough as a set for PCA to extract anything meaningfully more compact than the original variables.

PCA is not factor analysis, even though the menus sit near each other

Stata’s pca and its factor-analysis command (factor) are separate commands with separate logic, not two options inside one procedure. PCA decomposes the total variance of your variables directly, with no assumption about an underlying latent construct causing the correlations; factor analysis explicitly models a smaller number of latent factors as the cause of the observed correlations, and estimates unique (non-shared) variance for each variable separately from the common variance the factors explain. In practice PCA is more common as a dimension-reduction or index-construction step; factor analysis is more common when the actual research question is about latent constructs themselves. See CASRAI’s exploratory factor analysis guide for the factor command and how the two diverge in practice, and factor scores for what changes once you move from PCA-style component scores to factor-analysis-style factor scores.

Related Stata procedures

  • Regression in Stata — using saved component scores as predictors to address multicollinearity among the originals.
  • ANOVA in Stata — comparing component scores across groups once they’re saved as variables.
  • Correlation matrices in Stata — inspecting the correlation structure PCA is decomposing before you run it.

Frequently asked questions

Is PCA the same as factor analysis in Stata?

No. They’re separate commands (pca vs. factor) built on different models. PCA decomposes total variance with no latent-cause assumption; factor analysis models a smaller set of latent factors as the cause of the observed correlations and separates unique from common variance. See the section above and CASRAI’s exploratory factor analysis guide for the full distinction.

Does pca use the correlation or covariance matrix by default?

Correlation, by default — each variable is standardized before extraction. Use the covariance option to run on raw covariances instead, which only makes sense when your variables already share a comparable, meaningful scale.

Does Stata automatically apply the “eigenvalue over 1” rule?

No. The default mineigen() threshold is a near-zero cutoff (1e-5), so a plain pca varlist call reports every component. You have to set mineigen(1) yourself to apply the Kaiser criterion at extraction time, or just read the eigenvalue table and re-run with components(#) once you’ve decided how many to keep.

Should I rotate the components?

If you’re using PCA purely for dimension reduction ahead of another analysis (e.g. predictors in a regression), rotation is optional — it doesn’t change the variance explained or the quality of scores as summaries. If you’re trying to interpret what each component substantively represents, rotation (rotate, varimax by default) usually makes the loading pattern easier to read, and is standard practice for that purpose.

How do I save PCA component scores as new variables in Stata?

predict newvar1 newvar2 ..., score immediately after pca (or after rotate, if you rotated) — one new variable per component, one predict call listing as many new variable names as components you want scores for.

What does a KMO value from estat kmo tell me?

The Kaiser-Meyer-Olkin measure of sampling adequacy, run via estat kmo after pca, summarizes how much of the correlation among your variables is likely to be common variance PCA can usefully compress versus noise. A low overall value (conventionally under about 0.6) suggests the variable set isn’t correlated enough as a group for PCA to meaningfully reduce it.

Follow CASRAI

Research-administration guidance, standards updates and independent tool reviews.

Referenced across the research world

University of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logoUniversity of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logo
  • University of Cambridge logo
  • Columbia University logo
  • Crossref logo
  • University of Edinburgh logo
  • Harvard University logo
  • University of Oxford logo
  • Princeton University logo
  • Stanford School of Medicine logo
  • University College London logo
  • ORCID logo

View CASRAI adoption →

Regulatory Radar

Stop finding out after the fact

$29/month, cancel anytime. Daily digest updates from our analysis, a dashboard holding the same items, and a cited assistant for everything they raise.

  • Federal Register, Federal Register+, Grants.gov, Regulations.gov, NSF News, UKRI, plus CASRAI’s own published content.
  • 44,322 indexed passages, and every answer cites the ones it drew on.