ECON 310 · Econometrics I

Choosing Which Variables to Include

Learn how to decide what goes into a regression, and why leaving out and piling in variables both cause trouble.

Key takeaways

  • Start with what question you are answering, because prediction and cause-and-effect call for different choices.
  • Leaving out a variable that matters and is tied to your key variable biases your result.
  • Adding variables that do not matter wastes information and rarely helps; adding the wrong kind can hurt.
  • R² never falls when you add a variable, so it cannot tell you whether the variable belongs; adjusted R² can.
  • Pick variables with theory before you look at results, and test the choice on data the model has not seen.

Meet Lena, who wants to explain house prices in her town. She has a spreadsheet with forty columns: square footage, bedrooms, lot size, year built, distance to the school, the color of the front door, the mayor's birthday, and on and on. Her first instinct is to toss everything into the regression and let the computer sort it out. Her second instinct, after reading about how a bigger model always has a higher R², is to keep adding.

Both instincts lead somewhere bad. A regression is not a bucket where more is better. Every variable you include or leave out is a choice, and the choice changes what your coefficients mean. This lesson gives you a way to decide: first think about what you want to learn, then check the choice with evidence. We will see that there are two ways to go wrong (too few variables, too many) and a third, sneakier way (the wrong kind of variable).

Step one: what is the question?

Lena could be asking two different things.

A prediction question: "Given a house's features, what will it sell for?" Here you want the model that predicts best. A variable is useful if it improves predictions, whether or not it "causes" prices. A feature like "number of fireplaces" may just signal a fancier house and still help.

A cause question: "If a new park opens next door, how much does the price change, holding other things fixed?" Now you care about one coefficient, the one on the park, and you choose the other variables to make that one coefficient trustworthy. Here a variable's role matters a lot, not merely whether it improves fit.

Most of the trouble in this lesson shows up in the second case. If your goal is only forecasting, see the forecasting lesson.

Too few: leaving out what matters

Suppose park distance and house size are both related to price, and bigger houses are built near parks. If Lena leaves size out, the regression gives the park the credit that belongs to size. The coefficient on the park is biased: it is too high because it is partly picking up the size effect. This is omitted variable bias, covered in depth in its own lesson. The bias happens when the left-out variable (1) affects the outcome and (2) is related to the variable you care about.

The message: include variables that influence the outcome and are tied to your key variable. These are called confounders, and they are the first priority.

Too many: adding what does not matter

Suppose Lena adds a variable that really has nothing to do with price, like the front door color coded as a number. Three things happen.

  • A little more noise. The model spends a degree of freedom estimating the useless coefficient, which slightly raises the standard errors of everything else. Results get a bit less precise, though not biased.
  • A false alarm risk. With enough useless variables, a few will look significant by luck. At a 5% cutoff, about 1 in 20 useless variables will pass.
  • Overfitting. The model starts to memorize quirks of this one dataset. It fits the sample beautifully and predicts new houses badly.

Adding lots of variables that are strongly related to one another causes a separate trouble, covered in the multicollinearity lesson: individual coefficients become unstable.

The wrong kind: variables your key variable causes

This one surprises people. Some variables should stay out even though they are related to both the outcome and the key variable. The classic case is a mediator: something that sits on the path from your key variable to the outcome.

Suppose you want the effect of years of education on wages. Education leads people into certain occupations (engineer, nurse), and those occupations pay well. Occupation is partly how education raises wages. If you control for occupation, you compare people with the same occupation but different education, and you wipe out the part of education's effect that works through the occupation. Made-up numbers show the pattern: without occupation, an extra year of school goes with 8% higher pay; with it, only 5%. The 5% answers "the effect of schooling inside a given job," which is a real question but not the same one as "the full effect of schooling."

The rule of thumb: control for things that come before your key variable and affect both it and the outcome. Be careful with things that come after it, since they may be part of the effect you want to measure.

