xuyiqing / gsynth

Generalized Synthetic Control Method
Other
131 stars 40 forks source link

problem with single case treatment in gsynth - get Error in rowSums(Y.ct) : 'x' must be an array of at least two dimensions #45

Open hamaluco opened 4 years ago

hamaluco commented 4 years ago

hello

I have some trouble with the gsynth function using r on OS

I want to analyse the economic growth effects of EU membership for Croatia. The SCM will pool from the neighbouring Balkan countries to conduct the analysis, none of which are EU members. Thus, this analysis apply a single case/unit treatment. However, after a lot of struggle I cannot seem to be able to do this with gsynth.

When I try to run gsynth I have my treatment variable (EU) and DV (growth) as well as some control variables, but the error I have been getting is this:

Error in rowSums(Y.ct) : 'x' must be an array of at least two dimensions

library(gsynth) Registered S3 method overwritten by 'GGally': method from
+.gg ggplot2

system.time(m1 <- gsynth(gdpprcapitagrowth ~ eu + industry + agriculture + populationgrowth + uneployment + tradeinservices, data = qog, index = c("country", "year"), force = "two-way", EM = TRUE, CV = TRUE, r = c(0, 5), se = TRUE, na.rm = TRUE, inference = "parametric", nboots = 1000, parallel = FALSE))

Error in rowSums(Y.ct) : 'x' must be an array of at least two dimensions Timing stopped at: 0.055 0.009 0.078

I gathered that this was a problem with with my treatment and its lack of varying dimensions on it, so I tried adding another EU member state (that would receive the treatment) to the analysis, Bulgaria, and with this the gsynth function worked with no errors

My question is then the following: Is gsynth only possible for multiple with treatments with multiple units and not as in my case where only one unit receives treatment? Because this seems to be the case right now

Thank you and apologies for any potential misunderstandings of my question. I am quite new to github and to R

xuyiqing commented 4 years ago

It should be able to accommodate a single treated unit (it could be bug though). Have you installed the most up-to-date version?

If yes, could you send us via email some sample data and code for us to replicate your error?

yiqingxi@stanford.edu liulch@mit.edu

On Tue, Jul 7, 2020 at 4:05 PM hamaluco notifications@github.com wrote:

hello

I have some trouble with the gsynth function using r on OS

I want to analyse the economic growth effects of EU membership for Croatia. The SCM will pool from the neighbouring Balkan countries to conduct the analysis, none of which are EU members. Thus, this analysis apply a single case/unit treatment. However, after a lot of struggle I cannot seem to be able to do this with gsynth.

When I try to run gsynth I have my treatment variable (EU) and DV (growth) as well as some control variables, but the error I have been getting is this:

Error in rowSums(Y.ct) : 'x' must be an array of at least two dimensions

library(gsynth) Registered S3 method overwritten by 'GGally': method from +.gg ggplot2

system.time(m1 <- gsynth(gdpprcapitagrowth ~ eu + industry + agriculture + populationgrowth + uneployment + tradeinservices, data = qog, index = c("country", "year"), force = "two-way", EM = TRUE, CV = TRUE, r = c(0, 5), se = TRUE, na.rm = TRUE, inference = "parametric", nboots = 1000, parallel = FALSE))

Error in rowSums(Y.ct) : 'x' must be an array of at least two dimensions Timing stopped at: 0.055 0.009 0.078

I gathered that this was a problem with with my treatment and its lack of varying dimensions on it, so I tried adding another EU member state (that would receive the treatment) to the analysis, Bulgaria, and with this the gsynth function worked with no errors

My question is then the following: Is gsynth only possible for multiple with treatments with multiple units and not as in my case where only one unit receives treatment? Because this seems to be the case right now

Thank you and apologies for any potential misunderstandings of my question. I am quite new to github and to R

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

-- Yiqing Xu

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

hamaluco commented 4 years ago

I believe my version is the CRAN version gsynth_1.0.9. I did check for updates using update.packages and checked trough old.packages but this seemed to be the latest one

mduska commented 3 years ago

Hello,

I am having a similar problem using RStudio on OS (I have tried CRAN v1.0.9 and Github v1.1.7, and get the same error). I also only have a single case in my treatment group. Were you ever able to resolve this?

Thanks!

xuyiqing commented 3 years ago

Could one of you send us via email some sample data and code for us to replicate your error?

On Sat, Feb 20, 2021 at 5:43 PM mduska notifications@github.com wrote:

Hello,

I am having a similar problem using RStudio on OS (I have tried CRAN v1.0.9 and Github v1.1.7, and get the same error). I also only have a single case in my treatment group. Were you ever able to resolve this?

Thanks!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/xuyiqing/gsynth/issues/45#issuecomment-782779129, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB2PKGBGRZJ5G6JESOFDAJTTABQNHANCNFSM4OT2GEGA .

-- Yiqing Xu

Assistant Professor Department of Political Science University of California, San Diego http://yiqingxu.org/

mduska commented 3 years ago

Could one of you send us via email some sample data and code for us to replicate your error? On Sat, Feb 20, 2021 at 5:43 PM mduska @.***> wrote: Hello, I am having a similar problem using RStudio on OS (I have tried CRAN v1.0.9 and Github v1.1.7, and get the same error). I also only have a single case in my treatment group. Were you ever able to resolve this? Thanks! — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#45 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB2PKGBGRZJ5G6JESOFDAJTTABQNHANCNFSM4OT2GEGA . -- Yiqing Xu Assistant Professor Department of Political Science University of California, San Diego http://yiqingxu.org/

Just sent to your email listed above.