DisplayTreatment: DisplayTreatment

View source: R/DisplayTreatment.R

DisplayTreatmentR Documentation

DisplayTreatment

Description

DisplayTreatment visualizes the treatment distribution across units and time in a panel data set

Usage

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
)

Arguments

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 decreasing = FALSE.

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 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.

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 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.

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.

Value

DisplayTreatment returns a treatment variation plot (using ggplot2 geom_tile() or geom_raster()), which visualizes the variation of treatment across unit and time.

Author(s)

In Song Kim <insong@mit.edu>, Erik Wang <haixiao@Princeton.edu>, Adam Rauh <amrauh@umich.edu>, and Kosuke Imai <imai@harvard.edu>

Examples


DisplayTreatment(unit.id = "wbcode2",
                 time.id = "year", legend.position = "none",
                 xlab = "year", ylab = "Country Code",
                 treatment = "dem", data = dem)



PanelMatch documentation built on June 22, 2024, 10:32 a.m.