# Interaction terms in level-log regression

I have the following regression: $y=\alpha + \beta_{1}\text{ln}x_{1} + \beta_{2}(\text{ln} x_{1}\cdot \text{ln}x_{2})$ How do I interpret the marginal effect of $x_{1}$ on $y$? I haven't find anything about the interaction term in a level-log regression. Thanks a lot

• Are you sure you don’t want to include a term involving $\text{ln} x_2$ alone? Anyway, if you multiply $x_1$ by $c$, than $y$ will increase by $\left(\beta_1 + \beta_2 \text{ln} x_2 \right) \text{ln} c$. That's it. Commented Feb 18, 2016 at 12:59
• shouldn't I take the derivative of y with respect to $x_{1}$? Commented Feb 18, 2016 at 13:11
• Well, you could, yes, but in my opinion that’s not an appropriate way to describe the dependance. If you use $\log x_1$ instead of $x_1$ it’s because you think $y$ responds (almost) linearly to an increase of $x$ by a factor $c$, rather than by an additive increment. Commented Feb 18, 2016 at 14:53

The expected value of $$y$$ given $$x$$ in your model is

$$E[y \vert x_1,x_2]=\alpha + \beta_1 \ln x_1 + \beta_2 \ln x_1 \cdot \ln x_2$$

Taking the derivative of that with respect to $$x_1$$, you get

$$\frac{\partial y}{\partial x_1} = \frac{\beta_1}{x_1}+ \frac{\beta_2}{x_1} \ln x_2$$

Multiplying both sides by $$x_1$$ and rearranging, you get something like

$$\frac{\partial y}{\partial x_1} \frac{x_1}{1} = \beta_1+ \beta_2 \ln x_2$$

The LHS is the very definition of a semi-elasticity. This means that you can interpret $$\frac{1}{100} \cdot (\beta_1+ \beta_2 \ln x_2)$$ as the expected change in units of $$y$$ from a 1% increase in $$x$$.

As I understand it, the interpretation of a level-log regression induces a non-linear effect of $x_{1}$ on $y$; that is, a percentage change in $x_{1}$ will provide an increase in the level of $y$. This can further be interpreted the same with regards to the interaction term. Switching the log transformation of $x$ and $y$ will change the magnitude, but still retain the non-linear effect.

Here is a quick demonstration in R:

$$y = \alpha + \beta_{1}female + \beta_{2}log(math) + \beta_{3}log(math) \cdot log(read)$$

where $y$ is reading ability

Sample Data:

