Dummy variables and interaction terms

Dummy variables and interaction terms

Published September 28, 2026

Dummy variables and interaction terms

On this page

Learning Outcome Statement

Formulate and interpret a multiple regression model that includes qualitative independent variables.

On the exam: You get a regression vignette with coefficient estimates, dummy coding, and a specified independent-variable value, then choose the correctly formulated model, predicted value, slope, or category difference in an item set or MCQ.

Suppose a hiring analyst wants salary to reflect both experience and an MBA. The outcome, $Y$, is annual salary measured in USD per year. Experience, $X$, is measured in years, and the qualitative category indicator, $D$, is $1$ for an employee with an MBA and $0$ for the non-MBA base category. The sample is cross-sectional, and the interaction lets the MBA change both starting salary and the experience slope.

TermMeaning and unit
$b_0$Base-category intercept, USD per year
$b_1$Base-category slope, USD per year per year of experience
$b_2$Category intercept shift, USD per year
$b_3$Category slope shift, USD per year per year of experience
$e$Unexplained component, USD per year

The product $XD$ is the interaction, measured in years because $D$ is dimensionless. For a fitted value, $\hat Y$ is predicted annual salary, so $e$ is omitted.

$$ Y=b_0+b_1X+b_2D+b_3XD+e $$

Read the equation as a base line plus category shifts. The term $b_0$ starts the base-category prediction at $X=0$, and $b_1X$ moves it with experience. The term $b_2D$ shifts the intercept for the category of interest, while $b_3XD$ changes its slope. When $X$ equals $0$, $b_2$ is the category difference. When $D=0$, the intercept is $b_0$ and the slope is $b_1$. When $D=1$, the intercept is $b_0+b_2$ and the slope is $b_1+b_3$. A positive active term raises predicted salary, and a negative active term lowers it. If $b_3$ is nonzero, the category effect depends on $X$, so calculate the category-of-interest minus base-category difference as $b_2+b_3X$ at the specified $X$.

To test coefficient significance, use $H_0$: coefficient equals $0$ versus $H_A$: coefficient does not equal $0$, using the stated tail convention. Statistical significance concerns evidence against the zero coefficient. Economic significance comes from the size of the predicted salary difference.

Use this sequence when the question asks you to formulate or interpret the model.

Loading diagram…

The flow separates model setup from interpretation, which helps prevent a common substitution error. Choose the non-MBA group as the reference, then activate the MBA terms only when $D=1$. At the specified experience, calculate the fitted value and compare the two groups using both the intercept shift and the slope shift. The lines therefore share the same coding but can have different starting points and slopes.

Worked example

You are handed a sample, cross-sectional regression of annual salary measured in USD per year on experience measured in years and MBA status. The base category is non-MBA. The employee has an MBA and $5$ years of experience. The exam asks for predicted salary, the MBA experience slope, and the MBA category difference at $5$ years.

GivenValue
$b_0$USD 50,000 per year
$b_1$USD 3,000 per year per year of experience
$b_2$USD 12,000 per year
$b_3$USD 1,000 per year per year of experience
$X$5 years
$D$1 for MBA
Base categoryNon-MBA

The first line is the non-MBA base category, and the second line is the MBA category. Compare the values at each experience level to see both effects of the interaction: the MBA line starts USD 12,000 higher at zero experience, then rises USD 1,000 more for each additional year. At five years, that accumulated slope shift makes the category difference USD 17,000, while the fitted MBA salary is USD 82,000 per year. The chart gives the pattern; the values below make the comparisons precise.

Loading diagram…
Experience (years)Non-MBA salaryMBA salary
0USD 50,000USD 62,000
5USD 65,000USD 82,000
10USD 80,000USD 102,000
  1. Create the interaction. Multiply experience by the dummy because the MBA-specific slope shift is active only for the MBA employee. The product is $XD=5\times1=5.00$ years.
  2. Build the base prediction first. This isolates the non-MBA line. The result is $b_0+b_1X=50{,}000+3{,}000\times5=65{,}000$ USD per year.
  3. Calculate the category adjustment. The dummy activates both shifts. The result is $b_2D+b_3XD=12{,}000\times1+1{,}000\times5.00=17{,}000$ USD per year.
  4. Add the base prediction and category adjustment. The fitted salary is $65{,}000+17{,}000=82{,}000$ USD per year.
  5. Read the MBA slope. Because $D=1$, the slope is $b_1+b_3=3{,}000+1{,}000=4{,}000$ USD per year per year of experience.

