xuyiqing / gsynth

Generalized Synthetic Control Method
Other
131 stars 40 forks source link

Heterogeneous treatment effect D:time in formula #62

Open yahoochen97 opened 3 years ago

yahoochen97 commented 3 years ago

Hi,

I am trying to replicate the simulation study in your paper that has linearly growing effect which is heterogereous. However, when I included time-treatment interaction in the model formula:

fit <- interFE(y ~ 1 + x1 + x2 + D:time, data = data, index=c("unit","time"), r = 2, force = "two-way", nboots = 100)

an error prompted:

Error in FUN(X[[i]], ...) : Calling var(x) on a factor x is defunct. Use something like 'all(duplicated(x)[-1L])' to test for a constant vector.

My data have two time-varying covariates, treatment indicator, time and unit factors. Could you show me the proper way to obtain heterogeneous treatment effect using gsynth package? Thank you in advance!

yahoochen97 commented 3 years ago

I also tried not factoring time variable and another error occured:

Error in interFE.default(formula = NULL, data = data, Y = Yname, X = Xname, : Variable "time" is time-invariant. Try to remove it.

xuyiqing commented 3 years ago

Have you checked this out?

https://yiqingxu.org/packages/gsynth/gsynth_examples.html

On Thu, May 27, 2021 at 8:06 PM Yehu Chen @.***> wrote:

I also tried not factoring time variable and another error occured:

Error in interFE.default(formula = NULL, data = data, Y = Yname, X = Xname, : Variable "time" is time-invariant. Try to remove it.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/xuyiqing/gsynth/issues/62#issuecomment-850077613, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB2PKGDYZVKCQWE635MOLNDTP4CE3ANCNFSM45VSW2YA .