ebenmichael / augsynth

Augmented Synthetic Control Method
MIT License
147 stars 52 forks source link

Error in running multisynth: "Error in rowMeans(residuals[, 1:tj], na.rm = TRUE) : 'x' must be an array of at least two dimensions" #41

Closed Ales-G closed 3 years ago

Ales-G commented 3 years ago

Hello, first of all thank you very much for your great work: augsynth is a great package! I am trying to estimate a multisynth (ppool_syn <- multisynth(y ~ treat,id,time,data, n_leads = 3)model with only a reduced number of leads. However, when I run it generates the following error: Error in rowMeans(residuals[, 1:tj], na.rm = TRUE) : 'x' must be an array of at least two dimensions. Do you know what may be causing this problem and if there is any possibility for me to overcome it?

Thanks a lot in advance for your help

Best regards

ebenmichael commented 3 years ago

I think the problem is that the smallest pre-treatment length is 1? In that case, residuals[, 1:tj] becomes a vector instead of a matrix and so rowMeans doesn't work. I just pushed a quick change to fix this by making it residuals[, 1:tj, drop = F]. Let me know if that solves the problem! If not, we can try to debug.