The model predicts USD 82,000 per year for the MBA employee, an estimated USD 17,000 per year difference versus the non-MBA employee with the same experience.

Changed condition

You keep every coefficient and coding rule unchanged but change only experience. The employee now has $8$ years, and you need to predict how the fitted MBA salary and category difference move.

QuantityOriginalChanged
Experience, $X$5 years8 years
Predicted MBA salaryUSD 82,000 per yearUSD 94,000 per year
MBA category differenceUSD 17,000 per yearUSD 20,000 per year

The prediction before calculating is straightforward. Moving $X$ from $5$ to $8$ years raises MBA salary because its slope is USD 4,000 per year of experience. The category difference widens from USD 17,000 to USD 20,000 because $b_3$ adds USD 1,000 per experience year. Before reading on, compute the base-category salary at $8$ years.

Common error

A candidate reads $b_2$ beside $D$ and calls it the unconditional category premium. That feels right because $b_2D$ is the visible category term. A nonzero $b_3$, or a request for the category effect at a specified experience level, gives it away, so calculate $b_2+b_3X$ instead.

Calculator

Enter the base prediction and the category adjustment separately, then add them.

KeysDisplay
50000 + (3000 x 5) =65,000
STO 165,000
12000 + (1000 x 5) =17,000
RCL 1 + 17000 =82,000

Check yourself

Practice

A sample cross-sectional regression predicts annual salary in USD per year from experience in years and MBA status. The non-MBA employee is the base category. The model uses D=1 for MBA and D=0 for non-MBA. Estimated coefficients are b_0 of USD 50,000 per year, b_1 of USD 3,000 per year per year of experience, b_2 of USD 12,000 per year, and b_3 of USD 1,000 per year per year of experience. The employee has X=5 years and D=1.

Question 1

Which model correctly represents the salary relationship?

Question 2

What annual salary does the model predict for the employee?

Question 3

What experience slope does the model predict for the MBA employee?

Question 4

What is the MBA minus non-MBA category difference at 5 years of experience?

Which coding matches the stated base category and category of interest?

A coefficient is tested under the stated two-tailed convention. Which hypotheses are correct?

Revision snapshot

Code $D=1$ for the category of interest and $D=0$ for the base category. Use $Y=b_0+b_1X+b_2D+b_3XD+e$. $b_2$ is the category difference when $X$ equals $0$. When $D=0$, the intercept is $b_0$ and the slope is $b_1$. When $D=1$, the intercept is $b_0+b_2$ and the slope is $b_1+b_3$. If $b_3$ is nonzero, the qualitative-variable effect depends on $X$, so interpret $b_2+b_3X$ at the specified $X$. Test coefficient significance with $H_0$: coefficient equals $0$ versus $H_A$: coefficient does not equal $0$, using the stated tail convention. On exam, formulate the model, then calculate the requested value, slope, or category difference.

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: Dummy variables and interaction terms

  1. 1. Aster Quantitative Strategies is developing a systematic equity allocation model. The research team first models a monthly market valuation spread using the first-order autoregressive specification in Exhibit 1. The spread and intercept use the same units. The team treats the process as covariance stationary when the absolute value of the autoregressive coefficient is less than one and wants to estimate the level toward which the spread reverts over long horizons. A second team develops a machine-learning model that predicts next-month cross-sectional equity returns. The candidate predictors consist of accounting variables, price and volume measures, analyst language, and news sentiment. All predictors are standardized using parameters estimated within the applicable training sample. Because the number of predictors is large relative to the useful signal, the team considers lasso regression. Its objective function combines prediction error with an L1 penalty on coefficient magnitude. The team is willing to trade some in-sample fit for reduced variance and a more parsimonious model. It does not assume that regularization will correct time-series dependence or poor data quality. For portfolio-risk analysis, Aster generates 20,000 one-year price paths under geometric Brownian motion using a common set of estimated parameters. The team reports the fifth percentile of simulated portfolio returns as a lower-tail threshold. It separately considers calculating the average return among observations below that percentile. The news archive used to construct sentiment scores includes only companies still listed when the archive was extracted. Delisted and failed companies are absent even when their historical news was originally available. The team recognizes that this feature can create survivorship bias and make historical model performance appear stronger than performance obtainable in real time. Exhibit 2 summarizes the simulation, archive, and model-selection procedures.

    • 2. Summit Systematic Strategies is developing a monthly equity-market forecasting process. Quantitative analyst Noah Reed initially proposes using the logarithm of an equity index's price level as the dependent variable in a conventional regression. Because a nonstationary series can produce misleading significance and spurious relationships, the research director requires Reed to test both the log price level and its first difference. Exhibit 1 reports augmented Dickey–Fuller test results. For these tests, the null hypothesis is that the series has a unit root, and the firm uses a 5% significance level. Reed also estimates a first-order autoregressive model for monthly returns. Returns and the intercept in Exhibit 1 are expressed in decimal form in the model, although the most recent observation is displayed as a percentage. The innovation has a conditional expected value of zero. The director asks for a one-period point forecast based solely on the stated model and most recent return; no simulation adjustment or long-run mean estimate is required. The second phase of the project classifies whether the next month's index return will be positive. Reed considers a random forest and a simpler logistic regression. The available observations are ordered through time, and the model will be used prospectively. Exhibit 2 presents model accuracy and Reed's proposed validation method. The outcome classes are approximately balanced, and identical classification thresholds are used for both models. The random forest's hyperparameters were repeatedly adjusted to improve training accuracy. The director emphasizes that model selection should reflect performance on data unavailable during fitting rather than training accuracy alone. He also requires the validation design to preserve the information set that would have existed at each historical prediction date. Randomly moving future observations into the development sample would not satisfy that requirement. One candidate predictor is a macroeconomic series that is initially published shortly after month-end and subsequently revised. Reed's database contains only the final revised values, which were released two months after each associated prediction date. He proposes using those final values without reconstructing the real-time publication history. All security identifiers remain in the data regardless of whether the issuer later leaves the index, and the positive and negative outcome classes have similar frequencies. The director asks Reed to identify the principal bias created by the proposed macroeconomic feature.

      • 3. Atlas Systematic Strategies is developing a model to forecast daily returns on an exchange-traded fund and a separate classifier to identify issuers likely to experience financial distress. All observations have reliable event timestamps, but the raw vendor file contains both current security identifiers and historical identifiers. The research director requires the team to recreate the information set that would have existed at each forecast date. Before estimating the return model, the team tests the ETF price level, its first difference, and its daily return for stationarity. Exhibit 1 reports augmented Dickey–Fuller test results using a 5% significance level. The team is not testing for cointegration and intends to use a conventional model requiring stationary input series. An analyst proposes using the ETF price level without transformation because the series contains more intuitive economic information. Another analyst warns that unrelated nonstationary series can produce apparently significant but spurious relationships. The team then divides the return observations chronologically into training, validation, and final test samples. Three candidate models are fitted using identical predictors. Exhibit 2 reports training and validation root mean squared error; lower RMSE indicates better predictive performance. The final test sample has not been examined and will be used only once after the model is selected. The director instructs the team not to select a model based solely on its training error. For the distress project, distress is the positive class. Exhibit 3 presents results from a separate holdout sample. The investment application places particular importance on identifying issuers that actually become distressed, so the team examines recall as well as precision and overall accuracy. The data engineer also reviews controls for look-ahead and survivorship bias. She proposes retaining original release timestamps for alternative data, using security-universe membership as known on each historical date, fitting all scaling parameters only on the training sample, and preserving chronological order during validation. The team agrees that randomly shuffling time-dependent observations or using full-sample preprocessing statistics could transfer future information into model development.

        • 4. Ardent Quantitative Strategies is developing a monthly return-forecasting system. The research team first examines a candidate predictor, y, using an autoregressive model estimated in levels. Exhibit 1 reports the estimated lag coefficient and diagnostic tests. The team uses the Augmented Dickey–Fuller test to assess whether the predictor has a unit root. A failure to reject the test's null hypothesis is interpreted as evidence that the series should not be treated as covariance stationary without an appropriate transformation. After completing the time-series review, the team combines market, accounting, textual-sentiment, and macroeconomic variables. Exhibit 2 summarizes the resulting data-science project. Many of the 120 predictors are highly correlated because several vendors supply related measures of valuation, momentum, and investor sentiment. The portfolio manager believes that each predictor contains potentially useful information and asks the team to retain all predictors while reducing instability in their estimated coefficients. The current model achieves 98% accuracy in the training sample but only 61% accuracy in the validation sample. The team currently creates the validation sample by randomly selecting individual monthly observations across the full 2008–2024 period. A senior researcher objects that this approach can allow later market regimes to influence model choices applied to earlier periods. She proposes a validation design that repeatedly estimates the model using information available through a given date and tests it on subsequent observations. The project also uses macroeconomic series downloaded from a vendor's current database. Historical observations in that database incorporate revisions released months or years after the original announcements. The data do not include vintage dates showing which estimate was publicly available on each historical date. The intended backtest assumes that a portfolio is formed immediately after each original economic release. The chief risk officer asks the team to identify the most appropriate stationarity treatment, validation method, and regularization approach. He also asks it to classify the principal bias created by using revised macroeconomic values in a historical simulation. The model will be used for genuine out-of-sample forecasting, so procedures that merely improve in-sample fit without preserving the information set available at each decision date are unacceptable.

          • 5. Aster Peak Investments is developing a monthly asset-allocation model. The research team first analyzes a valuation spread defined as the log earnings yield of an equity index minus a long-term government bond yield. It estimates a first-order autoregressive model for the spread and wants to measure how rapidly a shock decays. The estimated coefficient and relevant significance result are reported in Exhibit 1. The team separately examines an equity index's price level and monthly return series. Augmented Dickey–Fuller tests include the deterministic terms selected by the research policy, and the null hypothesis for each test is that the series has a unit root. The team uses a 5% significance level. The chief investment officer requires stationary inputs unless the modeling method explicitly addresses nonstationarity. For return forecasting, analysts compare linear regression with a random forest. Prediction error is measured by root mean squared error, so lower values indicate better predictive performance. Because investment decisions occur sequentially, the validation method should reproduce the information set that would have existed at each forecast date. The team intends to reserve a final sample for a single unbiased assessment after model choice and hyperparameter tuning. Exhibit 2 describes departures from that intended process. Analysts repeatedly inspected the designated final test sample while selecting tree depth, number of predictors considered at each split, and minimum leaf size. They also reconstructed a historical predictor using financial statements that were restated after the corresponding forecast dates. The original statements were available in the archived database, but they were not used for this predictor. The research director asks whether the random forest's apparent validation advantage is reliable. She notes that model complexity alone does not establish superior out-of-sample performance and that a final test sample ceases to be independent when it influences model selection. Transaction costs and portfolio constraints are outside the scope of this model-comparison exercise.

            • 6. Northstar Analytics develops forecasting and classification models for an asset manager. Its first project examines monthly returns and price levels for a broad commodity index. The estimated models and selected diagnostics are presented in Exhibit 1. The innovations in each model have an estimated mean of zero. For the Return Model, the analyst treats the process as a covariance-stationary AR(1) model if the absolute value of its autoregressive coefficient is less than one. The analyst also checks whether residual autocorrelation remains after estimation. The Ljung–Box test has a null hypothesis that the tested residual autocorrelations are jointly zero. The Price Model produces a high R-squared, but the analyst recognizes that a high goodness-of-fit measure does not establish stationarity. The unit-root test fails to reject its null. Northstar therefore considers whether a transformation is required before using the series in predictive regressions or drawing conventional statistical inferences. The second project predicts corporate defaults using accounting, market, and macroeconomic variables observed monthly from 2012 through 2023. Because predictions will be used prospectively, Northstar proposes training on 2012–2020 data, validating hyperparameters on 2021 data, and reserving 2022–2023 as a final test period. Missing-value imputation and variable standardization must be estimated without using validation or test observations. Another analyst instead proposes randomly mixing all dates and standardizing the variables using the entire sample before splitting the data. The default model's final test-period classification results appear in Exhibit 2. A positive classification denotes a predicted default. The credit team is particularly interested in precision because investigating predicted defaults is costly, although it also monitors recall and overall accuracy. Northstar's governance policy requires that the final test set be evaluated only after model architecture, variables, and hyperparameters have been selected. Repeatedly using test results to modify the model would convert the test sample into another validation sample and overstate genuinely out-of-sample performance.

              • 7. Atlas Systematic Strategies is developing a model to forecast equity-sector returns and identify corporate defaults. The research director asks an independent model-validation team to review the project before it is implemented in client portfolios. The project combines market prices, accounting variables, macroeconomic releases, and unstructured text extracted from regulatory filings. All records are time stamped, but the validation team must determine whether each time stamp represents the date information became available or merely the date on which it was entered into the research database. One proposed predictor is an aggregate valuation ratio observed monthly. The research team estimates a first-order autoregressive model for the ratio. The estimated lag coefficient exceeds one, and a unit-root test fails to reject its null hypothesis. The team nevertheless uses the level series in predictive regressions, arguing that a high in-sample R-squared demonstrates usefulness. The validation team warns that regressions involving nonstationary variables can produce apparently significant relations that are spurious. It recommends transforming the series appropriately and reassessing stationarity before using it in the forecasting model. For its machine-learning model, Atlas partitions the observations chronologically into training, validation, and test sets. Analysts estimate parameters with the training observations. During model development, however, they repeatedly compare alternative hyperparameter combinations using test-set accuracy and select the combination with the highest result. They then report the same test-set accuracy to prospective clients as an unbiased estimate of out-of-sample performance. The default classifier is trained on a data set in which defaults are rare. A model that classifies almost all issuers as nondefault generates high overall accuracy but identifies few actual defaults. Because failing to identify a default is particularly costly, the validation team focuses on performance measures that separately assess the proportion of predicted defaults that are correct and the proportion of actual defaults that the model identifies. The macroeconomic database creates another concern. Government agencies revise previously released observations, and the research database stores only the latest revised series. Backtests therefore use revised historical values even though portfolio managers would have observed preliminary values at the original forecast dates. Exhibit 1 summarizes the validation findings requiring corrective action.

                • 8. Solstice Research develops forecasts for a technology-sector investment strategy. One analyst models an issuer's monthly revenue growth with an AR(1) specification. The model includes an intercept, and all growth rates are expressed in decimal form. The estimated coefficients and the latest observation appear in Exhibit 1. The analyst also tests for a calendar effect by including a Q4 seasonal dummy variable alongside the AR(1) structure, and separately considers using the issuer's log share-price series in a predictive regression, applying augmented Dickey-Fuller tests to the level and first difference. A data-science team separately builds models to predict next-month stock returns. Candidate predictors include valuation ratios, trading activity, management-language scores, and satellite-derived measures of facility usage. The team estimates a linear regularized model, an unpruned decision tree, and a pruned decision tree. Exhibit 2 reports root mean squared errors from the training sample and a later chronological validation period. Hyperparameters are selected without using the final validation observations. The research director is concerned about model complexity and data leakage. She states that a large reduction in training error is not useful if validation error deteriorates materially. She also requires that every historical prediction use only data that would have been available at the prediction date. For example, an alternative-data vendor sometimes revises historical facility-usage observations after receiving improved satellite classifications. Solstice must use the original release rather than the revised history when testing a strategy. A junior analyst proposes randomly shuffling all monthly observations before splitting the data into training and validation sets. Another proposes selecting variables according to correlations calculated using the entire history and then reporting performance from the same period. The director instead considers a rolling procedure in which models are repeatedly estimated using observations available through each date and tested on the next period. All time-series tests use the significance level specified in Exhibit 1. The return-model comparison uses validation RMSE as the primary measure of out-of-sample predictive accuracy, and lower values are preferred. Each question can be answered independently from the stated estimates and policies.

                  Flashcards: Dummy variables and interaction terms

                  1. 1. How to correct for conditional heteroskedasticity of regression residuals?

                    Show answer

                    calculate robust standard errors (White-corrected standard errors, heteroskedasticity-consistent standard errors)

                  2. 2. What do penalized regression models do?

                    Show answer

                    \- reduce the problem of overfitting by imposing a penalty based on the number of features used by the model\ \- seek to minimize the SSE and the penalty value

                  3. 3. What is principal component analysis used for?

                    Show answer

                    to identify the factors of a statistical factor model, which cannot necessarily be described using conventional economic variables

                  4. 4. When is using a log-linear model most appropriate?

                    Show answer

                    when a variable grows at a constant rate

                  5. 5. How to correct for heteroskedasticity?

                    Show answer

                    - robust stadard errors (drawback: coefficients may be underestimated) - Generalized least squares

                  6. 6. Breusch-pagan test:\ What does it test for?\ What kind of test is it?\ What data is it used for?

                    Show answer

                    conditional heteroskedasticity\ chi-square\ pooled cross-sectional and time series

                  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