Should this variable go in?
Include it Leaving it out biases the coefficient on X. Include it if you can It sharpens the estimate with smaller standard errors. Usually leave it out It carries part of X's effect, so controlling hides that part. Leave it out It adds noise and uses a degree of freedom. Hits Y, ties to X Hits Y only X causes it No link to Y Should variable Z go in the model? Ask how Z relates to X (your key variable) and Y (the outcome). Should variable Z go in the model? Ask how Z relates to X (your key variable) and Y (the outcome). Hits Y, ties to X: Include it Leaving it out biases the coefficient on X. Hits Y only: Include it if you can It sharpens the estimate with smaller standard errors. X causes it: Usually leave it out It carries part of X's effect, so controlling hides that part. No link to Y: Leave it out It adds noise and uses a degree of freedom.

A rough guide for a cause question. Theory about how the world works settles the cases the data cannot.

Does R² help? Not by itself

You learned in the R-squared lesson that R² measures how much of the variation your model explains. The trouble: R² can never fall when you add a variable, even a useless one. At worst the new coefficient comes out zero and R² stays put; usually it ticks up a hair. So choosing the model with the biggest R² always picks the biggest model.

Adjusted R² fixes this by charging a penalty for each extra variable. The formula is:

Adjusted R² = 1 − (1 − R²) × (n − 1) ÷ (n − k − 1)

Here n is the number of observations and k is the number of slope variables. A new variable raises adjusted R² only if it improves fit by more than the penalty.

A worked comparison

Lena has n = 50 houses. Model A uses k = 2 variables (size and distance to school) and has R² = 0.60. Model B adds four more variables, so k = 6, and has R² = 0.62.

Model A: (1 − 0.60) = 0.40. Then 0.40 × 49 ÷ 47 = 19.6 ÷ 47 ≈ 0.4170. Adjusted R² = 1 − 0.4170 = 0.583.

Model B: (1 − 0.62) = 0.38. Then 0.38 × 49 ÷ 43 = 18.62 ÷ 43 ≈ 0.4330. Adjusted R² = 1 − 0.4330 = 0.567.

Ordinary R² rose from 0.60 to 0.62, but adjusted R² fell from 0.583 to 0.567. The four extra variables added a sliver of fit and a bigger penalty, so Model A wins.

R² rises, adjusted R² falls
R², Model A (2 variables) 0.6 R², Model B (6 variables) 0.62 Adjusted R², Model A 0.58 Adjusted R², Model B 0.57 R², Model A (2 variables) 0.6 R², Model B (6 variables) 0.62 Adjusted R², Model A 0.58 Adjusted R², Model B 0.57

Hypothetical example: the numbers are made up to show the method, not a quote or an average.

You can also test a block of extra variables directly with an F test, as in the F test lesson. Other scorecards, called information criteria (AIC and BIC are the common ones), also penalize size; lower values are better. They are worth knowing by name, and your software prints them.

Check on fresh data

The surest guard against overfitting is to test the model on data it has not seen. Hold out a share of your observations, say 20%, fit the model on the other 80%, and check how well it predicts the held-out houses. A model that fits the 80% great and the 20% badly has memorized rather than learned. The simpler model often wins on fresh data.

A sensible recipe

  1. Write down the question and which coefficient (if any) you most care about.
  2. List what theory says matters. What affects the outcome? What affects your key variable? Include the confounders.
  3. Exclude mediators and other consequences of your key variable, unless you deliberately want their pathway removed.
  4. Fit the model and look at both the coefficients and the residual checks in the residuals lesson.
  5. Test variations lightly, and report them. If your main coefficient swings wildly when you add or remove a control, say so; that fragility is itself a finding.

Back to Lena. Her question is about the new park, so she asks what else drives both park proximity and price. House size and neighborhood qualify, so they go in. The sale month matters for prices, so it goes in too. The "fresh paint" score, assigned by the real estate agent after seeing a high offer, is a consequence of the price, not a cause, so it stays out. The door color, which has no plausible link, stays out. That leaves a short model she can explain to a neighbor in two sentences, which is a good test of any choice.

