RDScatter: Scatterplot of binned raw observations

View source: R/plots.R

RDScatterR Documentation

Scatterplot of binned raw observations

Description

Scatterplot of raw observations in which each point corresponds to an binned average.

Usage

RDScatter(
  formula,
  data,
  subset,
  cutoff = 0,
  na.action,
  avg = 10,
  xlab = NULL,
  ylab = NULL,
  vert = TRUE,
  propdotsize = FALSE
)

Arguments

formula

object of class "formula" (or one that can be coerced to that class) of the form outcome ~ running_variable

data

optional data frame, list or environment (or object coercible by as.data.frame to a data frame) containing the outcome and running variables in the model. If not found in data, the variables are taken from environment(formula), typically the environment from which the function is called.

subset

optional vector specifying a subset of observations to be used in the fitting process.

cutoff

specifies the RD cutoff for the running variable.

na.action

function which indicates what should happen when the data contain NAs. The default is set by the na.action setting of options (usually na.omit). Another possible value is na.fail

avg

Number of observations to average over. If set to Inf, then take averages for each possible value of the running variable (convenient when the running variable is discrete).

xlab, ylab

x- and y-axis labels

vert

Draw a vertical line at cutoff?

propdotsize

If TRUE, then size of points is proportional to number of observations that the point averages over (useful when avg=Inf). Otherwise the size of points is constant.

Value

An object of class "ggplot", a scatterplot the binned raw observations.

Note

subset is evaluated in the same way as variables in formula, that is first in data and then in the environment of formula.

Examples

RDScatter(log(earnings)~yearat14, data=cghs, cutoff=1947,
               avg=Inf, propdotsize=TRUE)

kolesarm/RDHonest documentation built on April 14, 2024, 3:27 a.m.