Reputation: 79
I am using the synth
package in R to implement a synthetic control method, where I use the dataprep()
function to construct the appropriate matrices to be passed to synth()
. That is, I call dataprep()
as follows:
dataprep_out <- dataprep(foo = csv_data,
predictors = vars_dep,
predictors.op = "mean",
time.predictors.prior = 2000:2010,
dependent = "Log_gdp",
unit.variable = "REG_FACTOR",
unit.names.variable = "REG_ID",
time.variable = "Year",
treatment.identifier = my_factor_treated,
controls.identifier = my_controls,
time.optimize.ssr = 2000:2010,
time.plot = 2000:2017
)
after which I call synth()
:
synth_out <- synth(data.prep.obj = dataprep_out)
This works fine and gives me the results I expect. However, when I repeat the same piece of code for another treated observation but with exactly the same controls (i.e., my_factor_treated
is the only argument in dataprep()
that has changed), I get the following error upon calling synth()
:
Error in svd(c) : infinite or missing values in 'x'.
I am struggling to find the cause of this error, also because I am unsure which object is being passed to the svd()
function during the execution of synth()
. None of the columns in the objects returned by dataprep()
contain only zeroes, and they contain no Inf values (which makes sense, because otherwise this error should have occurred on the first treated observation as well, right?).
I would appreciate if someone could tell me why this error occurs and how I can prevent it. I have checked out multiple related questions but haven't been able to find my answer. Thanks!
PS. I am not sure how to provide a suitable MWE since I guess my problem is data-related and I won't be able to share the dataset that I am using.
Upvotes: 2
Views: 2007
Reputation: 1
If the suggestion by @yang3122 does not work, the problem could be optimization process fails due to being computationally singular. In this case, you might want to make some adjustments to the Margin.ipop values within the synth() function. The default value is 5e-04, and a slight increase in this value may be able to resolve the optimization issue.
Upvotes: 0
Reputation: 11
I encountered the same issue, and the same as you did I confirmed there is no missing value or all 0's in my data set. Later I realized this is caused by optimization algorithm used in generating weights. One thing you can try is to add argument "optimxmethod='All'" in synth function. This will try all available methods and report you the one with best performance.
Upvotes: 1