Principal components analysis and clustering algorithms

Principal components analysis and clustering algorithms

Published September 28, 2026

Principal components analysis and clustering algorithms

On this page

Learning Outcome Statement

Describe unsupervised machine learning algorithms-including principal components analysis, k-means clustering, and hierarchical clustering-and determine the problems for which they are best suited.

On the exam: The vignette gives the data structure, objective, scaling, eigenvalues, centroids, or dendrogram, then asks for the best algorithm, an interpretation, or a variance or squared-distance result in an item set or multiple-choice question.

Unsupervised learning starts with observations but no target label. You want either a smaller coordinate set or a set of groups. When a grouping method needs a preselected number of groups, call that number $k$. The exam rewards matching the requested output to the algorithm.

AlgorithmData or objectiveResult
PCACorrelated variables, reduce dimensionsOrthogonal components, variance ranking
K-meansCompact groups, $k$ knownLabels, centroids
Hierarchical clusteringNested or exploratory groupsDendrogram, nested clusters

Standardize the indicators before PCA when their scales differ, so scale does not dominate the variance. The retained scores can supply cleaner coordinates for a later clustering step, but clustering creates the group membership.

PCA transforms correlated variables into orthogonal components and ranks them by variance explained. For component $i$, let $\lambda_i$ be its eigenvalue. Let $v_i$ be its variance share, and let $j$ index every component in the data. Variance explained by component $i$ is calculated as follows.

$$ v_i=\frac{\lambda_i}{\sum_j \lambda_j} $$

The numerator carries the variance of the chosen component. The denominator adds the variance carried by every component. A larger $\lambda_i$ raises $v_i$, while a larger denominator lowers $v_i$ when the numerator stays fixed.

The model choice is a decision about the output you need. Standardize indicators first, then follow the branch that matches reduction, centroid assignment, or nested grouping.

Loading diagram…

K-means assigns observations to the nearest centroid and updates centroids iteratively. A centroid is the current center of a group in the score space. It suits compact groups when $k$ is known. Hierarchical clustering builds nested groups that can be inspected through a dendrogram. The dendrogram lets you inspect nested relationships before selecting a grouping cut.

Worked example

You are handed cross-sectional data on funds with three standardized risk indicators. PCA returns three components with eigenvalues, and the analyst keeps two components before assigning a new fund to the nearer of two candidate centroids. The exam asks for the variance retained and the nearer centroid.

ItemValue
Standardized indicators3
PCA components3
Components retained2
Candidate clusters2
Eigenvalues $(\lambda_1,\lambda_2,\lambda_3)$$2.1, 0.6, 0.3$
New fund $(PC_1, PC_2)$$1.2, 0.4$
Growth centroid$1.8, 0.7$
Defensive centroid$-0.6, -0.3$

These are cross-sectional observations, so no annual or periodic conversion applies. The indicators were standardized before PCA, and the supplied eigenvalues are dimensionless outputs from a sample analysis. The negative scores are coordinates, not cash-flow signs.

The bars are the eigenvalues in component order.

Loading diagram…

For the distance calculation, the new fund's first score is $x_1=1.2$ and its second score is $x_2=0.4$. The growth centroid has coordinates $g_1=1.8$ and $g_2=0.7$. The defensive centroid has coordinates $r_1=-0.6$ and $r_2=-0.3$. For a centroid with coordinates $c_1$ and $c_2$, the squared Euclidean distance $d^2$ is calculated as follows.

$$ d^2=(x_1-c_1)^2+(x_2-c_2)^2 $$

  1. Add the eigenvalues because the denominator is total variance. This produces $\lambda_1+\lambda_2+\lambda_3=2.1+0.6+0.3=3.0000$.
  2. Divide the first eigenvalue by total variance. This produces $v_1=\frac{2.1}{3.0000}=0.70$, or 70.00%.
  3. Calculate the remaining shares because retained variance includes the other component. The shares are $\frac{0.6}{3.0000}=0.20$ and $\frac{0.3}{3.0000}=0.10$. The retained cumulative share is $0.70+0.20=0.90$, or 90.00%.
  4. Compare the fund with the growth centroid by squaring each coordinate difference and adding them. The differences are $-0.60$ and $-0.30$, giving $0.36+0.09=0.45$.
  5. Repeat the distance calculation for the defensive centroid. The differences are $1.80$ and $0.70$, giving $3.24+0.49=3.73$.

Keeping two components retains 90.00% of variance. The new fund is closer to growth because 0.45 is less than 3.73, so K-means assigns it to growth.

