term | Model 1 |
|---|---|
(Intercept) | 1.26 |
aid_pct | 0.1 |
democracy | 0.23 |
aid_pct * | 0.5 ** |
N | 40 |
R sq. | 0.5 |
Adj. R sq. | 0.46 |
Significance: ***p < .01; **p < .05; *p < .1 | |
An example with easytable
Vilnius University
2026-04-30
When the effect of a predictor variable \(x_1\) on the response variable \(\widehat{y}\) is not independent from another predictor \(x_2\)
For example, the interaction term tells us whether the relationship between \(x_{1}\) and \(\widehat{y}\) is different when \(x_{2} = 1\) compared with when \(x_{2} = 0\).
\[ \widehat{y} = \beta_{0} + \beta_{1}x_{1} + \beta_{2}x_{2} + \epsilon \]
Where
\[ \widehat{y} = \beta_{0} + \beta_{1}x_{1} + \beta_{2}x_{2} + \beta_{3}(x_{1} \times x_{2}) + \epsilon \]
Where:
Assume \(x_{1}\) is continuous and \(x_{2}\) is binary.
When \(x_{2} = 0\):
\[ \widehat{y} = \beta_{0} + \beta_{1}x_{1} \]
When \(x_{2} = 1\):
\[ \widehat{y} = (\beta_{0} + \beta_{2}) + (\beta_{1} + \beta_{3})x_{1} \]
\(\beta_{2}\) is the change in the intercept when \(x_{2} = 1\).
\(\beta_{3}\) is the change in the slope of \(x_{1}\) when \(x_{2} = 1\).
term | Model 1 |
|---|---|
(Intercept) | 1.26 |
aid_pct | 0.1 |
democracy | 0.23 |
aid_pct * | 0.5 ** |
N | 40 |
R sq. | 0.5 |
Adj. R sq. | 0.46 |
Significance: ***p < .01; **p < .05; *p < .1 | |

Suppose we want to study whether foreign aid is associated with economic growth (RQ). But we suspect that aid does not work the same way everywhere.
\[ \widehat{Growth} = 1.37 + 0.35 Aid + 0.52 Capacity + 0.20(Aid \times Capacity) \]
Where
The effect of aid is not just \(0.35\).
Because aid is interacted with state capacity, the effect of aid is:
\[ \frac{\partial \widehat{Growth}}{\partial Aid} = 0.35 + 0.20 Capacity \]
For every one-point increase in state capacity, the association between aid and predicted GDP growth becomes 0.2 percentage points stronger.
term | Model 1 |
|---|---|
(Intercept) | 1.37 ** |
aid_pct | 0.35 *** |
state_capacity | 0.52 |
aid_pct * | 0.2 ** |
N | 40 |
R sq. | 0.64 |
Adj. R sq. | 0.61 |
Significance: ***p < .01; **p < .05; *p < .1 | |

term | Model 1 | Model 2 | Model 3 |
|---|---|---|---|
(Intercept) | 1.37 ** | 1.37 ** | 1.35 *** |
aid_pct | 0.35 *** | 0.35 *** | 0.1 *** |
state_capacity | 1.51 *** | 0.52 | 0.53 *** |
aid_pct * | 0.2 ** | 0.2 *** | |
democracy | 0.24 * | ||
population_m | 0 | ||
aid_pct * | 0.5 *** | ||
N | 40 | 40 | 40 |
R sq. | 0.58 | 0.64 | 0.99 |
Adj. R sq. | 0.55 | 0.61 | 0.99 |
Significance: ***p < .01; **p < .05; *p < .1 | |||
easytableeasytableeasytable() vs summary()
Call:
lm(formula = gdp_growth ~ aid_pct + state_capacity, data = df)
Residuals:
Min 1Q Median 3Q Max
-3.515 -1.321 0.022 1.369 3.330
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 1.37244 0.55819 2.459 0.01874 *
aid_pct 0.34556 0.09717 3.556 0.00105 **
state_capacity 1.51190 0.24582 6.150 3.93e-07 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 1.738 on 37 degrees of freedom
Multiple R-squared: 0.577, Adjusted R-squared: 0.5542
F-statistic: 25.24 on 2 and 37 DF, p-value: 1.221e-07
easytable()term | Model 1 | Model 2 |
|---|---|---|
(Intercept) | 1.37 ** | 1.37 ** |
aid_pct | 0.35 *** | 0.35 *** |
state_capacity | 1.51 *** | 0.52 |
aid_pct * | 0.2 ** | |
N | 40 | 40 |
R sq. | 0.58 | 0.64 |
Adj. R sq. | 0.55 | 0.61 |
Significance: ***p < .01; **p < .05; *p < .1 | ||
easytable() commandsterm | Model 1 | Model 2 | Model 3 |
|---|---|---|---|
(Intercept) | 1.37 ** | 1.37 ** | 1.35 *** |
aid_pct | 0.35 *** | 0.35 *** | 0.1 *** |
state_capacity | 1.51 *** | 0.52 | 0.53 *** |
aid_pct * | 0.2 ** | 0.2 *** | |
democracy | 0.24 * | ||
population_m | 0 | ||
aid_pct * | 0.5 *** | ||
N | 40 | 40 | 40 |
R sq. | 0.58 | 0.64 | 0.99 |
Adj. R sq. | 0.55 | 0.61 | 0.99 |
Significance: ***p < .01; **p < .05; *p < .1 | |||
# Name models, set digits
easytable(m1, m2,
digits = 1,
model.names = c("A", "B"),
highlight = TRUE)term | A | B |
|---|---|---|
(Intercept) | 1.4 ** | 1.4 ** |
aid_pct | 0.3 *** | 0.3 *** |
state_capacity | 1.5 *** | 0.5 |
aid_pct * | 0.2 ** | |
N | 40 | 40 |
R sq. | 0.58 | 0.64 |
Adj. R sq. | 0.55 | 0.61 |
Significance: ***p < .01; **p < .05; *p < .1 | ||
term | Model 1 | Model 2 | Model 3 |
|---|---|---|---|
(Intercept) | 1.37 ** | 1.37 ** | 1.35 *** |
aid_pct | 0.35 *** | 0.35 *** | 0.1 *** |
state_capacity | 1.51 *** | 0.52 | 0.53 *** |
aid_pct * | 0.2 ** | 0.2 *** | |
democracy | 0.24 * | ||
aid_pct * | 0.5 *** | ||
population_m | Y | ||
N | 40 | 40 | 40 |
R sq. | 0.58 | 0.64 | 0.99 |
Adj. R sq. | 0.55 | 0.61 | 0.99 |
Significance: ***p < .01; **p < .05; *p < .1 | |||
library(easytable)
mtcars
# Define models
m1 <- lm(mpg ~ wt, data = mtcars)
m2 <- lm(mpg ~ wt + hp, data = mtcars)
m3 <- lm(mpg ~ wt + hp + cyl + am, data = mtcars)
# Table
easytable(m1, m2, m3,
control.var = c("cyl", "am"),
model.names = c("A", "B", "C"),
export.word = "table.docx",
export.csv = "table.csv",
highlight = TRUE)Work in pairs or groups of 3.
Your task is to use the gapminder data to test one interaction effect.
lifeExplog_gdpcontinent, pop, or a dummy variable (binary) you create