Common mistakes

Letting stars choose the model. Dropping every variable with a t below 2 and keeping the rest is called stepwise-by-t-test, and it produces overconfident results. The survivors look better than they are because you selected them for looking good. The sample of fits you did not report is invisible, but it exists.

Controlling for everything. The urge to "control for all we can" feels careful, yet it can include mediators and make results worse.

Treating a good fit as proof. A high R² with a theoretically odd variable set is a warning, not a reward. Fit is not truth.

Ignoring the data's limits. With 20 observations, a model with 15 variables has almost nothing left over to estimate noise with. Keep k small relative to n.

Words to know

Confounder a variable that affects both your key variable and the outcome, and should usually be included.

Mediator a variable on the path between your key variable and the outcome, often best left out.

Overfitting building a model so tailored to one sample that it predicts new data poorly.

Adjusted R² a version of R² that penalizes each extra variable.

Information criterion a score, such as AIC or BIC, that rewards fit and penalizes model size.

Hold-out sample data kept aside to test a model's predictions.

Degrees of freedom observations minus coefficients estimated, which shrinks as you add variables.

Check yourself

  1. Name two situations that lead to different variable choices: a prediction goal and a cause goal. How does the goal change the choice?
  2. Explain why R² can never go down when you add a variable.
  3. Compute adjusted R² for a model with n = 40, k = 3 and R² = 0.50.
  4. Model X (k = 3) has R² = 0.50 with n = 40. Model Y adds two variables (k = 5) and has R² = 0.51. Using adjusted R², which is better?
  5. A researcher studying the effect of schooling on wages controls for the worker's current occupation. Why might this understate the effect of schooling?
  6. Why is it risky to drop all variables with small t statistics and then report the survivors?
Show the answers
  1. A prediction goal keeps whatever improves forecasts; a cause goal keeps confounders and excludes mediators so one key coefficient is trustworthy.
  2. At worst the new variable gets a coefficient of zero and the squared errors stay the same, so R² cannot fall.
  3. (1 − 0.50) × 39 ÷ 36 = 0.50 × 1.0833 = 0.5417, so adjusted R² = 1 − 0.5417 = 0.458.
  4. Y: 0.49 × 39 ÷ 34 = 19.11 ÷ 34 ≈ 0.5621, so adjusted R² ≈ 0.438. That is below X's 0.458, so Model X is better.
  5. Occupation is partly a result of schooling, so controlling for it removes the part of the effect that works through better jobs.
  6. The survivors were selected for looking significant, so their results look stronger than they really are and some will be luck.

A free self-study program written for 4Economics with AI writing tools and not reviewed line by line by a person. It is not an accredited degree and awards no credit. Check anything you rely on against a textbook or primary source. Report an error.

In this unit: Multiple regression

  1. Multiple Regression and Holding Things ConstantMultiple regression adds more predictors so each slope shows the link between x and y with the other variables held fixed.10 min
  2. Omitted Variable BiasLeaving out a variable that affects the outcome and relates to your predictor makes the slope wrong. Learn the size and direction of the error.10 min
  3. Testing Several Coefficients: The F TestLearn how the F test checks whether a group of regression variables matters together, even when each one looks weak alone.11 min
  4. Dummy VariablesSee how 0-or-1 variables let a regression handle categories like seasons or yes-or-no features, and how to avoid the dummy trap.11 min
  5. Interaction TermsLearn how multiplying two variables lets a regression say that the effect of one thing depends on the level of another.10 min
  6. Logs, Squares and Functional FormLearn how squares and logarithms let a straight-line regression fit curves, and how to read the coefficients in each form.10 min
  7. Choosing Which Variables to IncludeLearn how to decide what goes into a regression, and why leaving out and piling in variables both cause trouble.10 min

In the news