Changed condition

QuantityOriginalChanged
$PC_1$ eigenvalue2.11.8
Total eigenvalue sum3.00002.7000
$PC_1$ variance share0.700.67
Two-component cumulative share0.900.89

Predict the direction before calculating. Lowering the $PC_1$ eigenvalue lowers its numerator and the denominator, so the share falls from 0.70 to 0.67. The two-component cumulative share falls from 0.90 to 0.89, while the centroid distances do not move because the scores and centroids are unchanged. Now calculate the changed $PC_2$ share yourself.

Common error

You may reach for PCA because it reduces dimensions and makes observations easier to plot. That choice feels right when you want a simpler picture, but PCA creates new coordinates rather than groups. When the question asks you for labels, segments, centroids, or a dendrogram, choose clustering because the clustering algorithm assigns observations to groups.

Calculator

Use the squared growth distance to check the nearest-centroid calculation.

KeysDisplay
0.360.36
+0.36
0.090.09
=0.45

Check yourself

Practice

A cross-sectional fund study standardizes three risk indicators. PCA produces eigenvalues 2.1, 0.6, and 0.3. The new fund scores 1.2 and 0.4 on PC_1 and PC_2. Candidate centroids are growth at 1.8 and 0.7 and defensive at -0.6 and -0.3. The analyst uses two components and squared Euclidean distance.

Question 1

Which algorithm is best suited to transform correlated indicators into fewer orthogonal coordinates?

Question 2

What proportion of variance does PC_1 explain?

Question 3

Using squared Euclidean distance, what is the new fund's distance squared to the growth centroid?

Question 4

Which algorithm assigns the new fund to the nearest candidate centroid?

An analyst wants nested or exploratory groups and wants to inspect the structure through a dendrogram. Which algorithm is best suited?

Revision snapshot

PCA transforms correlated variables into orthogonal components and ranks them by variance explained. Variance explained by a component equals its eigenvalue divided by the sum of all eigenvalues. Use $v_i=\frac{\lambda_i}{\sum_j\lambda_j}$. K-means assigns observations to the nearest centroid and updates centroids iteratively. Hierarchical clustering builds nested groups that can be inspected through a dendrogram. The trap is treating PCA coordinates as group labels.

MethodChoose it for
PCAReduction
K-meansCompact groups, $k$ known
Hierarchical clusteringNested or exploratory grouping

Choose PCA for reduction, k-means for compact groups when $k$ is known, and hierarchical clustering for nested or exploratory grouping. On the exam, match the requested output to the method.

Unlock the full lesson and continue reading

Signup to continue reading this lesson and unlimited access questions, flashcards, AI notes, and more

Scan to download app

Scan to download
UNLOCK FREE ACCESS

