Learn R Programming

panelView (version 1.0.1)

panelView: Panel Data Visualizations

Description

Visualizes panel data with dichotomous treatments

Usage

panelView(formula, data, index, na.rm = FALSE, outcome.type = "c", 
                 type = "missing", by.group = FALSE, theme.bw = FALSE,
                 xlim = NULL, ylim = NULL, 
                 xlab = NULL, ylab = NULL, legendOff = FALSE, 
                 legend.labs = NULL, main = NULL, id = NULL, show.id = NULL,
                 raw.color = NULL, axis.adjust = FALSE, axis.lab = "both", 
                 axis.lab.gap = c(0, 0))

Arguments

formula

an object of class "formula": a symbolic description of the model to be fitted. The first variable on the right-hand-side is designated as the treatment indicator.

data

a data frame (must be with a dichotomous treatment); the panel does not have to be balanced.

index

a two-element string vector specifying the unit (group) and time indicators. Must be of length 2.

na.rm

a logical flag indicating whether to list-wise delete missing data. The algorithm will report an error if missing data exist.

outcome.type

a string that specifies the numerical type of outcome variable. Must be either "c"(default) for continuous response or "d" for discrete response. For continuous response, time series lines for specified units will be plotted, and for discrete response, jittered points at each period will be plotted.

type

a string that specifies the type of the plot. Must be either "missing" (default), which plots the treatment/missing-data status of each unit at each time point) or "raw", which plots the raw outcome data

by.group

a logic flag indicating whether the data should be plotted in separate groups based on treatment status changes.

theme.bw

a logical flag specifying whether to use the theme with white background and without grid lines.

xlim

a two-element numeric vector specifying the range of x-axis. When the class of time variable is string, must specify the range of strings to be shown, e.g. xlim=c(1,30).

ylim

a two-element numeric vector specifying the range of y-axis.

xlab

a string indicating the label of the x-axis.

ylab

a string indicating the label of the y-axis.

legendOff

a logical flag controlling whether to show the legend.

legend.labs

a vector specifying the legend labels. Ignored when legendOff=TRUE.

main

a string that controls the title of the plot.

id

a vector specifying units to be shown in the plot. Useful when the number of units is very large.

show.id

a numeric vector or sequence specifying the sorted order of units to be shown in the "missing" plot. Useful when the number of units is very large. Ignored if !is.null("id").

raw.color

a string vector specifying color setting for the raw plot. If there are no reversals among treated units and by.group = FALSE, must in the sequence of: color for control group units, color for treated group units in pre-treatment period and color for treated units in post-treatment period(thus length equals to 3); else must be in the sequence of: color for control status and color for treated status(length equals to 2). If left blank, default color setting will be used.

axis.adjust

a logic flag indicating whether to adjust labels on the x-axis. Useful when the class of time variable is string and there are many time periods.

axis.lab

a string indicating whether labels on the x- and y-axis will be shown. There are four options: "both" (default): labels on both axes will be shown; "unit": only labels on y-axis will be shown; "time": only labels on the x-axis will be shown; "none": no labels will be shown.

axis.lab.gap

a numeric vector setting the gaps between labels on the x- or y-axis for "missing" plot. Default is axis.lab.gap = c(0, 0), which means that all labels will be shown. Useful for datasets with large N or T.

Details

panelView visualizes treatment status, missing values, and the raw outcome data of a time-series cross-sectional dataset with a dichotomous treatment indicator.

For more details, see http://yiqingxu.org/software/panelView/panelView.html.

Examples

Run this code
# NOT RUN {
library(panelView)
data(panelView)
panelView(turnout ~ policy_edr + policy_mail_in + policy_motor, 
          data = turnout, index = c("abb","year"))
# }

Run the code above in your browser using DataLab