Umut
Umut

Reputation: 87

Extract first stage results from feols() IV regression for 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

Upvotes: 4

Views: 1965

Answers (2)

Laurent Berg&#233;
Laurent Berg&#233;

Reputation: 1372

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

Upvotes: 5

xilliam
xilliam

Reputation: 2259

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

modelsummary::modelsummary(mod$iv_first_stage)

modelsummary

Upvotes: 1

Related Questions