rddapp (version 1.1.0)

plot.rd: Plot the Regression Discontinuity plot.rd plots the relationship between the running variable and the outcome. It is based on the plot.RD function in the rdd package.

Description

Plot the Regression Discontinuity

plot.rd plots the relationship between the running variable and the outcome. It is based on the plot.RD function in the rdd package.

Usage

# S3 method for rd
plot(x, preds = NULL, fit_line = c("linear", "quadratic",
  "cubic", "optimal", "half", "double"), fit_ci = c("area", "dot", "hide"),
  fit_ci_level = 0.95, bin_n = 20, bin_level = 0.95,
  bin_size = c("shade", "size"), quant_bin = TRUE, xlim = NULL,
  ylim = NULL, include_rugs = FALSE, ...)

Arguments

x

An rd object, typically the result of rd_est.

preds

Predictions generated by predict.rd.

fit_line

Models to be shown as fitted lines.

fit_ci

Whether and how to plot prediction CIs around the fitted lines.

fit_ci_level

Confidence level of prediction CIs.

bin_n

Number of bins for binned data points (plot raw data points if = 0; suppress data points if < 0).

bin_level

Confidence level for CIs around binned data points.

bin_size

How to plot the number of observations in each bin.

quant_bin

Whether the data are binned per quantiles.

xlim

x-axis limits.

ylim

y-axis limits.

include_rugs

Whether to include 1d plot for both axes.

...

Additional arguments affecting the plots produced.

Examples

Run this code
# NOT RUN {
 
dat <- data.frame(x = runif(1000, -1, 1), cov = rnorm(1000))
dat$tr <- as.integer(dat$x >= 0)
dat$y <- 3 + 2 * dat$x + 3 * dat$cov + 10 * (dat$x >= 0) + rnorm(1000)
rd <- rd_est(y ~ x + tr | cov, data = dat, cutpoint = 0, t.design = "geq") 
plot(rd)
# }

Run the code above in your browser using DataCamp Workspace