Practice Questions: Principal components analysis and clustering algorithms

  1. 1. An investor deposits USD 10,000 for 18 months at a stated annual rate of 6%, compounded monthly. The calculated future value is closest to:

    • A. USD 10,900
    • B. USD 10,913
    • C. USD 10,939
    Show answer

    Answer: C. USD 10,939

    > Key point: For monthly compounding, use the monthly rate and the total number of months as the compounding periods. Why USD 10,939 is correct - Monthly rate: 6% ÷ 12 = 0.5%; periods: 18 months. - Future value = USD 10,000 × (1.005)^18 ≈ USD 10,939. Working | Step | Working | Result | |---|---|---| | Monthly rate | 6% ÷ 12 | 0.5% | | Number of periods | 18 months | 18 | | Future value | USD 10,000 × (1.005)^18 | USD 10,939 | Answer: USD 10,939 Why the other options are wrong - USD 10,900: Simple interest gives USD 10,000 × [1 + (0.06 × 1.5)] = USD 10,900; it omits monthly compounding. - USD 10,913: Annual compounding gives USD 10,000 × (1.06)^1.5 ≈ USD 10,913; the rate is compounded monthly.

  2. 2. For 36 independent monthly active returns, the mean is 0.80% and sample standard deviation is 2.40%. At 5%, test H₀: μ ≤ 0 against H₁: μ > 0; the one-tailed critical t-value is 1.69.

    • A. Fail to reject the null because 0.80% is economically small
    • B. Fail to reject the null because the test statistic is below 1.96
    • C. Reject the null in favor of a positive mean return
    Show answer

    Answer: C. Reject the null in favor of a positive mean return

    > Key point: For a one-tailed test, compare the calculated t-statistic with the supplied one-tailed critical value. Why Reject the null in favor of a positive mean return is correct - Standard error = 2.40% / √36 = 0.40%. - t = 0.80% / 0.40% = 2.00; since 2.00 exceeds the 1.69 critical value, reject the null. Working | Step | Working | Result | |---|---|---| | Standard error | 2.40% / √36 | 0.40% | | Test statistic | 0.80% / 0.40% | 2.00 | | Decision | 2.00 > 1.69 | Reject H₀ | Answer: Reject the null in favor of a positive mean return. Why the other options are wrong - Fail to reject the null because 0.80% is economically small: economic magnitude does not determine statistical significance; the test statistic exceeds the threshold. - Fail to reject the null because the test statistic is below 1.96: the statistic is 2.00, not below 1.96; the supplied one-tailed critical value is 1.69.

  3. 3. An analyst obtains a p-value of 0.030 for a two-sided test conducted at the 5% significance level. The analyst should most likely:

    • A. Reject the null hypothesis
    • B. Fail to reject the null hypothesis
    • C. Accept the null hypothesis as true
    Show answer

    Answer: A. Reject the null hypothesis

    > Key point: Reject the null hypothesis when the p-value is below the significance level. Why Reject the null hypothesis is correct - The p-value (0.030) is below the 5% significance level (0.050), so the result is statistically significant and the null hypothesis is rejected. Why the other options are wrong - Fail to reject the null hypothesis: This is the decision when the p-value is greater than the significance level, not when it is lower. - Accept the null hypothesis as true: A hypothesis test does not establish that the null is true; when evidence is insufficient, the decision is to fail to reject it.

  4. 4. An analyst compares one-period simple returns with continuously compounded returns for an asset whose price remains positive. Which conclusion is most accurate?

    • A. Both returns have a lower bound of −100%
    • B. Neither return has a finite lower bound
    • C. Only the continuously compounded return is unbounded below
    Show answer

    Answer: C. Only the continuously compounded return is unbounded below

    > Key point: Simple returns cannot fall below −100%, while continuously compounded returns have no finite lower bound. Why Only the continuously compounded return is unbounded below is correct - A simple return is P₁/P₀ − 1; with positive prices, it stays above −100%. - A continuously compounded return is ln(P₁/P₀); as the ending price approaches zero, this return approaches negative infinity. How they compare | Return measure | Lower bound | |---|---| | Simple | −100% (not reached for positive ending prices) | | Continuously compounded | No finite lower bound | Why the other options are wrong - Both returns have a lower bound of −100%: the continuously compounded return can fall below −100% without limit. - Neither return has a finite lower bound: the simple return remains above −100% when prices are positive.

  5. 5. An investor deposits USD 1,000 at the beginning of each quarter for two years. At 8% nominal compounded quarterly, the value immediately after the eighth quarter's interest is credited is closest to:

    • A. USD 8,000.00
    • B. USD 8,582.97
    • C. USD 8,754.63
    Show answer

    Answer: C. USD 8,754.63

    > Key point: Beginning-of-quarter deposits form an annuity due, so each deposit earns one extra quarter of interest. Why USD 8,754.63 is correct - The quarterly rate is 8% ÷ 4 = 2%. - The eight deposits accumulate as an ordinary annuity, then receive one additional quarter of growth: USD 1,000 × [(1.02⁸ − 1) ÷ 0.02] × 1.02 = USD 8,754.63. Working | Step | Working | Result | |---|---|---| | Quarterly rate | 8% ÷ 4 | 2% | | Ordinary-annuity value | USD 1,000 × [(1.02⁸ − 1) ÷ 0.02] | USD 8,582.97 | | Adjust for beginning deposits | USD 8,582.97 × 1.02 | USD 8,754.63 | Answer: USD 8,754.63 Why the other options are wrong - USD 8,000.00: This totals the deposits but omits all interest. - USD 8,582.97: This treats deposits as occurring at quarter-end and omits the extra quarter of growth for each beginning-of-quarter deposit.

  6. 6. A portfolio's mean annual return is 8.00% from 36 independent observations, with sample standard deviation 12.00%. Using a 1.96 critical value, the calculated 95% confidence interval is closest to:

    • A. 7.35% to 8.65%
    • B. 4.08% to 11.92%
    • C. 3.30% to 12.70%
    Show answer

    Answer: B. 4.08% to 11.92%

    > Key point: A confidence interval for the mean uses the sample standard deviation divided by the square root of the observation count. Why 4.08% to 11.92% is correct - Standard error = 12.00% ÷ √36 = 2.00%. - Interval = 8.00% ± 1.96 × 2.00% = 8.00% ± 3.92%. Working | Step | Working | Result | |---|---|---| | Standard error | 12.00% ÷ √36 | 2.00% | | Margin of error | 1.96 × 2.00% | 3.92% | | Confidence interval | 8.00% ± 3.92% | 4.08% to 11.92% | Answer: 4.08% to 11.92% Why the other options are wrong - 7.35% to 8.65%: Dividing by 36 instead of √36 gives a 0.33% standard error and a 0.65% margin of error, producing this interval. - 3.30% to 12.70%: Using 25 observations gives a 2.40% standard error and a 4.70% margin of error, producing this interval.

  7. 7. A deposit earns a nominal annual rate of 7.20%, compounded monthly. The calculated value of its effective annual return is closest to:

    • A. 7.20%
    • B. 7.44%
    • C. 7.47%
    Show answer

    Answer: B. 7.44%

    > Key point: For a nominal annual rate compounded monthly, calculate the effective annual return by compounding the monthly rate 12 times. Why 7.44% is correct - Monthly rate = 7.20% ÷ 12 = 0.60%. - Effective annual return = (1 + 0.072/12)¹² − 1 ≈ 7.44%. Working | Step | Working | Result | |---|---|---| | Monthly rate | 7.20% ÷ 12 | 0.60% | | Effective annual return | (1 + 0.072/12)¹² − 1 | 7.44% | Answer: 7.44% Why the other options are wrong - 7.20%: This is the nominal annual rate; it omits interest earned on interest during monthly compounding. - 7.47%: This uses continuous compounding, e⁰·⁰⁷² − 1, rather than monthly compounding.

  8. 8. A portfolio invests 60% in an asset with 12% volatility and 40% in an asset with 20% volatility; correlation is 0.25. The calculated diversification ratio is closest to:

    • A. 0.792
    • B. 1.000
    • C. 1.264
    Show answer

    Answer: C. 1.264

    > Key point: Diversification ratio equals weighted-average asset volatility divided by portfolio volatility. Why 1.264 is correct - Weighted-average asset volatility: 0.60 × 12% + 0.40 × 20% = 15.20%. - Portfolio volatility is about 12.03%, so the ratio is 15.20% ÷ 12.03% ≈ 1.264. Working | Step | Working | Result | |---|---|---| | Portfolio variance | 0.60² × 0.12² + 0.40² × 0.20² + 2 × 0.60 × 0.40 × 0.25 × 0.12 × 0.20 | 0.014464 | | Portfolio volatility | √0.014464 | 12.03% | | Weighted-average volatility | 0.60 × 12% + 0.40 × 20% | 15.20% | | Diversification ratio | 15.20% ÷ 12.03% | 1.264 | Answer: 1.264 Why the other options are wrong - 0.792: This reverses the ratio, dividing portfolio volatility by weighted-average asset volatility. - 1.000: This would require portfolio volatility to equal weighted-average asset volatility; the 0.25 correlation makes portfolio volatility lower.

