Visualize the treatment distribution across units and time in a panel data set
DisplayTreatment(
panel.data,
color.of.treated = "red",
color.of.untreated = "blue",
title = "Treatment Distribution \n Across Units and Time",
xlab = "Time",
ylab = "Unit",
x.size = NULL,
y.size = NULL,
legend.position = "none",
x.angle = NULL,
y.angle = NULL,
legend.labels = c("not treated", "treated"),
decreasing = FALSE,
matched.set = NULL,
show.set.only = FALSE,
hide.x.tick.label = FALSE,
hide.y.tick.label = FALSE,
gradient.weights = FALSE,
dense.plot = FALSE
)
DisplayTreatment
returns a treatment variation plot (generated via ggplot2 geom_tile() or geom_raster()),
which visualizes the variation of treatment across units and time. The results can be customized using ggplot2 syntax.
PanelData
object
Color of the treated observations provided as a character string (this includes hex values). Default is red.
Color of the untreated observations provided as a character string (this includes hex values). Default is blue.
Title of the plot provided as character string
Character label of the x-axis
Character label of the y-axis
Numeric size of the text for xlab or x axis tick labels. Assign x.size = NULL to use built in ggplot2 method of determining label size. When the length of the time period is long, consider setting to NULL and adjusting size and ratio of the plot.
Numeric size of the text for ylab or y axis tick labels. Assign y.size = NULL to use built in ggplot2 method of determining label size. When the number of units is large, consider setting to NULL and adjusting size and ratio of the plot.
Position of the legend. Provide this according to ggplot2 standards.
Angle (in degrees) of the tick labels for x-axis
Angle (in degrees) of the tick labels for y-axis
Character vector of length two describing the labels of the legend to be shown in the plot. ggplot2 standards are used.
Logical. Determines if display order should be increasing or decreasing by the amount of treatment received. Default is decreasing
= FALSE.
(optional) a matched.set
object containing a single treated unit and a set of matched controls. If provided, this set will be highlighted on the resulting plot.
(optional) logical. If TRUE, only the treated unit and control units contained in the provided matched.set
object will be shown on the plot.
Default is FALSE. If no matched.set
is provided, then this argument will have no effect.
logical. If TRUE, x axis tick labels are not shown. Default is FALSE.
logical. If TRUE, y axis tick labels are not shown. Default is FALSE.
(optional) logical. If TRUE, the "darkness"/shade of units in the provided matched.set
object will be displayed according to their weight. Control units with higher weights will appear darker on the resulting plot. Control units with lower weights will appear lighter. This argument has no effect unless a matched.set
is provided.
logical. if TRUE, lines between tiles are removed on resulting plot. This is useful for producing more readable plots in situations where the number of units and/or time periods is very high.
In Song Kim <insong@mit.edu>, Erik Wang <haixiao@Princeton.edu>, Adam Rauh <amrauh@umich.edu>, and Kosuke Imai <imai@harvard.edu>
dem.panel <- PanelData(panel.data = dem,
unit.id = "wbcode2",
time.id = "year",
treatment = "dem",
outcome = "y")
DisplayTreatment(panel.data = dem.panel,
legend.position = "none",
xlab = "year", ylab = "Country Code")
Run the code above in your browser using DataLab