plot_placebos {SCtools} | R Documentation |
Function to plot placebos of a synthetic control analysis
Description
Creates plots with the difference between observed units and synthetic controls for the treated and control units. See Abadie, Diamond, and Hainmueller (2011).
Usage
plot_placebos(
tdf = tdf,
discard.extreme = FALSE,
mspe.limit = 20,
xlab = NULL,
ylab = NULL,
title = NULL,
alpha.placebos = 1,
...
)
Arguments
tdf |
An object with a list of outcome values for placebos,
constructed by |
discard.extreme |
Logical. Whether or not units with high pre-treatement
MSPE should be excluded from the plot. Takes a default of |
mspe.limit |
Numerical. Used if |
xlab |
Character. Optional. Label of the x axis. |
ylab |
Character. Optional. Label of the y axis. |
title |
Character. Optional. Title of the plot. |
alpha.placebos |
the transparency setting, default of |
... |
optional arguments (currently not used) |
Value
p.gaps Gaps plot indicating difference between the treated unit, the placebos, and their respective synthetic controls.
See Also
generate.placebos
, gaps.plot
,
synth
, dataprep
Examples
## Example with toy data from Synth
library(Synth)
# Load the simulated data
data(synth.data)
# Execute dataprep to produce the necessary matrices for synth
dataprep.out<-
dataprep(
foo = synth.data,
predictors = c("X1"),
predictors.op = "mean",
dependent = "Y",
unit.variable = "unit.num",
time.variable = "year",
special.predictors = list(
list("Y", 1991, "mean")
),
treatment.identifier = 7,
controls.identifier = c(29, 2, 13, 17),
time.predictors.prior = c(1984:1989),
time.optimize.ssr = c(1984:1990),
unit.names.variable = "name",
time.plot = 1984:1996
)
# run the synth command to create the synthetic control
synth.out <- synth(dataprep.out, Sigf.ipop=2)
## run the generate.placebos command to reassign treatment status
## to each unit listed as control, one at a time, and generate their
## synthetic versions. Sigf.ipop = 2 for faster computing time.
## Increase to the default of 5 for better estimates.
tdf <- generate.placebos(dataprep.out,synth.out, Sigf.ipop = 2, strategy='multicore')
## Plot the gaps in outcome values over time of each unit --
## treated and placebos -- to their synthetic controls
p <- plot_placebos(tdf,discard.extreme=TRUE, mspe.limit=10, xlab='Year')
p