Skip to content

Instantly share code, notes, and snippets.

@bgall
Created February 14, 2018 19:42
Show Gist options
  • Save bgall/52ba9cc78ade12ad4f2969efc418df7f to your computer and use it in GitHub Desktop.
Save bgall/52ba9cc78ade12ad4f2969efc418df7f to your computer and use it in GitHub Desktop.
Conditioning on the dependent variable changes the L in LATE
# Load packages
library(dplyr)
# Create data
set.seed(1)
x <- rnorm(1000000, mean = 0, sd = 1)
y <- x*x
full <- data.frame(x, y)
# Full data OLS
lm(y ~ x, data = full) %>% summary()
# Condition sample on tails of observed distribution
partial <- full %>% dplyr::filter(y > quantile(y, 0.8) | y < quantile(y, 0.2))
# Partial data OLS
lm(y ~ x, data = partial) %>% summary()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment