library(tidyverse) library(fixest) N <- 100000 X <- tibble( y = rnorm(N), x1 = rnorm(N) ) %>% mutate( x2_a = rnorm(N), x2_b = -1*x1 + rnorm(N, sd = 0.2), x2_c = 1*x1 + rnorm(N, sd = 0.2) ) cor(X$x1,X$x2_b) # X %>% # ggplot( # aes(x = x1, y = x2_c) # ) + # geom_point() M <- 10000 iter <- 10:M %>% map_dfr( function(s){ out <- X %>% sample_n(size = s, replace = TRUE) %>% feols( x1 ~ x2_b, data = . ) out$coeftable %>% as_tibble(rownames = "term") %>% slice(2) } ) iter %>% mutate( N = 10:M ) %>% ggplot( aes(x = N, y = Estimate) ) + geom_point() + geom_smooth() + geom_hline(yintercept = -1)