← 10. Patterns & segmentation
Principal Component Analysis
Try this analysis →

Principal Component Analysis (PCA)

Reduces dimensions while keeping as much as possible of the information that overlapping variables share.

StandardizationEigenvalues · explained varianceLoadings and scoresBiplot

Electricity useNatural gas useCooling demandHeating demandPeak power demandEnergy use variabilityWeighted sumPC1 · 46%Overall consumption intensityPC2 · 25%Cooling ↔ heatingTwo components total 71%

Suppose an energy research institute is comparing the energy use characteristics of 120 regions across the country. The institute collected several indicators for each region, including electricity use, natural gas use, summer cooling demand, winter heating demand and peak power demand.

But these indicators can be closely related to one another. Regions that consume a lot of electricity often also have high peak power demand, and regions with high heating demand may also show high natural gas use.

When variables carry similar information like this, it can be more useful to summarize their common variation with a few new indicators than to compare every indicator separately. Principal component analysis (PCA) is a method that reduces dimensions while retaining as much of the information in several numeric variables as possible.

In this article we use a single example to look at how principal components are built, standardization, eigenvalues and explained variance ratios, component loadings and scores, visualization, how PCA differs from factor analysis, and how to interpret results and what to watch out for.

SECTION 1

What does principal component analysis do?

PCA creates new variables, called principal components, as linear combinations of the original variables.

The first principal component (PC1) is the direction that explains the most variation in the data, and the second principal component (PC2) is the direction, orthogonal to the first, that explains the most of the remaining variation. Later components are built on the same principle.

Electricity useNatural gas useCooling demandHeating demandPeak power demandEnergy use variabilityWeightedsumOrthogonal directionsPC146%Overall consumption intensityPC225%Cooling ↔ heatingTwo components total 71%
Summarizing six indicators with two components

For example, if six energy indicators are summarized with two principal components, instead of comparing six values one by one for each region, you can look at the overall characteristics through two coordinates, PC1 and PC2.

However, using only two components loses some of the information in the original data. How much information was retained must be checked with the explained variance ratio.

PCA is a method for summarizing the variation in observed data. Principal components are not automatically given a causal meaning, and the researcher must interpret and name new components by looking at the contributions of the original variables.

SECTION 2

What kinds of studies use it?

PCA is useful when there are many correlated numeric variables and you want to summarize or visualize them with a few indicators.

Besides comparing regional energy characteristics, it can be used to explore patterns across many health checkup indicators, condense a product's many performance metrics, or reduce the dimensionality of features fed into a machine learning model.

PurposeWhat PCA gives you
Data summaryPrincipal components that represent the variation in many variables
Visualization2D or 3D principal component coordinates
Less redundant informationCompresses information from highly correlated variables
Follow-up analysisComponent scores for regression, clustering and more

However, reducing dimensions with PCA does not necessarily improve predictive performance. Information important for prediction may lie in a direction with small variance. Depending on the purpose of the follow-up analysis, compare the original variables with the principal components.

SECTION 3

Worked example: regional energy use characteristics

Suppose the research institute collected the following six variables for 120 regions.

To reduce differences due to regional size, all variables were defined as indicators that take population or the size of relevant facilities into account.

VariableWhat is measuredUnit
Electricity useAnnual electricity use per personMWh/person
Natural gas useAnnual natural gas use per personMWh/person
Cooling demandSummer cooling electricity use per personkWh/person
Heating demandWinter heating energy use per personkWh/person
Peak power demandPeak power demand per 10,000 residentsMW
Energy use variabilityCoefficient of variation of monthly consumptionIndex

The research question is: "Can six regional energy consumption indicators be summarized with a few principal components, and what usage characteristics do those components represent?"

The figures and result tables in this example were constructed to illustrate how PCA is interpreted; they are not actual regional energy statistics.

SECTION 4

Why standardize before PCA

If the original variables differ in units and variance, a variable with a wide range of values can have an outsized influence on the first principal component.

For example, cooling demand is in kWh, natural gas use in MWh, and variability is a unitless index, so analyzing them in their original units would let the choice of units itself affect the results.

SD before standardizationAfter standardizationElectricity use1.8 MWh1.0Natural gas use1.2 MWh1.0Cooling demand210 kWh1.0Heating demand320 kWh1.0Peak power demand0.6 MW1.0Energy use variability0.08 index1.0
Spread of variables before and after standardization

For this reason, when analyzing indicators measured in different units together, standardization, which sets each variable's mean to 0 and standard deviation to 1, is often used.

zij = ( xij − x̄j ) ÷ sj

Here xij is the value of variable j for region i, x̄j is the mean of variable j, and sj is its standard deviation. Applying PCA to standardized data is effectively the same as finding the principal components from the correlation matrix.

If all variables are in the same unit and differences in variance are themselves important information for the study, you might choose PCA based on the covariance matrix. So standardization is not a step to apply automatically; decide based on the variables' units and the purpose of the analysis.

SECTION 5

How are principal components computed?