Flashcards: Principal components analysis and clustering algorithms

  1. 1. What are reinforced learning algorithms?

    Show answer

    programs that learn from their own prediction errors

  2. 2. What are deep learning algorithms used for?

    Show answer

    complex tasks such as image recognition, natural language processing, and so on

  3. 3. When does machine learning perform better than standard statistical approaches?

    Show answer

    when dealing with a large number of variables (high dimension) and when the relationships are nonlinear

  4. 4. How does variance error and bias error change with model complexity?

    Show answer

    variance increases with model complexity\ bias decreases with model complexity

  5. 5. What is accuracy?

    Show answer

    the % of correctly predicted classes out of total predictions

  6. 6. When given the prob. of correct call, IC =

    Show answer

    \= 2(% correct) - 1

  7. 7. What are the investment applications of KNN?

    Show answer

    - predicting bankruptcy - assigning a bond to a ratings class - predicting stock prices - creating customized indices

  8. 8. What are the investment applications of random forest?

    Show answer

    - factor-based asset allocation - prediction models for success of an IPO

  9. 9. When is LASSO useful?

    Show answer

    in building parsimonious models through feature reduction

  10. 10. What kind of mean is a F1 score?

    Show answer

    the harmonic mean of recall and precision

Everything you need for CFA prep

Get full Oncourse access with lessons, practice questions, flashcards and AI study tools.

GET STARTED FOR FREE
75% OFFLimited time offer
GET 75% OFF