Created
December 8, 2023 20:16
-
-
Save apoorvalal/f268f64d3cf32c5264aca415ef51abb0 to your computer and use it in GitHub Desktop.
numerical verification of equality of coefficient and SE per FWL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(estimatr) | |
data(auto) | |
# %% FWL regression coefficient | |
auto$ytil = lm(price ~ displacement, auto)$resid | |
auto$x2til = lm(weight ~ displacement, auto)$resid | |
(fwlest = lm_robust(ytil ~ x2til, auto, se_type = "HC0") | |
%>% summary %>% .$coefficients %>% .[2, 1:2]) | |
# %% | |
(fullest = | |
lm_robust(price ~ weight + displacement, auto, se_type = "HC0") %>% | |
summary %>% .$coefficients %>% .[2, 1:2] | |
) | |
# %% theorem 1 and theorem 2 - Ding 2021 Statistics and Probability Letters | |
all.equal(fwlest, fullest) | |
# %% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment