0

I am currently writing a research project on the effects of voting behaviour after the closure of mines in a given area. For this research I have chosen the 'synthetic control' method. Now, I have run into trouble with the synth package, namely, each time that I try to dataprep the data to create the synthetic control unit I get error messages. These messages show the the following:

"Your panel, as described by unit.variable and time.variable, is unbalanced. Balance it and run again."

I have currently modelled my data after the Abadie's dataset used in his study on terrorism in the Basque region. And I ought to note that there is no missing data in my dataset, nor are there outliers.

I have tried to make several changes to my code, however, each time I try this, I run into trouble. Moreover, I have tried copying code from others who came up with a solution, but this did not work either. I would be very very thankful if someone could help me with my problem.

Some other lovely person has helped me with my previous problem, for which I am very grateful. However, being new to coding, I do not really have any idea as to how to solve my problem.

enter code here {dataprep_outcomes <- dataprep(foo=dataset [dataset$Year %in% c(1948:1986),],
                          predictors = c("Income","Distance","Gini","Percentage_voted","Protest"),
                          dependent = c("Percentage_voted"),
                          unit.variable = c("Municipality_No"),
                          time.variable = c("Year"),
                          treatment.identifier = 1, 
                          controls.identifier = c(2:14),
                          time.predictors.prior = intersect(1948:1965, dataset$Year),
                          time.optimize.ssr = intersect(1948:1986, dataset$Year),
                          unit.names.variable = c("Municipality_ID"),
                          time.plot = intersect("1948:1986"), dataset$Year)}

I would like to run my dataprep. If one has suggestions regarding the manner in which I can alter my data, that would be welcome as well!

Thank you in advance.

jkdev
  • 11,360
  • 15
  • 54
  • 77
Alex
  • 13
  • 6
  • 1
    We need at least a sample of your data. I don’t know though is the sample will show us why you are getting an unbalanced data error. Can you edit your question and include the output of `dput( yourdataframe)`. If the output is really big, like several dozen lines or more, use `dput(head(yourdataframe,10))`. That’ll at least give us an idea of your data. – shea Jan 06 '19 at 16:37
  • Dear Shea, so now I do not get the error message anymore, which is great. However, I do get the message "Error in as.vector(y) : argument "y" is missing, with no default", I don't know if you would have any suggestions as how to fix this? – Alex Jan 06 '19 at 16:50
  • The `Error in as.vector(y)` occurs in your last line. You're feeding `intersect` only a single argument. I think it should read `time.plot = intersect(1948:1986, dataset$Year))`. – Brendan A. Jan 06 '19 at 17:28
  • Thank you to all who responded, the solution did indeed work! – Alex Jan 06 '19 at 17:39

0 Answers0