Synthetic Controls - synth command

Hello everyone!

I am trying to apply the synth package in R but I have not been sucessful. In order to make it easier for you guys to help me, here it's an example of this package being sucessfully applied: https://cran.r-project.org/web/packages/MSCMT/vignettes/CheckingSynth.html

I am trying to run the code and the following message keeps showing up:

Error: Positive column indexes in [ must match number of columns:

  • .data has 31 columns
  • Position 807 equals 32
  • Position 808 equals 32
  • Position 809 equals 32
  • Position 810 equals 32
  • ... and 106102 more problems

As far as I understood, the program is not being able to read observations that have more than 31 (my number of columns) as a value for ID (my unit variable). However, both things should have nothing to do with each other.

R_code <- Intermediates1975limpo$ID = as.numeric(as.factor(Intermediates1975limpo$pairs))

dataprep.out <- dataprep(foo = Intermediates1975limpo,
predictors = "gdp_o",
predictors.op = "mean",
time.predictors.prior = 1980:1995,
dependent = "tradeflow",
unit.variable = Intermediates1975limpo$ID ,
unit.names.variable = "pairs",
time.variable = "year",
treatment.identifier = 541,
controls.identifier =c(1:540,542:19967),
time.optimize.ssr = 1975:1995,
time.plot = 1975:2000)

Does someone has ever had the same problem and could help me ?

*My dataset is completely balanced.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.