Best subsets regression: choosing predictors with Mallows' Cp

Updated

Best subsets regression fits a regression model for every combination of your candidate predictors and lists the best few of each size, so you can see which inputs earn their place before you settle on one model. It does not pick the final model for you. It gives you a short list, with statistics such as adjusted R² and Mallows' Cp, to choose from with engineering judgment.

When to use it

  • You have five to fifteen candidate predictors, often from historical process records, and do not know which ones matter.
  • Several predictors are related to each other, and you want to see which one of a related group works best.
  • You want a check on stepwise regression, which adds or removes one term at a time and can miss a good combination.
  • You want a small model that predicts nearly as well as the full one, because every predictor in the model is one more thing to control and measure.

With k candidates there are 2ᵏ − 1 models, so the method suits a modest number of predictors. With dozens of correlated predictors, look at partial least squares instead.

How it works

For each model size (1 predictor, 2 predictors, and so on), the method fits every combination by least squares, as in regression analysis, and keeps the one or two with the highest R². For each, it reports:

  • R²: the share of variation explained. It always rises with more terms, so use it only to compare models of the same size.
  • R²(adj): R² penalized for the number of terms. It can fall when a term adds little.
  • R²(pred): how well the model predicts each row when that row is left out of the fit. It exposes overfitting.
  • S: the standard deviation of the residuals, in the response's units.
  • Mallows' Cp: compares the model's error with the error of the full model, which serves as the estimate of pure noise:
Cp = SSEₚ / MSE(full) − (n − 2p)

Here SSEₚ is the error sum of squares of the candidate model, p the number of its coefficients including the constant, and MSE(full) the mean square error of the model with all predictors. A model that leaves out nothing important has Cp close to p. A Cp far above p means the model is biased: it misses a term that matters. The full model always has Cp = p exactly, so Cp cannot judge it.

Example

A molding cell has 20 runs of process records for a polypropylene cover, with five candidate predictors and the measured warpage (mm):

RunMelt (°C)Mold (°C)Hold pressure (MPa)Hold time (s)Cooling (s)Warpage (mm)
121645512.7251.92
222160583.7241.79
323565643.4152.01
421440693.9172.10
520945865.2151.90
623475784.0211.41
721845644.0112.29
821445512.8112.54
923380563.5161.84
1023365904.9141.63
1123255684.5231.87
1222960784.8211.71
1322965522.8182.15
1422650513.2202.12
1522545845.6201.77
1623470745.3221.47
1723665622.6241.79
1823660634.1122.35
1923875543.3191.79
2022560573.2122.16

In these records melt and mold temperature move together (correlation 0.82), and so do hold pressure and hold time (0.87), because operators tend to change them as a pair. The best two models of each size:

VarsPredictorsR² (%)R²(adj) (%)R²(pred) (%)CpS (mm)
1Cooling40.136.825.6137.10.2285
1Hold pressure30.726.916.3161.10.2457
2Hold pressure, Cooling71.568.261.758.70.1620
2Hold time, Cooling61.557.048.884.30.1884
3Mold, Hold pressure, Cooling92.491.088.67.40.0862
3Mold, Hold time, Cooling84.581.576.727.70.1234
4Melt, Mold, Hold pressure, Cooling94.593.089.84.10.0759
4Mold, Hold pressure, Hold time, Cooling92.490.486.29.40.0890
5All five94.592.688.46.00.0783
Adjusted and predicted R² of the best model of each size406080PercentR²(adj)R²(pred)12345Number of predictors
Adjusted and predicted R² of the best model of each size

The four-predictor model with melt temperature, mold temperature, hold pressure and cooling time stands out: it has the highest adjusted and predicted R², the smallest S, and Cp = 4.1, close to its p = 5. Fitted on its own, it gives:

Warpage = 2.536 + 0.00845·Melt − 0.01634·Mold − 0.01372·Hold pressure − 0.03705·Cooling

All four terms have p-values below 0.05 (melt temperature is the weakest, at 0.031), and the VIFs of melt and mold temperature are about 3.2 because of their correlation. The AICc and BIC criteria described in regression analysis point to the same model.

How to read the results

  • Look for the elbow. R²(adj) climbs steeply up to three predictors, then barely moves. A model past the elbow buys little prediction for an extra input to control.
  • Compare Cp with p. The three-predictor model has Cp = 7.4 against p = 4, a sign that it leaves out something real (melt temperature). The four-predictor model's 4.1 is close to its 5.
  • Read pairs of similar models. Hold pressure and hold time compete for the same slot: once hold pressure is in, hold time adds nothing (compare the two four-predictor rows). The data cannot fully separate them, so confirm which one acts with an experiment.
  • Prefer R²(pred) to R²(adj) when they disagree. The full model's R²(adj) is close to the best, but its R²(pred) drops, a typical sign of a term that fits noise.
  • Refit and check the chosen model. Best subsets does not show residual plots. Fit the model you picked with regression analysis and look at its residuals.

Common mistakes

  • Taking the top row as the answer. Two models a hair apart in R² can differ greatly in cost and in sense. Choose among the close ones with process knowledge.
  • Judging the full model by Cp. Its Cp always equals p, by construction.
  • Feeding in too many candidates for the data. With 20 rows and 15 candidates, some combination will fit noise well by chance.
  • Reading cause from records. Melt temperature earns its place here, but it moves with mold temperature in these records. Only a designed experiment can separate them with confidence.

Frequently asked questions

What is a good Mallows' Cp?

A value close to p, the number of coefficients including the constant, and preferably small. A Cp much larger than p means the model misses an important term. A Cp below p is usually just random variation.

Is best subsets better than stepwise regression?

It looks at every combination, so it cannot miss the best model of each size the way stepwise can. Stepwise is faster with many predictors. Many engineers run both and look at where they agree.

Can best subsets handle squared terms or interactions?

Yes, if you add them as candidate columns. Keep the hierarchy in mind: a model with a squared term should also contain the linear term.

Why does a coefficient change from one model to another?

Correlated predictors share credit. Here mold temperature's coefficient is −0.0126 mm/°C on its own and −0.0163 mm/°C in the four-predictor model, because melt temperature, which rises with mold temperature in these records, pushes warpage the other way. Compare coefficients only within the model you chose.

Try it with your own data

StatLab SPC is free, open-source statistics for engineers. It runs in your browser, works offline, and never uploads your data.

Open StatLab