df <- structure(list(write = c(52L, 59L, 33L, 44L, 52L, 52L, 59L, 46L,
57L, 55L, 46L, 65L, 60L, 63L, 57L, 49L, 52L, 57L, 65L, 39L, 49L,
63L, 40L, 52L, 44L, 37L, 65L, 57L, 38L, 44L, 31L, 52L, 67L, 41L,
59L, 65L, 54L, 62L, 31L, 31L, 47L, 59L, 54L, 41L, 65L, 59L, 40L,
59L, 59L, 54L, 61L, 33L, 44L, 59L, 62L, 39L, 37L, 39L, 57L, 49L,
46L, 62L, 44L, 33L, 42L, 41L, 54L, 39L, 43L, 33L, 44L, 54L, 67L,
59L, 45L, 40L, 61L, 59L, 36L, 41L, 59L, 49L, 59L, 65L, 41L, 62L,
41L, 49L, 31L, 49L, 62L, 49L, 62L, 44L, 44L, 62L, 65L, 65L, 44L,
63L, 60L, 59L, 46L, 52L, 59L, 54L, 62L, 35L, 54L, 65L, 52L, 50L,
59L, 65L, 61L, 44L, 54L, 67L, 57L, 47L, 54L, 52L, 52L, 46L, 62L,
57L, 41L, 53L, 49L, 35L, 59L, 65L, 62L, 54L, 59L, 63L, 59L, 52L,
41L, 49L, 46L, 54L, 42L, 57L, 59L, 52L, 62L, 52L, 41L, 55L, 37L,
54L, 57L, 54L, 62L, 59L, 55L, 57L, 39L, 67L, 62L, 50L, 61L, 62L,
59L, 44L, 59L, 54L, 62L, 60L, 57L, 46L, 36L, 59L, 49L, 60L, 67L,
54L, 52L, 65L, 62L, 49L, 67L, 65L, 67L, 65L, 54L, 44L, 62L, 46L,
54L, 57L, 52L, 59L, 65L, 59L, 46L, 41L, 62L, 65L), female = structure(c(2L,
1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("female", "male"), class = "factor"),
math = c(41L, 53L, 54L, 47L, 57L, 51L, 42L, 45L, 54L, 52L,
51L, 51L, 71L, 57L, 50L, 43L, 51L, 60L, 62L, 57L, 35L, 75L,
45L, 57L, 45L, 46L, 66L, 57L, 49L, 49L, 57L, 64L, 63L, 57L,
50L, 58L, 75L, 68L, 44L, 40L, 41L, 62L, 57L, 43L, 48L, 63L,
39L, 70L, 63L, 59L, 61L, 38L, 61L, 49L, 73L, 44L, 42L, 39L,
55L, 52L, 45L, 61L, 39L, 41L, 50L, 40L, 60L, 47L, 59L, 49L,
46L, 58L, 71L, 58L, 46L, 43L, 54L, 56L, 46L, 54L, 57L, 54L,
71L, 48L, 40L, 64L, 51L, 39L, 40L, 61L, 66L, 49L, 65L, 52L,
46L, 61L, 72L, 71L, 40L, 69L, 64L, 56L, 49L, 54L, 53L, 66L,
67L, 40L, 46L, 69L, 40L, 41L, 57L, 58L, 57L, 37L, 55L, 62L,
64L, 40L, 50L, 46L, 53L, 52L, 45L, 56L, 45L, 54L, 56L, 41L,
54L, 72L, 56L, 47L, 49L, 60L, 54L, 55L, 33L, 49L, 43L, 50L,
52L, 48L, 58L, 43L, 41L, 43L, 46L, 44L, 43L, 61L, 40L, 49L,
56L, 61L, 50L, 51L, 42L, 67L, 53L, 50L, 51L, 72L, 48L, 40L,
53L, 39L, 63L, 51L, 45L, 39L, 42L, 62L, 44L, 65L, 63L, 54L,
45L, 60L, 49L, 48L, 57L, 55L, 66L, 64L, 55L, 42L, 56L, 53L,
41L, 42L, 53L, 42L, 60L, 52L, 38L, 57L, 58L, 65L), read = c(57L,
68L, 44L, 63L, 47L, 44L, 50L, 34L, 63L, 57L, 60L, 57L, 73L,
54L, 45L, 42L, 47L, 57L, 68L, 55L, 63L, 63L, 50L, 60L, 37L,
34L, 65L, 47L, 44L, 52L, 42L, 76L, 65L, 42L, 52L, 60L, 68L,
65L, 47L, 39L, 47L, 55L, 52L, 42L, 65L, 55L, 50L, 65L, 47L,
57L, 53L, 39L, 44L, 63L, 73L, 39L, 37L, 42L, 63L, 48L, 50L,
47L, 44L, 34L, 50L, 44L, 60L, 47L, 63L, 50L, 44L, 60L, 73L,
68L, 55L, 47L, 55L, 68L, 31L, 47L, 63L, 36L, 68L, 63L, 55L,
55L, 52L, 34L, 50L, 55L, 52L, 63L, 68L, 39L, 44L, 50L, 71L,
63L, 34L, 63L, 68L, 47L, 47L, 63L, 52L, 55L, 60L, 35L, 47L,
71L, 57L, 44L, 65L, 68L, 73L, 36L, 43L, 73L, 52L, 41L, 60L,
50L, 50L, 47L, 47L, 55L, 50L, 39L, 50L, 34L, 57L, 57L, 68L,
42L, 61L, 76L, 47L, 46L, 39L, 52L, 28L, 42L, 47L, 47L, 52L,
47L, 50L, 44L, 47L, 45L, 47L, 65L, 43L, 47L, 57L, 68L, 52L,
42L, 42L, 66L, 47L, 57L, 47L, 57L, 52L, 44L, 50L, 39L, 57L,
57L, 42L, 47L, 42L, 60L, 44L, 63L, 65L, 39L, 50L, 52L, 60L,
44L, 52L, 55L, 50L, 65L, 52L, 47L, 63L, 50L, 42L, 36L, 50L,
41L, 47L, 55L, 42L, 57L, 55L, 63L)), class = "data.frame", row.names = c(NA,
-200L), .Names = c("write", "female", "math", "read"))


Regression Code:

library(ggplot2)
fit <- lm(write ~ female + log(math) + log(math)*log(read), data = df)

ggplot(df, aes(log(math), write)) + geom_point() + geom_smooth()

fit

>Call:
lm(formula = write ~ female + log(math) + log(math) * log(read),
data = df)

Coefficients: