| Źródło |
Reproduced in R based on the code presented in the CC-BY-3.0 and GPL licensed open science paper:
Abadie, Alberto and Diamond, Alexis J. and Hainmueller, Jens, Synth: An R Package for Synthetic Control Methods in Comparative Case Studies (June 2011). Journal of Statistical Software, Vol. 42, Issue 13, June 2011. Paper and license information available at: https://www.jstatsoft.org/article/view/v042i13
# from http://www.jstatsoft.org/v42/i13/paper on CC-BY-3.0/GPL license
library(Synth)
data("basque")
dataprep.out <- dataprep(
foo = basque,
predictors = c("school.illit", "school.prim", "school.med",
"school.high", "school.post.high", "invest"),
predictors.op = "mean",
time.predictors.prior = 1964:1969,
special.predictors = list(
list("gdpcap", 1960:1969 , "mean"),
list("sec.agriculture", seq(1961, 1969, 2), "mean"),
list("sec.energy", seq(1961, 1969, 2), "mean"),
list("sec.industry", seq(1961, 1969, 2), "mean"),
list("sec.construction", seq(1961, 1969, 2), "mean"),
list("sec.services.venta", seq(1961, 1969, 2), "mean"),
list("sec.services.nonventa", seq(1961, 1969, 2), "mean"),
list("popdens", 1969, "mean")),
dependent = "gdpcap",
unit.variable = "regionno",
unit.names.variable = "regionname",
time.variable = "year",
treatment.identifier = 17,
controls.identifier = c(2:16, 18),
time.optimize.ssr = 1960,
time.plot = 1955:1997)
synth.out <- synth(data.prep.obj = dataprep.out, method = "BFGS")
gaps <- dataprep.out$Y1plot - (dataprep.out$Y0plot %*% synth.out$solution.w)
path.plot(synth.res = synth.out, dataprep.res = dataprep.out,
Ylab = "realne PKB per capita (tys. 1986 USD)", Xlab = "rok",
Ylim = c(0, 12), Legend = c("Kraj Basków", "syntetyczny Kraj Basków"),
Legend.position = "bottomright")
|