xuyiqing / gsynth

Generalized Synthetic Control Method
Other
130 stars 40 forks source link

error occurred at simulating error step #43

Open di-yuan-88 opened 4 years ago

di-yuan-88 commented 4 years ago

Hi, We ran into the following error with some of our gsynth model: Simulating errors ...Error in { : task 602 failed - "'data' must be of a vector type, was 'NULL'"

In our study, we have lots of treated units with varying treatment timing. So we just tried to run gsynth on the entire dataset and a subset only with treated units at a certain period. The error only occurs when using the subset (the 2nd model in the sample code).

I also attached the sample data & code to reproduce the error. The code:

test1 <- readRDS("tmpdata/testdata.RDS")

out1 <- gsynth(dv1 ~ treatment + covar1 + covar2 + covar3 + covar4 + covar5 + covar6, data = test1, index = c("id", "TimePeriod"), na.rm = TRUE, force = "two-way", CV = TRUE, r = c(0,5), se = TRUE, inference = "nonparametric", min.T0 = 7, seed = 1, nboots = 1000, parallel = TRUE, cores = 4)

test2 <- test1 %>% group_by(id) %>% mutate(check = sum(treatment)) %>% ungroup() %>% filter(check == 7 | check == 0) %>% select(-check)

out2 <- gsynth(dv1 ~ treatment + covar1 + covar2 + covar3 + covar4 + covar5 + covar6, data = test2, index = c("id", "TimePeriod"), na.rm = TRUE, force = "two-way", CV = TRUE, r = c(0,5), se = TRUE, inference = "parametric", min.T0 = 7, seed = 1, nboots = 1000, parallel = TRUE, cores = 4)

I found the error seems to be related to a particular covariate and random number generator: when I remove "covar6" from the model, the error disappears, and also I ran multiple times, sometimes it went through...

Also, I'm on PC Windows 10 with R version is 4.0.0. and gsynth 1.0.9

Many thanks!

Dee

testdata.zip

xuyiqing commented 4 years ago

Could you send me a sample data and code file such that we can replicate the error?

I believe we do have a built-in "id" option to accommodate your needs.

Best, Yiqing

On Thu, Jun 25, 2020 at 7:13 AM deedeewoo notifications@github.com wrote:

Hi, We ran into the following error with some of our gsynth model: Simulating errors ...Error in { : task 602 failed - "'data' must be of a vector type, was 'NULL'"

In our study, we have lots of treated units with varying treatment timing. So we just tried to run gsynth on the entire dataset and a subset only with treated units at a certain period. The error only occurs when using the subset (the 2nd model in the sample code).

I also attached the sample data & code to reproduce the error. The code:

test1 <- readRDS("tmpdata/testdata.RDS")

out1 <- gsynth(dv1 ~ treatment + covar1 + covar2 + covar3 + covar4 + covar5 + covar6, data = test1, index = c("id", "TimePeriod"), na.rm = TRUE, force = "two-way", CV = TRUE, r = c(0,5), se = TRUE, inference = "nonparametric", min.T0 = 7, seed = 1, nboots = 1000, parallel = TRUE, cores = 4)

test2 <- test1 %>% group_by(id) %>% mutate(check = sum(treatment)) %>% ungroup() %>% filter(check == 7 | check == 0) %>% select(-check)

out2 <- gsynth(dv1 ~ treatment + covar1 + covar2 + covar3 + covar4 + covar5 + covar6, data = test2, index = c("id", "TimePeriod"), na.rm = TRUE, force = "two-way", CV = TRUE, r = c(0,5), se = TRUE, inference = "parametric", min.T0 = 7, seed = 1, nboots = 1000, parallel = TRUE, cores = 4)

I found the error seems to be related to a particular covariate and random number generator: when I remove "covar6" from the model, the error disappears, and also I ran multiple times, sometimes it went through...

Also, I'm on PC Windows 10 with R version is 4.0.0. and gsynth 1.0.9

Many thanks!

Dee

testdata.zip https://github.com/xuyiqing/gsynth/files/4831825/testdata.zip

— 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/43, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB2PKGAB3JKQN2PBZSPIQ3DRYNLPJANCNFSM4OINGTNA .

-- Yiqing Xu

Assistant Professor Department of Political Science Stanford University http://yiqingxu.org/

di-yuan-88 commented 4 years ago

Hi Professor,

Thanks for your prompt reply! Here is the sample data & code: error-rep.zip

We did use the 'id' option when plotting individual unit's "actual vs. synthetic control trajectory", but the results (the trajectory of synthetic control) of some units are not the same from the 1st & 2nd model in the attached code.

Thanks! Dee

lzy318 commented 4 years ago

Hi Dee, Could you try the latest version of gsynth (version 1.1.6), it seems that this problem has been fixed in the latest version.

di-yuan-88 commented 4 years ago

Hi, just download the latest version, and it works now. Thanks!