Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extract first stage results from feols() IV regression for modelsummary()

Tags:

r

modelsummary

I'd like to report the first and the second stage results from feols() IV regression using modelsummary(). I couldn't find a way (except running the first stage as a separate model).

I can display first and second stage results using etable() like this:

library(fixest)
library(tidyverse)
library(modelsummary)

# create a toy dataset
base <- iris
names(base) <- c("y", "x1", "x_endo_1", "x_inst_1", "fe")
base$x_inst_2 <- 0.2 * base$y + 0.2 * base$x_endo_1 + rnorm(150, sd = 0.5)
base$x_endo_2 <- 0.2 * base$y - 0.2 * base$x_inst_1 + rnorm(150, sd = 0.5)

# estimate an instrumental variable model
mod <- feols(y ~ x1 | fe | x_endo_1 + x_endo_2 ~ x_inst_1 + x_inst_2, base)

# First and second stage results
etable(mod, stage = 1:2)

I'd appreciate any pointers.

Thanks, Umut

like image 793
Umut Avatar asked Oct 19 '25 16:10

Umut


2 Answers

From fixest documentation: enter image description here

To get both first and second stage, use summary with stage = 1:2. Then you can feed it to modelsummary:

modelsummary(summary(mod, stage = 1:2))

enter image description here

like image 178
Laurent Bergé Avatar answered Oct 21 '25 04:10

Laurent Bergé


The first-stage IV regression model summary can be generated with:

modelsummary::modelsummary(mod$iv_first_stage)

modelsummary

like image 33
xilliam Avatar answered Oct 21 '25 05:10

xilliam



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!