What I want to achieve is to run the regression many times, each time R records the estimates of did in one data.frame. Everytime, I change the "ifelse" condition to different years , ie., ifelse(mydata$year >= 1993, 1, 0), thus I can run a different regression.
I attached my code as the following: Can anyone help it? (The data can be downloaded through browser if R returned errors)
library(foreign) mydata = read.dta("http://dss.princeton.edu/training/Panel101.dta") mydata$time = ifelse(mydata$year >= 1994, 1, 0) mydata$did = mydata$time * mydata$treated mydata$treated = ifelse(mydata$country == "E" | mydata$country == "F" | mydata$country == "G", 1, 0) didreg = lm(y ~ treated + time + did, data = mydata) summary(didreg)