Skip to content

Instantly share code, notes, and snippets.

@medewitt
Created October 7, 2019 19:38
Show Gist options
  • Save medewitt/95ba74fcb66e392ed857843be69ee4b0 to your computer and use it in GitHub Desktop.
Save medewitt/95ba74fcb66e392ed857843be69ee4b0 to your computer and use it in GitHub Desktop.
library(Synth)
data(synth.data)
synth.data$dummy <- rnorm(168, 0, .00001)
# create matrices from panel data that provide inputs for synth()
dataprep.out<-
dataprep(
foo = synth.data,
predictors = c("dummy"),
predictors.op = "mean",
dependent = "Y",
unit.variable = "unit.num",
time.variable = "year",
treatment.identifier = 7,
controls.identifier = c(29, 2, 13, 17, 32, 38),
time.predictors.prior = c(1984:1989),
time.optimize.ssr = c(1984:1990),
unit.names.variable = "name",
time.plot = 1984:1996
)
out <- synth(data.prep.obj = dataprep.out)
path.plot(synth.res = out, dataprep.res = dataprep.out)
dataprep.out$Y1plot - (dataprep.out$Y0plot %*% out$solution.w)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment