Home > Enterprise >  Regression with before and after
Regression with before and after

Time:11-24

I have a dataset with four variables (df)

household group income post
1 0 20'000 0
1 0 22'000 1
2 1 10'000 0
2 1 20'000 1
3 0 20'000 0
3 0 21'000 1
4 1 9'000 0
4 1 16'000 1
5 1 8'000 0
5 1 18'000 1
6 0 22'000 0
6 0 26'000 1
7 1 12'000 0
7 1 24'000 1
8 0 24'000 0
8 0 27'000 1

Group is a binary variable and is 1, when household got support from state. and post variable is also binary and is 1, when it is after some household got support from state. Now I would like to run a before vs after regression that estimates the group effect by comparing post-period and before period for the supported group. I would like to put the dependent variable in logs, to have the effect in percentage, so the impact of state support on income.

I used that code, but I don't know if it is right to get the answer?

library("fixest")

feols(log(income) ~ group   post,data=df) %>% etable()

Is there another way?

CodePudding user response:

If I understand your question correct. You want to see the change for group = 1 on going from period = 0 to period = 1? Then you have to subset your data to only include group = 1.

data <- read_excel("income_did.xlsx")
treated <- feols(income~post, data = subset(data, group == 1))
treated_log <- feols(log(income)~post, data = subset(data, group == 1))
etable(treated, treated_log)

regression table

PS: The interpretation of the coefficient as percentage change is a good approximation for small numbers. The correct formula for % change is: exp(beta_post)-1. In this case it is exp(0.6931)-1 = 0.999. So the change here is close to 100%, as we got confirmed when using nominal levels on income.

EDIT: If you are looking for the classic 2x2 design your code was almost corredt. Change with *. This tell us that the supported group increased the income with 7 250 more than the group which not received support.

comparing = feols(income ~ group * post,data)
comparing_log = feols(log(income) ~ group * post,data)
etable(comparing,comparing_log)

2x2 design

  •  Tags:  
  • r
  • Related