PCA creates new coordinates by taking weighted sums of the standardized variables.

The score on the first principal component can be written as follows.

PC1i = w1zi1 + w2zi2 + ⋯ + w6zi6

The coefficients wj are the weights given to each original variable, chosen so that the variance explained by the component is as large as possible. In standard PCA, the component directions are constructed to be orthogonal to one another.

PC1Explains 46%PC2Explains 25%
Directions of the component axes

In matrix terms, the principal components can be found by an eigendecomposition of the covariance or correlation matrix, or by a singular value decomposition (SVD) of the standardized data matrix. The eigenvectors give the directions of the components, and the eigenvalues give the variance explained along each direction.

The important point here is that the computed principal components are new composite variables, different from the original variables. Whether PC1 can be called 'scale of energy consumption' should be judged after checking the formula and the loadings.

SECTION 6

How many components should you keep?

The number of components is decided by weighing the cumulative explained variance ratio, the scree plot and the purpose of the follow-up analysis.

Below are the results of PCA on the six standardized variables.

ComponentEigenvalueExplained variance ratioCumulative explained variance ratio
PC12.7646%46%
PC21.5025%71%
PC30.7212%83%
PC40.488%91%
PC50.366%97%
PC60.183%100%
01230%50%100%EigenvalueCumulative2.76PC11.50PC20.72PC30.48PC40.36PC50.18PC646%71%83%91%97%100%
Eigenvalues and cumulative explained variance ratio

Because six standardized variables were used, the eigenvalues sum to 6. For example, the explained variance ratio of PC1 is 2.76 ÷ 6 = 0.46, or 46%. Using PC1 and PC2 together explains 71% of the total variance of the original variables.

In this example the goal is to look at the overall regional pattern with two components, so suppose we chose PC1 and PC2. In a study where preserving information matters more, however, you could keep up to PC3, which brings the cumulative share to 83%.

Rules such as '70% cumulative is enough' or 'always keep components with eigenvalues of 1 or more' should never be used as absolute criteria.

SECTION 7

How do you read component loadings?

Component loadings are used to understand the relationship between the original variables and the principal components.

The table below is a conceptually simplified example of loadings expressed as correlation coefficients between the original variables and the components.

Original variablePC1PC2
Electricity use0.820.18
Natural gas use0.72-0.44
Cooling demand0.600.68
Heating demand0.67-0.59
Peak power demand0.840.25
Energy use variability0.300.47
PC1PC2Electricity use+0.82+0.18Natural gas use+0.72−0.44Cooling demand+0.60+0.68Heating demand+0.67−0.59Peak power demand+0.84+0.25Energy use variability+0.30+0.47
Component loadings

This table is an example pattern to explain the meaning of the components. It is not presented as the result of computing the exact same matrix back from the eigenvalues in the previous section.

PC1 is strongly positively related to the overall scale of energy use, including electricity use, peak power demand and natural gas use. So for the purposes of the study, it can be interpreted as 'overall energy consumption intensity'.

On PC2, the loading for cooling demand is positive, and the loadings for heating demand and natural gas use are negative. So it can be interpreted as 'cooling-oriented vs. heating-oriented usage'.

The signs of principal components in PCA are arbitrary. Even if all the signs of a component come out reversed when the same analysis is run in a different program, they can represent mathematically the same direction. So do not attach a fixed substantive meaning to a positive value itself.

SECTION 8

What do component scores mean?

Component scores show where each region lies on the estimated principal component axes.

If loadings describe the variables, component scores describe the observed units, here the regions. For example, suppose we got the following scores.

RegionPC1 scorePC2 scoreExample interpretation
Region A+1.80+0.90High energy consumption intensity, cooling-oriented
Region B+1.20-1.10High consumption intensity, heating-oriented
Region C-1.30+0.40Low consumption intensity but relatively cooling-oriented
Region D-0.90-0.80Low consumption intensity, heating-oriented
PC1 →↑ PC2High intensityLow intensityCooling-orientedHeating-orientedRegion A(+1.80, +0.90)Region B(+1.20, -1.10)Region C(-1.30, +0.40)Region D(-0.90, -0.80)
Component scores of four regions

A score of 0 means being near the center of that component axis in the standardized data. A component score of +1.80 does not mean electricity use is 1.8 times higher. And because PCA scores are close to unitless composite coordinates, it is more natural to interpret the regions' relative positions and patterns than the absolute values.

SECTION 9

What do you check in a PCA plot?

Plotting the regions on a scatterplot of the first two components lets you see whether regions with similar energy use characteristics appear close together.

With PC1 on the horizontal axis and PC2 on the vertical axis, moving right can be read as higher overall energy consumption intensity, and moving up as more cooling-oriented. This reading holds as long as the component directions defined above are kept.

However, the variance shown in the 2D plot is 71% in this example. So even if two regions appear close together in the plot, they may differ in the remaining 29% of the information. Similarity between regions should not be judged fully from a single PC1–PC2 scatterplot.

