Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in cumuEff(): object 'D.boot' not found #30

Open
michaeldgarber opened this issue Oct 3, 2019 · 17 comments
Open

Error in cumuEff(): object 'D.boot' not found #30

michaeldgarber opened this issue Oct 3, 2019 · 17 comments

Comments

@michaeldgarber
Copy link

michaeldgarber commented Oct 3, 2019

Dear @xuyiqing, @liulch,
I would like to implement your function for finding cumulative effects (cumEff) but I get the following error when running this line of code. The gsynth object was successfully created.

gsynth_cum<- gsynth::cumuEff(gsynth_object,
                                cumu= TRUE,
                                id = NULL,
                                period = NULL)

Error in gsynth::cumuEff(gsynth_object, cumu = TRUE, id = NULL, period = NULL) :
object 'D.boot' not found

Thanks for any help you may be able to offer and for the terrific package.
-Michael

@liulch
Copy link
Collaborator

liulch commented Oct 8, 2019

Hi @michaeldgarber , can you also add the code that creates the gsynth object? Thx!

@michaeldgarber
Copy link
Author

michaeldgarber commented Oct 8, 2019

Hi @liulch - thanks for your reply. Here's a reprex, using the turnout data, which returns the same error for me. Perhaps I need to specify something in the 'id' and 'period' arguments?

gsynth version ‘1.1.4’
R version 3.6.1 (2019-07-05)

library(gsynth)
data(gsynth)

Use the turnout data, which has differential timing of treatment. Inspect data

panelView(turnout ~ policy_edr, data = turnout,  index = c("abb","year"), 
pre.post = TRUE, by.timing = TRUE) 

out <- gsynth::gsynth(turnout ~ policy_edr + policy_mail_in + policy_motor,
              data = turnout,  index = c("abb","year"), se = TRUE, 
               inference = "parametric", r = c(0, 5), 
              CV = TRUE, force = "two-way", nboots = 1000, seed = 02139)

out_cum_eff <- gsynth::cumuEff(out,
        cumu = TRUE, 
         id=NULL,
       period = NULL)

Error in gsynth::cumuEff(out, cumu = TRUE, id = NULL, period = NULL) :
object 'D.boot' not found

@michaeldgarber
Copy link
Author

Hi @xuyiqing and @liulch ,

I see that you have added eff.boot as an output of the gsynth function. Thank you. As a result, I no longer need the cumuEff function, as I can calculate everything I need using the output of gsynth. So, for my purposes, the issue here could be closed, but I'll leave it open since, technically, I think the issue is still present.

Thanks again,
Michael

@xuyiqing
Copy link
Owner

xuyiqing commented Nov 18, 2019 via email

@michaeldgarber
Copy link
Author

No problem! Thanks for the update. As I mentioned, I think I figured it out with gsynth::gsynth alone so any additions would just be for convenience. Thanks again! M

@feliuserra
Copy link

Hi,

Sorry to "reopen" this and bother about this again, but I am having the same issue. When running the cumuEff function I get the following error:

Error in cumuEff(out, cumu = TRUE) : object 'D.boot' not found

@michaeldgarber could you please further develop how eff.boot allows you to compute yourself the cumulative effect? eff.boot shows a matrix with 3 dimensions: the first is the number of time periods, the second is the number of treated units and the third is the number of unique ids in the dataset. is that correct?

Perhaps this should go in another issue, but I will drop it here and if needed I can open a new issue.

Thank you very much in advance,
Feliu

@michaeldgarber
Copy link
Author

michaeldgarber commented Apr 9, 2020 via email

@feliuserra
Copy link

Hi Michael,

Thanks so much for the quick reply! Let me know if you need help or anything. Here is my email just in case: feliu.serra@bsc.es

Thanks again in advance,
Best,
Feliu

@xuyiqing
Copy link
Owner

xuyiqing commented Apr 9, 2020 via email

@michaeldgarber
Copy link
Author

michaeldgarber commented Apr 13, 2020 via email

@gl-smith
Copy link

gl-smith commented Apr 14, 2020

Hi @xuyiqing and @liulch ,

I have been having the same error where running cumuEff provides the error:
Error in cumuEff(out, cumu = TRUE, id = NULL, period = c(0, 5)) : object 'D.boot' not found that others have mentioned.

For a point of reference, I am currently using the latest version of gsynth available on github (Version 1.1.6)

After looking at the source code, I noticed that D.boot first appears on line 61 in the line
(if (sum(c(D.boot)) == 0)). It looks like D.boot is never defined prior to line 61 and thus the source of the error. Would you be able to share the purpose of the D.boot object? If this is the only problem, the bug might have a relatively easy fix.

Thanks for all of the hard work on this package! It's a great resource.

Best,

Greg

@liulch
Copy link
Collaborator

liulch commented Apr 15, 2020 via email

@xuyiqing
Copy link
Owner

xuyiqing commented Apr 15, 2020 via email

@liulch
Copy link
Collaborator

liulch commented Apr 20, 2020 via email

@feliuserra
Copy link

Hi all,

Thanks to everyone for all the help. I have updated the gsynth package using devtools::install_github('xuyiqing/gsynth'). After that, the missing D.boot error no longer shows up. So, this error might be solved. Now it seems that D.boot and Dtr.boot are the same.

Also, I have checked the fix using the above mentioned code:

#30 (comment)

And it works fine.

However, I have found a new error. I should probably write it in a new issue, but I'll leave it in here just in case. I am just going to leave the error here and open a new issue if you think it's appropriate.

I have an out output, obtained running:

 system.time(out <- gsynth(f, 
                              data = final_df,
                              index = c('ID_new', 'time'),
                              force = "two-way", 
                              r = 2,
                              se = TRUE, 
                              CV=1, 
                              lambda = .01,
                              inference='jackknife',
                              nboots = 10, 
                              parallel = TRUE, 
                              min.T0=125))

Where f is the formula used, final_df is the dataframe used, and the rest of the parameters are just regular parameters. Please contact me on my email in case you need the object itself or the dataframe used to create this out object. The number of unique time periods is 757, the number of treated units is 308, and the number of control units is 543.

So far, the code runs smoothly, and I have tried it with different parameters/estimators and it works well. However, when I intend to execute the cumuEff function:

cumuEff(out, cumu=TRUE, period=NULL, id=NULL)

I obtain a new error. The error looks as follows:

Error in ts:te : result would be too long a vector

Googling for a similar error, I found that this might be because of the size of the panels that I am using. I am using a MacOS with 8 cores, i9 and 64GBs of RAM.

Then, I have tried tweaking the parameters available, such as period, and I still get the same error.

Can anyone point me in the right direction for the solution of this?

Sorry for the long post and thanks again. If someone believes that this should be a different issue please let me know and I will create it.

Thanks again for everything,

Best,

Feliu

@xuyiqing
Copy link
Owner

xuyiqing commented Apr 22, 2020 via email

@feliuserra
Copy link

Hi,

So, after giving it one more thought, I tried with a parametric estimator, instead of jackknife, and it worked. So either, this error is related to the 'jackknife' and cumulative effect for large samples, because it runs into a memory error, or something else that I am missing.

Thanks again for your help and interest, I believe there is no need to bother you anymore.The D.boot error has been solved.

Feliu

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants