Sub topic 11
Checking explained variance, stress, and stability
A perceptual map squeezes many attributes or pairwise judgments into two dimensions. Some information is always lost. This chapter shows how to measure that loss and how to test whether the picture would survive a different sample of customers.
This chapter assumes you can run the PCA and MDS examples from the earlier chapters, and that you know what a bootstrap resample is (drawing respondents with replacement). The code needs numpy, pandas, scipy, and scikit-learn.
Why a map needs a fit check
A two-dimensional map is a summary, and a summary can mislead in two ways.
- Poor fit: the real structure needs three or more dimensions, so distances on the map no longer match what customers said.
- Instability: the structure is real in this sample, but a different sample of respondents would move the brands noticeably.
Explained variance (for PCA) and stress (for MDS) address the first problem. Resampling addresses the second. Do both before you present any positioning conclusion.
Explained variance for PCA maps
PCA finds new axes, called components, ordered by how much of the total variation in the standardized ratings each one captures. The share captured by one component is its explained variance ratio. The ratios across all components sum to 1.
The map shows only the first two components. The share of variance they hold together is the cumulative explained variance. It tells you how much of the original rating pattern the map preserves.
import numpy as np
import pandas as pd
from sklearn.decomposition import PCA
from sklearn.preprocessing import StandardScaler
ratings = pd.DataFrame(
{
"affordable": [6.1, 5.4, 2.3, 3.0, 4.2],
"premium": [2.0, 3.1, 6.4, 5.8, 4.0],
"innovative": [3.2, 5.9, 5.1, 2.5, 4.4],
"reliable": [5.0, 3.3, 5.6, 6.0, 4.1],
},
index=["Brand A", "Brand B", "Brand C", "Brand D", "Brand E"],
)
scaled = StandardScaler().fit_transform(ratings)
pca_full = PCA().fit(scaled) # keep every component
ratio = pca_full.explained_variance_ratio_
summary = pd.DataFrame(
{"ratio": ratio, "cumulative": ratio.cumsum()},
index=[f"PC{i}" for i in range(1, len(ratio) + 1)],
)
print(summary.round(2))
# How much of each brand's position survives in two dimensions?
scores = pca_full.transform(scaled)
total = (scores ** 2).sum(axis=1)
in_2d = (scores[:, :2] ** 2).sum(axis=1)
quality = pd.Series(in_2d / total, index=ratings.index, name="share_in_2d")
print(quality.round(2))The first table is a scree summary. Look for the point where the ratios stop dropping steeply and flatten out. If PC3 is nearly as large as PC2, a two-dimensional map is cutting off real structure.
The second output is brand-level quality. For each brand it gives the fraction of its squared distance from the market centre that is visible in the first two dimensions. A brand with a low share sits partly "above" or "below" the page. Its map position is unreliable, and apparent closeness to a neighbour may be an artifact.
There is no universal cutoff for acceptable cumulative variance. Many analysts want the two dimensions to hold well over half of the variance, and they get cautious when a third component is close in size. Judge the number against how many attributes you rated. Four attributes can reach a high share easily. Fifteen attributes rarely do.
Stress for MDS maps
MDS places brands so that map distances match the dissimilarities respondents gave. Stress measures the mismatch. Zero means the distances match exactly, and larger values mean worse fit.
scikit-learn's stress_ attribute is a raw sum of squared differences. It depends on the scale of your input, so you can't compare it across studies. A normalized version, close to Kruskal's stress-1, is easier to interpret:
stress = sqrt( sum of (observed − fitted)² / sum of fitted² )
The sums run over all brand pairs. The following code computes it and compares one, two, and three dimensions.
import numpy as np
from scipy.spatial.distance import pdist, squareform
from sklearn.manifold import MDS
brands = ["A", "B", "C", "D", "E", "F"]
dissimilarity = np.array(
[
[0.0, 2.0, 3.0, 6.0, 7.0, 6.0],
[2.0, 0.0, 2.5, 5.5, 6.5, 6.0],
[3.0, 2.5, 0.0, 5.0, 6.0, 5.5],
[6.0, 5.5, 5.0, 0.0, 1.5, 3.0],
[7.0, 6.5, 6.0, 1.5, 0.0, 2.5],
[6.0, 6.0, 5.5, 3.0, 2.5, 0.0],
]
)
def normalized_stress(dissim, coords):
observed = squareform(dissim, checks=False) # upper triangle as a vector
fitted = pdist(coords) # map distances, same order
return float(np.sqrt(((observed - fitted) ** 2).sum() / (fitted ** 2).sum()))
for k in (1, 2, 3):
mds = MDS(n_components=k, dissimilarity="precomputed", n_init=8, random_state=0)
coords = mds.fit_transform(dissimilarity)
print(f"{k} dimension(s): stress = {normalized_stress(dissimilarity, coords):.3f}")Read the three values as an elbow curve. Stress always falls as you add dimensions, so the question is where the drop stops being worth it. A large fall from one to two dimensions and a small fall from two to three supports a two-dimensional map. With very few brands, the last step will approach zero for trivial reasons, because there are barely more points than dimensions. This is why MDS needs more brands than dimensions. Roughly eight or more brands is a safer base for a two-dimensional solution.
Kruskal's old rule of thumb reads stress of about 0.20 as poor, 0.10 as fair, 0.05 as good, and 0.025 as excellent. It was devised for nonmetric MDS, and results depend on the number of points. Use it as a rough guide, not a pass mark.
Local minima
MDS optimizes by iteration and can settle in a poor solution depending on its starting layout. The n_init argument restarts the fit several times and keeps the best result. If stress changes noticeably between seeds, increase n_init and check whether the map layout is the same up to rotation.
Stability: would another sample give the same map?
A map built from 120 respondents is one draw from the customers you could have asked. The standard check is a bootstrap. Resample respondents with replacement, rebuild the map each time, and see how far each brand moves.
One complication matters here. PCA and MDS axes have arbitrary sign and rotation. Two equivalent maps can look mirrored, so a bootstrap map must be aligned to the reference map before you measure movement. Orthogonal Procrustes rotation (which also allows flips) does this.
The respondent data below is simulated, so the example runs without a file. Replace it with your own array of shape (respondents, brands, attributes).
import numpy as np
import pandas as pd
from scipy.linalg import orthogonal_procrustes
from sklearn.decomposition import PCA
from sklearn.preprocessing import StandardScaler
rng = np.random.default_rng(42)
brands = ["Brand A", "Brand B", "Brand C", "Brand D", "Brand E"]
means = np.array(
[
[6.1, 2.0, 3.2, 5.0],
[5.4, 3.1, 5.9, 3.3],
[2.3, 6.4, 5.1, 5.6],
[3.0, 5.8, 2.5, 6.0],
[4.2, 4.0, 4.4, 4.1],
]
)
n_resp = 120
data = np.clip(means + rng.normal(0, 1.2, size=(n_resp, 5, 4)), 1, 7)
def map_from(sample):
brand_means = sample.mean(axis=0)
scaled = StandardScaler().fit_transform(brand_means)
return PCA(n_components=2).fit_transform(scaled)
reference = map_from(data)
scale = np.linalg.norm(reference, axis=1).mean() # typical distance from centre
moves = []
for _ in range(500):
resample = data[rng.integers(0, n_resp, n_resp)]
boot = map_from(resample)
rotation, _ = orthogonal_procrustes(boot, reference)
aligned = boot @ rotation
moves.append(np.linalg.norm(aligned - reference, axis=1))
moves = np.array(moves) # shape (500, 5)
report = pd.DataFrame(
{
"mean_move": moves.mean(axis=0),
"p95_move": np.percentile(moves, 95, axis=0),
},
index=brands,
)
report["p95_vs_scale"] = report["p95_move"] / scale
print(report.round(2))The p95_move column says that in 95% of resamples a brand stayed within that distance of its reference position. Dividing by the map's typical radius gives a relative figure. If a brand's 95th-percentile movement is larger than the gap between it and its nearest rival, you can't claim the two are separate. The same holds for a "gap" in the map that is smaller than the movement.
Other perturbations answer different questions:
- Split-half: build maps from two random halves of respondents and align them. Close agreement suggests the structure is not an accident of a few people.
- Drop one competitor: remove each brand in turn and rebuild. If the axes or other brands shift a lot, one brand is driving the whole solution.
- Drop one attribute: remove each attribute in turn. If an axis disappears, the axis depended on that single question.
Summary of the checks
| Check | Applies to | What it tells you | Warning sign |
|---|---|---|---|
| Cumulative explained variance | PCA | Share of rating variation kept in two dimensions | Low total, or PC3 close to PC2 |
| Brand-level quality | PCA | Which brands are poorly represented | A brand with a low share in two dimensions |
| Normalized stress | MDS | Mismatch between map distances and judgments | High stress, no elbow at two dimensions |
| Restarts (`n_init`) | MDS | Whether the optimizer found a stable solution | Stress or layout differs between seeds |
| Bootstrap movement | Both | Sampling uncertainty of each brand position | Movement larger than gaps between brands |
| Drop-one tests | Both | Dependence on one brand or attribute | Axes or positions change sharply |
Exercises
Exercise
A PCA map shows Brand C and Brand D close together. Brand C's sharein2d is 0.95 and Brand D's is 0.40. How should you treat the apparent closeness?
Show answer
Treat it with caution. Brand D loses 60% of its position outside the two displayed dimensions, so it may be far from Brand C in a dimension the map does not show. Check the third component, or compare their original ratings, before concluding they compete directly.
Exercise
A bootstrap shows that Brand E's 95th-percentile movement is 1.1 map units. The distance from Brand E to the nearest brand is 0.7 units. What can you conclude, and what would you do next?
Show answer
Brand E's position is not precise enough to separate it from its neighbour, since sampling noise exceeds the gap. Do not claim a distinct position. Collect more respondents, or report the two brands as one cluster, and rerun the bootstrap.