Learn R Programming

rddtools (version 1.6.0)

plot.rdd_data: Plot rdd_data

Description

Binned plot of the forcing and outcome variable

Usage

# S3 method for rdd_data
plot(
  x,
  h = NULL,
  nbins = NULL,
  xlim = range(object$x, na.rm = TRUE),
  cex = 0.7,
  nplot = 1,
  device = c("base", "ggplot"),
  ...
)

Arguments

x

Object of class rdd_data

h

The binwidth parameter (note this differs from the bandwidth parameter!)

nbins

Alternative to h, the total number of bins in the plot.

xlim

The range of the x data

cex

Size of the points, see par

nplot

Number of plot to draw

device

Type of device used. Currently not used.

Further arguments passed to the plot function.

Value

A plot

Details

Produces a simple binned plot averaging values within each interval. The length of the intervals is specified with the argument h, specifying the whole binwidth (contrary to the usual bandwidth argument, that gives half of the length of the kernel window. When no bandwidth is given, the bandwidth of Ruppert et al is used, see rdd_bw_rsw.

Examples

Run this code
# NOT RUN {
data(house)
house_rdd <- rdd_data(y=house$y, x=house$x, cutpoint=0)
plot(house_rdd)

## Specify manually the bandwidth:
plot(house_rdd, h=0.2)

## Show three plots with different bandwidth:
plot(house_rdd, h=c(0.2,0.3,0.4), nplot=3)

## Specify instead of the bandwidth, the final number of bins:
plot(house_rdd, nbins=22)

## If the specified number of bins is odd, the larger number is given to side with largest range
plot(house_rdd, nbins=21)
# }

Run the code above in your browser using DataLab