Can a dummy variable help me in a linear regression where my slope changes based on that variable

116 Views Asked by At

Sorry if that wasn't a particularly helpful title, let me explain the situation.

If I have a scatter chart of y ~ x1 and I notice that if I filter the data by tiers of a different variable, my slope changes (for instance, a positive relationship where the dummy variable is on, and a negative relationship where the dummy variable is off), how can I incorporate that into my model?

I ask because the research I've done on dummy variable seems to be centered around changing the intercept of the line, not changing the slope of the line. Is there a way to use a dummy variable to change the coefficient of my x1 variable, or are dummy variables only used in a way that adds (or subtracts) from the intercept?

1

There are 1 best solutions below

0
On

If $d$ is the dummy variable, use the following regression model: $ y = \beta_0 + \beta_1 d + \beta_2 x_1 + \beta_3(x_1 d) + \varepsilon$

Or your notation: $y \sim x_1 + d + d\cdot x_1$

$\beta_1$ corresponds to the difference (between the two groups defined by the dummy) in the intercepts while $\beta_3$ corresponds to the difference in the slopes.