Calculating interaction effects from OLS coefficients:
Interaction between two categorical independent variables
Jane E. Miller, PhD
The Chicago Guide to Writing about Multivariate Analysis, 2 nd edition.
Overview
• General equation for a model with main effects and interactions
• Review: Coding of main effects and interaction terms
• Solving for the interaction pattern based on estimated coefficients
• Graphical depiction of the interaction pattern
The Chicago Guide to Writing about Multivariate Analysis, 2 nd edition.
Estimated coefficients
OLS model of birth weight (grams)
Main effect terms
Non-Hispanic black (NHB)
Less than high school (<HS)
High school diploma (=HS)
Interaction terms
NHB_<HS
NHB_=HS
β
–168
–54
–62
– 39
+18
Reference category: Non-Hispanic whites with >HS education.
All variables are dummy-coded: 1 = named value, 0 = other values.
The Chicago Guide to Writing about Multivariate Analysis, 2 nd edition.
Interpreting the main effects
• The main effect terms estimate the difference in birth weight relative to those in the reference category
(non-Hispanic whites with more than complete high school education).
– β
NHB is an estimate of the difference in intercept between non-Hispanic black infants and those in the reference category.
– β
<HS and β
=HS estimate the difference in intercept between infants in the reference category and those born to mothers with less than complete high school and complete high school, respectively.
– Units are those of the dependent variable, grams.
The Chicago Guide to Writing about Multivariate Analysis, 2 nd edition.
Interpreting the interaction between race and education
• The race_education interaction tests whether the difference in birth weight for <HS versus
=HS is different for non-Hispanic black infants than for their non-Hispanic white counterparts.
– We calculate the overall effect for NHB and <HS as
= β
NHB
+ β
<HS
+ β
NHB_<HS
– If the difference in birth weight across mothers’ education categories were the same for blacks as for whites, then the interaction term β
NHB_<HS
= 0.
The Chicago Guide to Writing about Multivariate Analysis, 2 nd edition.
Calculating overall effect of interaction for specific case characteristics
• The general equation to calculate how a case differs from the reference category:
– main effects coefficients
– interaction term coefficients
– values of the independent variables
= (β
NHB
× NHB) + (β
<HS
× <HS) + (β
=HS
× =HS) +
(β
NHB_<HS
× NHB_<HS) + (β
NHB_=HS
× NHB_=HS)
• To see which βs pertain to which cases, fill in values of variables for different combinations of race and education.
The Chicago Guide to Writing about Multivariate Analysis, 2 nd edition.
Review: Coding of main effects and interaction term variables
Main effects terms Interaction terms
Case characteristics
Race Education Race & education
NHB <HS =HS NHB_<HS NHB_=HS
Non-H white & <HS 0
Non-H white & =HS 0
Non-H white & >HS 0
Non-H black & <HS 1
Non-H black & =HS 1
Non-H black & >HS 1
0
1
1
0
0
0
0
0
0
1
1
0
0
1
0
0
0
0
0
0
0
0
1
0
Reference category
The Chicago Guide to Writing about Multivariate Analysis, 2 nd edition.
Cases in the reference category for both independent variables
General equation to calculate how a case differs from the reference category:
= ( β
NHB
× NHB) + ( β
<HS
( β
NHB_<HS
× NHB_<HS)
× <HS) + ( β
=HS
+ ( β
NHB_=HS
× =HS) +
× NHB_=HS)
Fill in values of variables for non-Hispanic whites with >HS:
NHB <HS =HS NHB_<HS NHB_=HS
Non-H white & >HS 0 0 0 0 0
= ( β
NHB
× 0) + ( β
<HS
( β
NHB_<HS
× 0) + ( β
× 0) + ( β
=HS
NHB_=HS
× 0)
× 0) = 0
+
The Chicago Guide to Writing about Multivariate Analysis, 2 nd edition.
Cases in the reference category for both independent variables
= ( β
NHB
× 0) + ( β
<HS
( β
NHB_<HS
× 0) + ( β
× 0) + ( β
=HS
NHB_=HS
× 0)
× 0) = 0
+
• All of the coefficients fall out of the equation for non-Hispanic whites born to mothers with >HS because each β is multiplied by a value of 0 .
• Thus, cases in the reference category for both race and education have a calculated overall effect of 0.
– As it should be, because there is no difference between them and themselves!
The Chicago Guide to Writing about Multivariate Analysis, 2 nd edition.
Cases in the reference category for 1 but not both independent variables
Fill values of variables for non-Hispanic whites with =HS into the general equation:
NHB <HS =HS NHB_<HS NHB_=HS
Non-H white & =HS 0 0 1 0 0
= ( β
NHB
× 0) + ( β
<HS
( β
NHB_<HS
× 0) + ( β
=HS
× 0) + ( β
NHB_=HS
× 0) =
×
β
1)
=HS
+
The equation for non-Hispanic white infants born to mothers with a high school diploma collapses to include only β
=HS because all of the other coefficients are multiplied by a value of 0.
The Chicago Guide to Writing about Multivariate Analysis, 2 nd edition.
Cases not in the reference category for either independent variable
Fill in values of variables for non-Hispanic blacks with =HS:
NHB <HS =HS NHB_<HS NHB_=HS
Non-H black & =HS 1 0 1 0 1
= ( β
NHB
× 1) + ( β
<HS
( β
NHB_<HS
= β
NHB
+ β
=HS
× 0)
+ β
+ ( β
=HS
× 0) + ( β
NHB_=HS
NHB_=HS
×
× 1)
1) +
Thus, the equation for non-Hispanic black infants born to mothers with a high school diploma collapses to include the main effects terms for both β
NHB and β
=HS and the interaction term β
NHB_=HS .
All the other βs fall out because they are multiplied by 0.
The Chicago Guide to Writing about Multivariate Analysis, 2 nd edition.
Equations to calculate overall effect
Equation
Subgroup
Non-Hisp.
white , <HS
Non-Hisp.
white , = HS
Non-Hisp. white , >HS
Symbols
= β
<HS
= β
=HS
NA (ref cat)
Estimated β
= –54
= –62
NA
Value
= –54
= –62
0
Non-Hisp. black , <HS
Non-Hisp. black , =HS
Non-Hisp.
black , >HS
= β
NHB
+ β
<Hs
+
β
NHB_<HS
= β
NHB
+ β
=Hs
+
β
NHB_=HS
= β
NHB
= (–168) + (–54)
+ (–39)
= (–168) + (–62)
+ (+18)
= –168
= –261
= –212
= –168
Difference in birth weight (grams) compared to infants born to non-Hispanic white women with more than a high school education = reference category.
The Chicago Guide to Writing about Multivariate Analysis, 2 nd edition.
Interpreting the sign of the interaction terms: NHB_<HS
•
β NHB_<HS = –39, meaning that infants in that group have lower estimated birth weight than would be predicted from their race and mother’s education alone, based on the main effects ( β
NHB
+ β
<HS
)
–
All three βs (both main effects and interaction) have negative signs, meaning that they cumulate to a large deficit in birth weight for NHB <HS.
– The β on the interaction term reinforces (adds to) the predicted deficit based on race and education alone.
The Chicago Guide to Writing about Multivariate Analysis, 2 nd edition.
Calculating overall effect for non-
Hispanic blacks with <HS education
β
NHB
=
β
<HS
=
β
NHB_<HS
=
–54
–39
–168
= β
NHB +
β
<HS +
β
NHB_<HS
= (–168) + (–54) + (–39) = –261
–39 –54 –168
Compared to infants born to non-Hispanic white women with more than a high school education = reference category.
The Chicago Guide to Writing about Multivariate Analysis, 2 nd edition.
Interpreting the sign of the interaction term: NHB_=HS
•
On the other hand, β
NHB_=HS
= +18, meaning that infants in that group have higher estimated birth weight than would be predicted from their race and mother’s education alone, based on the main effects ( β
NHB and
β =HS ).
– Both main effects terms have negative signs, but the interaction term has a positive ( opposite ) sign, so it partially offsets the deficit in birth weight predicted based on race and education alone.
The Chicago Guide to Writing about Multivariate Analysis, 2 nd edition.
Calculating overall effect for non-
Hispanic blacks with =HS education
β
NHB
=
β
=HS
=
β
NHB_=HS
=
+18
–62
–168
Note that interaction term has the
OPPOSITE SIGN of the two main effects, partially offsetting their two negative effects on birth weight with a positive effect.
= β
NHB +
β
=HS +
β
NHB_=HS
= (–168) + (–62) + (+18) = –212
+18
–62 –168
Compared to infants born to non-Hispanic white women with more than a high school education = reference category.
The Chicago Guide to Writing about Multivariate Analysis, 2 nd edition.
Overall effects of race and mother’s education on birth weight
= -261
Solid = main effect term.
Striped = interaction of education level w/ NHB.
Compared to non-Hispanic whites with >HS education.
The Chicago Guide to Writing about Multivariate Analysis, 2 nd edition.
Predicted value and the intercept term
• The intercept (or “constant”) term estimates the value of the dependent variable Y for cases in the reference category.
• To calculate the predicted value of Y for each combination of the X i
,
– add the estimated coefficient for the intercept (β
0
) to the βs for each variable that pertains to the category of interest.
The Chicago Guide to Writing about Multivariate Analysis, 2 nd edition.
Examples: Predicted value
• For instance, β
0
= 3,042.8.
• So infants who are in the reference category for all variables are estimated to weigh 3,042.8 grams.
• This includes non-Hispanic whites born to women with >HS.
– Reference category for race and mother’s education
• Those born to Mexican American women with less than a high school education:
• β
0 +
β
MA
+ β
<HS
+ β
MA_<HS
= 3,042.8 + (–104.2) + (–54.2) + 99.4
= 3,039.8 – 59.0
= 2,983.8 grams.
The Chicago Guide to Writing about Multivariate Analysis, 2 nd edition.
Use a spreadsheet to calculate and graph the interaction
• Spreadsheets can
– Store
• The estimated coefficients
• The input values of the independent variables
• The correct generalized formula to calculate the predicted values for many combinations of the IVs involved in the interaction
– Graph the overall pattern
• See spreadsheet template and podcast
The Chicago Guide to Writing about Multivariate Analysis, 2 nd edition.
Summary
• Calculating the overall shape of an interaction pattern requires adding together the pertinent main effects and interaction term coefficients for each possible combination of the two categorical
IVs in the interaction.
– A spreadsheet can be helpful for storing and organizing the coefficients and formulas.
• Depending on the respective signs of those βs, the interaction can either amplify or dampen the main effects on the component variables.
The Chicago Guide to Writing about Multivariate Analysis, 2 nd edition.
Suggested resources
• Chapter 16 of Miller, J.E. 2013. The Chicago
Guide to Writing about Multivariate Analysis,
2nd Edition.
• Chapters 8 and 9 of Cohen et al. 2003. Applied
Multiple Regression/Correlation Analysis for the
Behavioral Sciences, 3rd Edition. Florence, KY:
Routledge.
The Chicago Guide to Writing about Multivariate Analysis, 2 nd edition.
Supplemental online resources
• Podcast on creating interaction term variables
• Spreadsheet template for calculating overall effect of an interaction between two categorical variables.
The Chicago Guide to Writing about Multivariate Analysis, 2 nd edition.
Suggested practice exercises
• Study guide to The Chicago Guide to Writing about Multivariate Analysis, 2nd Edition.
– Questions #3 and 5 in the problem set for Chapter 16
– Suggested course extensions for Chapter 16
• “Applying statistics and writing” exercise #1.
The Chicago Guide to Writing about Multivariate Analysis, 2 nd edition.
Contact information
Jane E. Miller, PhD jmiller@ifh.rutgers.edu
Online materials available at http://press.uchicago.edu/books/miller/multivariate/index.html
The Chicago Guide to Writing about Multivariate Analysis, 2 nd edition.