## ----include = FALSE---------------------------------------------------------- knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "figures/with-fixest-" ) set.seed(1) ## ----message = FALSE---------------------------------------------------------- library(ivcheck) library(fixest) ## ----------------------------------------------------------------------------- data(card1995) head(card1995[, c("lwage", "educ", "college", "near_college", "age", "black", "south")]) ## ----------------------------------------------------------------------------- m <- feols( lwage ~ age + black + south | college ~ near_college, data = card1995 ) summary(m) ## ----------------------------------------------------------------------------- chk <- iv_check(m, n_boot = 500, parallel = FALSE) print(chk) ## ----------------------------------------------------------------------------- iv_kitagawa(m, n_boot = 300, parallel = FALSE) ## ----fig.width = 6, fig.height = 4-------------------------------------------- k <- iv_kitagawa(m, n_boot = 500, parallel = FALSE) hist(k$boot_stats, breaks = 40, main = "Kitagawa bootstrap distribution (Card 1995)", xlab = "sqrt(n) * positive-part KS") abline(v = k$statistic, col = "red", lwd = 2) ## ----eval = FALSE------------------------------------------------------------- # library(modelsummary) # modelsummary( # list("IV estimate" = m), # gof_custom = list( # "Kitagawa 2015 p-value" = sprintf("%.3f", k$p_value) # ) # ) ## ----eval = FALSE------------------------------------------------------------- # library(fixest) # library(ivcheck) # # # ... data loading ... # # # IV estimate # m <- feols(y ~ controls | d ~ z, data = df) # # # IV validity diagnostic # chk <- iv_check(m) # # # Report both in the paper # knitr::kable(chk$table)