xuyiqing / gsynth

Generalized Synthetic Control Method
Other
132 stars 40 forks source link

Error object 'eff.cnt' not found when using normalization #14

Open inkrement opened 6 years ago

inkrement commented 6 years ago

Even a basic regression like:

gsynth_res <- gsynth(y ~ step_dummy, data = gsynth_panel, index = c("channel_id","date"))

fails, when I set the option normalize to True. The output indicates a unspecified variable:

Parallel computing ...
Cross-validating ... 
 r = 0; sigma2 = 0.05228; IC = -2.95122; MSPE = 0.00071
 r = 1; sigma2 = 0.02246; IC = -3.62720; MSPE = 0.00009
 r = 2; sigma2 = 0.00185; IC = -5.95540; MSPE = 0.00000
 r = 3; sigma2 = 0.00077; IC = -6.66797; MSPE = 0.00000*
 r = 4; sigma2 = 0.00038; IC = -7.20358; MSPE = 0.00000
 r = 5; sigma2 = 0.00022; IC = -7.58177; MSPE = 0.00000

 r* = 3

Error in synth.core(Y = Y, X = X, D = D, I = I, W = W, r = r, r.end = r.end,  : 
  object 'eff.cnt' not found

ps: I am using the newest version (github-master).

GrimTrigger88 commented 6 years ago

I haven't been able to diagnose the error yet, but just take a look at the normalization implementation to make sure that it is what you want:

## normalize
norm.para <- NULL
if (normalize == TRUE) {
    sd.Y <- sd(as.matrix(data[,Yname]))
    data[,c(Yname, Xname)] <- data[,c(Yname, Xname)]/sd.Y
    norm.para <- sd.Y ## normalized parameter
}

If you want column-wise normalization, I recommend doing it prior to running gsynth.

inkrement commented 6 years ago

Ok, I haven't checked the source code in detail. But it is weird that there is no reference to eff.cnt in your extract. However, just removing the flag lead to a successful run.

xuyiqing commented 6 years ago

Thank you, Christian. We'll deal with it soon!

On Mon, May 14, 2018 at 11:27 AM, Christian Hotz-Behofsits < notifications@github.com> wrote:

Ok, I haven't checked the source code in detail. But it is weird that there is no reference to eff.cnt in your extract. However, just removing the flag lead to a successful run.

— 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/14#issuecomment-388916357, or mute the thread https://github.com/notifications/unsubscribe-auth/AHT1GAl5GhIZuk_oE0PCUGT7aS_YSg7Nks5tycycgaJpZM4T9RCC .

-- Yiqing Xu

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