Regression discontinuity I

Content for Thursday, March 26, 2026

Readings

Regression discontinuity

Slides

The slides for today’s lesson are available online as an HTML file. Use the buttons below to open the slides either as an interactive website or as a static PDF (for printing or storing for later). You can also click in the slides below and navigate through them with your left and right arrow keys.

View all slides in new window Download PDF of all slides

Tip

Fun fact: If you type ? (or shift + /) while going through the slides, you can see a list of special slide-specific commands.

Videos

Videos for each section of the lecture are available at this YouTube playlist.

You can also watch the playlist (and skip around to different sections) here:

In-class stuff

Here are all the materials we’ll use in class:

Quarto website resources:

Examples:

Other Quarto things

ggplotly() example:

library(tidyverse)
library(plotly)
library(gapminder)

plot_thing <- gapminder |> 
  filter(year == 2007) |> 
  ggplot(aes(x = gdpPercap, y = lifeExp, color = continent)) +
  geom_point(aes(text = country)) +  # text is a special aesthetic for plotly labels
  scale_x_log10()

ggplotly(plot_thing)

OJS example:

NoteR

This is R code!

# Make the gapminder data available to Observable JS
ojs_define(gapminder = gapminder)
NoteObservable

This is NOT R code! This is Observable JS code!

viewof current_year = Inputs.range(
  [1952, 2007], 
  {value: 1952, step: 5, label: "Year:"}
)

// Rotate the data so that it works with OJS
gapminder_js = transpose(gapminder)

// Filter the data based on the selected year
gapminder_filtered = gapminder_js.filter(d => d.year == current_year)

// Plot this thing
Plot.plot({
  x: {type: "log"},
  marks: [
    Plot.dot(gapminder_filtered, {
        x: "gdpPercap", y: "lifeExp", fill: "continent", r: 6,
        channels: {
          Country: d => d.country
        },
        tip: true
      }
    )
  ]}
)

References

Gertler, Paul J., Sebastian Martinez, Patrick Premand, Laura B. Rawlings, and Christel M. J. Vermeersch. 2016. Impact Evaluation in Practice. 2nd ed. Washington, DC: Inter-American Development Bank and World Bank. https://doi.org/10.1596/978-1-4648-0779-4.
Huntington-Klein, Nick. 2021. The Effect: An Introduction to Research Design and Causality. Boca Raton, Florida: Chapman and Hall / CRC. https://theeffectbook.net/.