bcallaway11 / did

Difference in Differences with Multiple Periods, website: https://bcallaway11.github.io/did
288 stars 92 forks source link

Version 2.1.2 and multiple cores on a Windows PC #141

Open tra6sdc opened 1 year ago

tra6sdc commented 1 year ago

Hello, I am using version 2.1.2 of did so that I can reduce the computation time by using multiple cores.

As a preamble, to be able to re-produce the same output at each call to att_gt I set the seed for the random number generator.

I wanted to check that when using multiple cores I was still able to re-produce the same outputs. However running the example code, I get a message that says that multiple cores can not be used on a Windows PC? Is this so, or do I need to do some preparatory work? I have installed and loaded doParallel.

> # set seed so everything is reproducible
> set.seed(1814)
>  
> # generate dataset with 4 time periods
> time.periods <- 4
> sp <- reset.sim(time.periods=time.periods)
> 
> # add dynamic effects
> sp$te.e <- 1:time.periods
> 
> # generate data set with these parameters
> # here, we dropped all units who are treated in time period 1 as they do not help us recover ATT(g,t)'s.
> dta <- build_sim_dataset(sp)
> 
> set.seed(1)
> example_attgt <- att_gt(yname = "Y",
+                         tname = "period",
+                         idname = "id",
+                         gname = "G",
+                         xformla = ~X,
+                         data = dta,
+                         pl= TRUE,
+                         cores=4
+ )
Error in parallel::mclapply(chunks, FUN = parallel.function, mc.cores = cores) : 
  'mc.cores' > 1 is not supported on Windows
> summary(example_attgt)