PC1PC2Electricity useNatural gas useCooling demandHeating demandPeak power demandEnergy use variabilityCoolingHeatingOther variablesRegion
Biplot

A biplot, which also draws the original variables' loadings as arrows, lets you look at the regions' scores and the variable directions at the same time. Here the interpretation of arrow lengths and angles can depend on the biplot scaling used, so check which scaling it is.

SECTION 10

How do PCA and exploratory factor analysis (EFA) differ?

PCA and EFA both organize many variables into a few dimensions, but they differ in purpose and statistical assumptions.

PCA creates new components that preserve as much of the total variance of the observed variables as possible. EFA estimates latent factors that explain the common variance of several items, and treats item-specific variation and measurement error separately.

AspectPCAEFA
PurposeCompress information and reduce dimensionsExplore common latent factors
Variance usedTotal variance of observed variablesMainly common variance
ResultMutually orthogonal componentsFactors that may be correlated depending on rotation and model
Typical useSummarize many energy indicators with a few coordinatesExplore latent concepts such as autonomy or collaboration in survey items

For example, to condense six energy indicators into two composite indicators, PCA is a suitable starting point. If instead you want to find out how many psychological latent factors 12 survey items actually measure, EFA may be more suitable.

Being able to give components meaningful names does not by itself make PCA a latent variable model.

SECTION 11

What should you watch out for when using PCA in a follow-up analysis?

PCA scores can be used as inputs to cluster analysis, regression models, visualization and so on.

But dimensionality reduction does not always improve the quality of a follow-up analysis. For example, if a variable that is important for predicting a particular regional risk does not contribute much to the total variance, keeping only the top components can lose predictive information.

If you use PCA in machine learning, learn the standardization means and standard deviations and the component directions from the training data only.

Then apply the transformation learned from the training data unchanged to the validation and test data. Computing PCA on the full data first and then splitting into training and test data can cause data leakage.

Also, the meaning of the components depends on the variables, sample and standardization method included in the analysis. If you rerun PCA after adding new variables or regions, the loadings and component scores can change, so keep the same transformation basis when comparing results.

SECTION 12

Common mistakes when interpreting PCA results

Do not interpret the explained variance ratio as prediction accuracy.

That PC1 and PC2 explain 71% of the total variance means that 71% of the variation in the six energy indicators is represented by the two axes. It does not mean a later regression will predict a target variable with 71% accuracy.

Do not leave out the standardization decision.

If variables in different units are not standardized, their units of measurement can strongly influence the component directions. Conversely, if differences in variance matter for the study, you may choose not to standardize.

Do not confuse loadings and scores.

Loadings show which variables are related to a component, and scores show where each observed unit lies on the component axis.

Do not interpret components as causes.

A region scoring high on PC1 only reflects a pattern of variation shared by several energy indicators; it does not mean a factor called PC1 caused the region's electricity consumption.

Check the data structure and outliers.

Because PCA is based on means, variances and covariances, it can be strongly affected by extreme observations. Rather than automatically deleting outliers, distinguish data errors from genuinely unusual regions and, if needed, consider alternatives such as robust PCA.

SECTION 13

How do you report PCA results?

When reporting PCA results, it is good to present the sample and number of variables, the preprocessing and standardization method, the criterion for choosing the number of components, each component's eigenvalue and explained variance ratio, the main loadings and the interpretation together.

If you used the scores in a follow-up analysis, also record how the scores were computed and the transformation basis.

Example report

To summarize regional energy consumption characteristics, principal component analysis (PCA) was conducted on six indicators for 120 regions. Because the variables were measured in different units, all indicators were standardized and PCA based on the correlation matrix was applied. The first principal component had an eigenvalue of 2.76 and explained 46% of the total variance, and the second had an eigenvalue of 1.50 and explained an additional 25%. The cumulative explained variance ratio of the two components was 71%.

The first principal component was closely related to the overall level of consumption, such as electricity use and peak power demand, and was interpreted as overall energy consumption intensity. The second principal component reflected the contrast between cooling demand and heating demand and was interpreted as cooling-oriented vs. heating-oriented usage. These results show that six related energy indicators can be summarized along two main axes to compare regional patterns.

The example loading pattern and the eigenvalue table were constructed separately to explain the principle.

✓Wrap-up

PCA is a way to compress the information in variables

Principal component analysis is a dimensionality reduction method that summarizes many numeric variables with a few new components.


Because it is constructed so that, starting with the first component, each explains as much variance as possible in turn, it is useful for organizing and visualizing patterns among correlated variables.

In the analysis, you first decide on the variables' units and whether to standardize, then use the eigenvalues and explained variance ratios to choose how many components to keep. You can then interpret what each component means from its loadings and look at the relative positions of the observed units from the component scores.

However, PCA is not a method for confirming latent factors or testing causal relationships. And a high explained variance ratio does not guarantee follow-up predictive performance, so use the results in a way that fits the purpose of the study.

KEY TAKEAWAY

The key to PCA is not to cut variables at all costs, but to check how much more concisely the data can be expressed while keeping a reasonable amount of information.