View source: R/DisplayTreatment.R
DisplayTreatment | R Documentation |
DisplayTreatment
visualizes the treatment distribution
across units and time in a panel data set
DisplayTreatment(
unit.id,
time.id,
treatment,
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
)
unit.id |
Name of the unit identifier variable as a character string |
time.id |
Name of the time identifier variable as a character string |
treatment |
Name of the treatment variable as a character string |
data |
data.frame that contains the time series cross sectional data used for matching and estimation. Unit and time data must be integers. Time data must also be formatted as sequential integers that increase by one. |
color.of.treated |
Color of the treated observations provided as a character string (this includes hex values). Default is red. |
color.of.untreated |
Color of the untreated observations provided as a character string (this includes hex values). Default is blue. |
title |
Title of the plot provided as character string |
xlab |
Character label of the x-axis |
ylab |
Character label of the y-axis |
x.size |
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. |
y.size |
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. |
legend.position |
Position of the legend. Provide this according to ggplot2 standards. |
x.angle |
Angle (in degrees) of the tick labels for x-axis |
y.angle |
Angle (in degrees) of the tick labels for y-axis |
legend.labels |
Character vector of length two describing the labels of the legend to be shown in the plot. ggplot2 standards are used. |
decreasing |
Logical. Determines if display order should be increasing or decreasing by the amount of treatment received. Default is |
matched.set |
a matched.set object (optional) containing a single treated unit and a set of matched controls. If provided, this set will be highlighted on the resulting plot. |
show.set.only |
logical. If TRUE, only the treated unit and control units contained in the provided |
hide.x.tick.label |
logical. If TRUE, x axis tick labels are not shown. Default is FALSE. |
hide.y.tick.label |
logical. If TRUE, y axis tick labels are not shown. Default is FALSE. |
gradient.weights |
logical. If TRUE, the "darkness"/shade of units in the provided |
dense.plot |
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. |
DisplayTreatment
returns a treatment variation plot (using ggplot2 geom_tile() or geom_raster()),
which visualizes the variation of treatment across unit and time.
In Song Kim <insong@mit.edu>, Erik Wang <haixiao@Princeton.edu>, Adam Rauh <amrauh@umich.edu>, and Kosuke Imai <imai@harvard.edu>
DisplayTreatment(unit.id = "wbcode2",
time.id = "year", legend.position = "none",
xlab = "year", ylab = "Country Code",
treatment = "dem", data = dem)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.