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

gsynth fails with "'data' must be of a vector type, was 'NULL''"? when se=TRUE, works otherwise #56

Closed
simenfuglestad opened this issue Mar 5, 2021 · 19 comments

Comments

@simenfuglestad
Copy link

I have a data frame vdem5 with columns country, year, corruption, bnp and eu (the dichotomous treatment variable). I have tried using gsynth like this:

system.time(out <- gsynth(corruption ~ eu + democracy + bnp, data = vdem5,
index = c("country","year"), force = "two-way",
CV = TRUE, r= c(0,5), se = TRUE,
inference = "parametric", nboots = 1000,
parallel = FALSE))

Console output looks like this:

_Cross-validating ...
r = 0; sigma2 = 0.00244; IC = -5.93214; MSPE = 0.00582
r = 1; sigma2 = 0.00071; IC = -6.05075; MSPE = 0.00289
r = 2; sigma2 = 0.00033; IC = -5.78892; MSPE = 0.00255
r = 3; sigma2 = 0.00011; IC = -5.95324; MSPE = 0.00242
r = 4; sigma2 = 0.00000; IC = -69.55168; MSPE = 0.00225*
r = 5; sigma2 = -0.00000; IC = NaN; MSPE = Inf

r* = 4

Simulating errors ...Error in array(x, c(length(x), 1L), if (!is.null(names(x))) list(names(x), :
'data' must be of a vector type, was 'NULL'_

I have checked multiple times that vdem5 is not NULL and that all the columns have no missing data.

However, if I set se=FALSE it works:

system.time(out <- gsynth(corruption ~ eu + democracy + bnp, data = vdem5,
index = c("country","year"), force = "two-way",
CV = TRUE, r= c(0,5), se = false,
inference = "parametric", nboots = 1000,
parallel = FALSE))

Now it runs through just fine. Any idea why se=TRUE causes it to fail?

@liulch
Copy link
Collaborator

liulch commented Mar 16, 2021

Hi, I think that the error occurs on bootstrapped samples. Can you send us a dataset that only includes the id, time and treatment variables so we can try replicating the error? Thx!

@simenfuglestad
Copy link
Author

Hi again, and sorry for the late reply.

Here is a google drive link containing the exact rdata file I've used, if you prefer I send it to you by other means then please let me know.

Also, for what it's worth, adding more countries(units, but not increasing the time scope) seemed to resolve the issue.

@liulch
Copy link
Collaborator

liulch commented Mar 22, 2021

Thank you for the data. Will check it and reply to you.

@liulch
Copy link
Collaborator

liulch commented Apr 2, 2021

Hi @simenfuglestad, have you tried the GitHub version? I tried your data and didn't get this error...

Screen Shot 2021-04-02 at 10 14 41 AM

@simenfuglestad
Copy link
Author

Hello again,

That is odd, though I did install gsynth directly in R studio with install.packages("gsynth"). Do you suspect this to be the cause?

I tested it again with your exact code on the same dataset as well as a few variations, still get the same result. See the screenshots below.

2
1

@liulch
Copy link
Collaborator

liulch commented Apr 2, 2021

Ah, that's the problem! you installed from cran, which is an older version. You can try installing from GitHub by typing
devtools::install_github('xuyiqing/gsynth'). Hope it will help!

@simenfuglestad
Copy link
Author

So I completetly uninstalled the CRAN version of gsynth, reinstalled via devtools like you said and now it works like a charm. Thank you very much for alll your help!

@svknair
Copy link

svknair commented Aug 6, 2021

Hello,

I have been facing a similar issue raised above but the error message looks slightly different as shown below.

gsynth error1

I installed gsynth in RStudio. Based on suggestion above, I tried to install from GitHub but that has not worked. I tried to fix the problem using suggestions from this SO link but to no avail. I have installed gfortran and clang4 R Binaries from the links provided in the gsynth GitHub homepage. But the installation from GitHub just doesn't work. I get the following error message:

gsynth error2

Any suggestions how to fix this problem?

@xuyiqing
Copy link
Owner

xuyiqing commented Aug 6, 2021 via email

@svknair
Copy link

svknair commented Aug 6, 2021

Hi, are you installing from BigSur? If yes, please check out this file: https://yiqingxu.org/public/BigSurError.pdf

Yes, I am installing from BigSur 11.4. Thanks for sharing the solution. I will try that and let you know how it goes.

@xuyiqing
Copy link
Owner

xuyiqing commented Aug 6, 2021 via email

@svknair
Copy link

svknair commented Aug 6, 2021

I think I kind of lost my way after step 3. The problem is not solved. Here is what I did after step 3:

I did not have a .profile file, so I created a text file with that name and copied the following:

export PATH="/usr/local/gfortran/bin:/Library/Frameworks/R.framework/Resources:$PATH"

After that, checking for gcc version didn't work. So I typed sudo nano /etc/paths in terminal and added /usr/local/gfortran/bin at the beginning of the file. Then I completed step 4.2 by creating the .Renviron file.

For step 5, I didn't have a Makevars file, so I created it and pasted the following:

`FLIBS=-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin20/20.5.0 -L/usr/local/gfortran/lib

CC = gcc
CXX = g++
CXX98 = g++
CXX11 = g++
CXX14 = g++
CXX17 = g++
CXX20 = g++
CXXCPP = g++
FC = gfortran
F77 = gfortran
OBJC = gcc
OBJCXX = g++`

After all this I tried installing gsynth from GitHub and got the same error message as before. Not sure if I am doing anything wrong while trying to implement your solution.

@xuyiqing
Copy link
Owner

xuyiqing commented Aug 6, 2021 via email

@svknair
Copy link

svknair commented Aug 6, 2021

Hi,

Appreciate your time and help.

Thanks

@xuyiqing
Copy link
Owner

xuyiqing commented Aug 6, 2021 via email

@xuyiqing
Copy link
Owner

xuyiqing commented Aug 6, 2021 via email

@svknair
Copy link

svknair commented Aug 9, 2021

I downloaded the latest version (1.2.1) from CRAN. But R aborts while running gsynth. I tried running gsynth after setting se = FALSE and got the following error:

Error in data_ub_adj(data_I, data_ub) : function 'Rcpp_precious_remove' not provided by package 'Rcpp'

Do you think this is still related to the macOS problem?

@xuyiqing
Copy link
Owner

xuyiqing commented Aug 9, 2021 via email

@svknair
Copy link

svknair commented Aug 9, 2021

Yes, I have installed Rcpp. I actually updated Rcpp package to the latest version and now gsynth works fine. Thanks much for your help!

@xuyiqing xuyiqing closed this as completed Aug 9, 2021
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

4 participants