Skip to content

Instantly share code, notes, and snippets.

@jvieroe
Created April 29, 2022 08:13
Show Gist options
  • Save jvieroe/6b7e8171e9bfff2933783842561cfae6 to your computer and use it in GitHub Desktop.
Save jvieroe/6b7e8171e9bfff2933783842561cfae6 to your computer and use it in GitHub Desktop.
fixest feols demo
library(fixest)
library(broom)
library(tidyverse)
library(janitor)
options(scipen = 999)
df <- gapminder::gapminder
mlist <- list()
mlist$m1 <- feols(lifeExp ~ gdpPercap,
panel.id = c('country', 'year'),
data = df)
mlist$m2 <- feols(lifeExp ~ gdpPercap | country,
panel.id = c('country', 'year'),
data = df)
mlist$m3 <- feols(lifeExp ~ gdpPercap | country + year,
panel.id = c('country', 'year'),
data = df)
mlist$m4 <- feols(lifeExp ~ gdpPercap + pop | country + year,
panel.id = c('country', 'year'),
data = df)
mlist$m5 <- feols(lifeExp ~ gdpPercap + pop | country + year,
panel.id = c('country', 'year'),
cluster = c('continent'),
data = df)
etable(mlist)
coefs_exp <- coeftable(mlist$m4) %>%
as.data.frame() %>%
clean_names() %>%
rownames_to_column(., "predictor") %>%
mutate(conf_low = estimate - (1.96 * std_error),
conf_high = estimate + (1.96 * std_error))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment