Data Science, Machine Learning, Tech, Artificial Intelligence, Economics.
fit <- ivreg(Y ~ X, Z, data = df) summary(fit, vcov = sandwich, df = Inf, diagnostics = TRUE) This code does the two steps for us, but what’s happening under the hood? First, we are regressing X on Z using OLS — that’s the first stage. Then, using the estimated model, we are generating predicted