This page demonstrates the usage of panelView, a function of the gsynth package. panelView has two main functionalities: (1) it can visualize the treatment/missing-value status of each observation in a panel/TSCS dataset; and (2) it can plot the outcome variable (or any continuous variable in the panel dataset) in a time-series fashion.

For more information of the gsynth package, please click here.

Authors: Yiqing Xu (UCSD); Licheng Liu (Tsinghua)

Date: Jan 22, 2018

Package: gsynth (v.1.0.8)


Installation

You can install the gsynth package from the following Github repository:

install.packages('devtools', repos = 'http://cran.us.r-project.org') # if not already installed
devtools::install_github('xuyiqing/gsynth')

Show treatment status and missing values

First, we show how we can visualize the treatment status and missing values in a panel dataset. The treatment indicator must be dichotomous. We first load data from the gsynth package.

library(gsynth)
data(gsynth)
ls()
## [1] "capacity" "simdata"  "turnout"

Using the turnout dataset (a balanced panel), we show the treatment status of Election Day Registration (EDR) in each state in a given year. The first variable on the right-hand-side of the regression formula is designated as the treatment indicator. Including covariates may change the plot because of missing values in these covariates. The index option specifies the unit (group) and time indicators. We can change the labels (titles) of x- and y-axes through xlab and ylab, respectively.

panelView(turnout ~ policy_edr + policy_mail_in + policy_motor, data = turnout, 
          index = c("abb","year"), xlab = "Year", ylab = "State")

We can use the main option to change the title of the plot, use the axis.lab.gap option to change the gaps between labels on the x- and y-axes, and use the legend.labs option to change the labels shown in the legend.

panelView(turnout ~ policy_edr + policy_mail_in + policy_motor, data = turnout,
          index = c("abb","year"), main = "EDR Reform", axis.lab.gap = c(1,2),
          legend.labs = c("Treated States (before EDR)", "Treated States (after EDR)", "Control States"))

We can turn off the labels on the y-axis (or x-axis) by specifying axis.lab = "time" (or "unit"). Specifying axis.lab = "off" will turn off labels on both axes. The default is axis.lab = "both".

panelView(turnout ~ policy_edr + policy_mail_in + policy_motor, data = turnout, 
          index = c("abb","year"), main = "EDR Reform", axis.lab = "time")