Understand the idea
When predictors are highly correlated with each other, ordinary regression's coefficients become unstable: a tiny change in the data can swing the estimated effects wildly, because the model cannot cleanly tell apart what each correlated predictor is individually contributing. PCR sidesteps this in two steps: first, compress the predictors into a handful of new, completely uncorrelated 'components' (the same technique as PCA), ordered by how much of the predictors' own spread each one captures; second, run an ordinary regression of the outcome on just the TOP FEW components instead of on all the original, correlated predictors.
How many components to keep is decided by checking, via cross-validation, which count actually predicts new data best, not by which count fits the training data best (keeping every single component just reproduces ordinary regression, defeating the whole purpose). The classic pattern: as you add more components, out-of-sample error typically drops, bottoms out, and then rises again as later components add more noise than signal. The bottom of that curve is where you want to stop.
One thing worth knowing up front: PCA, which builds the components, never looks at the outcome at all; it only looks at how much the PREDICTORS vary among themselves. That means the component capturing the most predictor variance is not guaranteed to be the component most related to the outcome you actually care about predicting. This is exactly the gap Partial Least Squares (PLS) is designed to close by building components that account for both predictor AND outcome variation together.
Practitioner explanation
KernelStats standardizes predictors (so PCA effectively runs on the correlation matrix, preventing a large-unit predictor from dominating the component directions), builds all min(p, n-1) principal components, and sweeps k=1,2,... choosing the component count via 5-fold cross-validation (seeded, reproducible) on RMSE; the k minimizing CV RMSE is kept by default, with a manual override available. Although the regression is fit entirely in component space, coefficients are BACK-TRANSFORMED through the loadings to recover ordinary per-predictor coefficients on the raw measurement scale, so the card can still report 'a one-unit rise in X_j changes y-hat by beta_j' in familiar, interpretable units despite the underlying fit living in a rotated space.
The product states directly and specifically that PCR is NOT feature selection: it keeps ALL predictors, blended together into components, and never zeroes any single predictor out the way lasso does; for sparse variable selection, lasso (or elastic net) is the correct tool, not PCR. Similarly, there are NO classical p-values for the back-transformed coefficients: like ridge and lasso, this is a cross-validated, shrinkage-flavored fit, and the cross-validation RMSE curve itself is the evidence for the model's quality, not a per-coefficient significance test.
The critical distinction from Partial Least Squares (PLS) is stated as the single thing to remember: PCA/PCR chooses component directions using ONLY the predictors, completely blind to the outcome y, so the highest-variance direction found is not guaranteed to be the direction most related to y. PLS builds components that account for BOTH predictor and outcome variation simultaneously and typically needs fewer components as a result; the product recommends reaching for PLS specifically when prediction is the goal, and treating PCR as the simpler, purely variance-driven story when the compression itself (rather than maximum predictive power) is the point.
When to use it
Consider it when
Predictors are numerous and/or highly correlated with each other, causing ordinary least squares to become unstable, and compressing them into a few uncorrelated components while retaining interpretable per-predictor coefficients (via back-transformation) is acceptable.
Use caution when
You need sparse feature selection (PCR keeps every predictor, blended into components; use lasso instead), prediction accuracy is the primary goal and PLS's outcome-aware components would likely need fewer components for the same performance, or you need classical p-values on individual coefficients, which this cross-validated approach does not provide.
Formulas and symbols
Principal components regression model
Z_m the m-th principal component score, p_m its loading vector; k chosen by cross-validation.
Back-transformed raw-scale coefficient
Component-space coefficients multiplied back through the PCA loadings and unstandardized, recovering an interpretable per-predictor effect.
Cross-validated component count selection
5-fold cross-validation (seeded) sweeping k=1,2,...,max; keeping every component reproduces ordinary least squares.
Assumptions and checks
- PCR's PCA step assumes predictors are on comparable scales; without standardizing first, the components would be dominated by whichever raw predictor happens to have the largest variance, rather than reflecting genuine shared structure.
In KernelStats: Checked directly: the card confirms predictors were z-scored before PCA, so this is enforced by construction rather than left to the analyst.
- No (severe) multicollinearity. If the retained components still leave much of the original correlation structure unaddressed, correlated predictors can still destabilize the reconstructed coefficients on the original scale.
In KernelStats: Checked directly: the number of orthogonal components retained is reported, and the card flags the degenerate case where every component was kept (all p of them), in which case PCR is numerically identical to ordinary least squares and provides no protection against collinearity at all.
- PCA chooses components purely to explain variance in the PREDICTORS, with no regard to which components actually relate to the outcome; a component that captures a lot of predictor variance but has nothing to do with the response can still be retained ahead of a more predictive one, unlike PLS.
In KernelStats: Not checked by KernelStats: the components are selected before the outcome is considered at all; compare against Partial Least Squares Regression (which steers components toward the outcome directly) if predictive components are the priority.
Alternatives
- Partial Least Squares Regression. Maximizing predictive accuracy is the goal: PLS builds components using both predictor AND outcome variation, typically needing fewer components than PCR for comparable or better performance.
- Ridge Regression. You want to stabilize coefficients under multicollinearity without any dimensionality compression step, keeping the fit directly in the original predictor space.
- Lasso Regression. The goal is sparse feature selection (zeroing out unhelpful predictors) rather than compressing all of them into components.
Worked example
Scenario
Predicting penguin body mass from three correlated measurements (bill length, bill depth, flipper length), with the component count chosen by 5-fold cross-validation (seed 42).
Result
The components explain 66.8%, 25.6% and 7.7% of predictor variance, but cross-validated RMSE is 475 g with one component, 471 g with two and 392 g with all three, so cross-validation keeps all three; R-squared = 0.76 and the back-transformed flipper-length coefficient is +50.3 g per mm. The card flags 'Dimension reduction active' as failed: with every component kept, PCR equals ordinary least squares.
Interpretation
The smallest component, carrying under 8% of the predictors' variance, is the one that predicts body mass best, a live demonstration that PCA ranks directions by predictor variance, blind to the outcome. Here PCR offers no compression; Partial Least Squares Regression, whose components are built with the outcome in view, or plain linear regression is the better choice.
Dataset: penguins.csv
Common misconceptions
Misconception
The first principal component is always the direction most predictive of the outcome.
Correction
PCA builds components using ONLY the predictors' own variance structure: it never looks at the outcome at all. The highest-variance direction among the predictors is not guaranteed to be the direction most related to y; this is exactly the gap Partial Least Squares closes by building components that account for outcome variation as well.
Misconception
PCR performs feature selection by identifying which predictors matter most.
Correction
PCR selects DIRECTIONS (principal components), each one a blend of every original predictor: it never zeroes out any single predictor and keeps all of them represented in the fitted components. For genuine sparse feature selection, where some predictors are dropped entirely, lasso or elastic net are the appropriate tools, not PCR.
References
- An Introduction to Statistical Learning with Applications in R (2nd ed.), Section 6.3, James, G., Witten, D., Hastie, T. and Tibshirani, R. (2021).
- The Elements of Statistical Learning, Section 3.5, Hastie, T., Tibshirani, R. and Friedman, J. (2009).
