Skip to content

Instantly share code, notes, and snippets.

@chrishanretty
Created December 28, 2024 15:37
Show Gist options
  • Save chrishanretty/2e8e18c50f9ef3ce78544252339b0e7d to your computer and use it in GitHub Desktop.
Save chrishanretty/2e8e18c50f9ef3ce78544252339b0e7d to your computer and use it in GitHub Desktop.
Replication of Hilbig and Wiedemann (2024), "How Budget Tradeoffs Undermine Electoral Incentives to Build Public Housing"
### Load libraries
library(tidyverse)
library(haven)
library(fixest)
library(modelsummary)
### Download data from https://dataverse.harvard.edu/dataset.xhtml?persistentId=doi:10.7910/DVN/GTEBJA#
gwz <- read_rds("data_main.rds") |>
mutate(inc_share_diff = inc_share_diff * 100) |>
filter(main_sample == 1)
### Set up the different model formula
f_change <- inc_share_diff ~ any_flats_kommune + pop_change_last_elec | state_year
f_levels <- inc_current_share ~ any_flats_kommune +
pop_change_last_elec | state_year
f_ldv <- inc_current_share ~ inc_prev_share + any_flats_kommune +
pop_change_last_elec | state_year
### Repeat the analysis using the same calls
### Compare with Table_2_3_D1_D2_D3_D9_E1_E4_E5_E6_E7_E9.R
m_change <- fixest::feols(f_change,
cluster = ~ags_8dig,
data = gwz)
m_levels <- fixest::feols(f_levels,
cluster = ~ags_8dig,
data = gwz)
m_ldv <- fixest::feols(f_ldv,
cluster = ~ags_8dig,
data = gwz)
### Output the model results
my_cm <- c("any_flats_kommune" = "Any new housing",
"pop_change_last_elec" = "Pop. change since last election",
"inc_prev_share" = "Lagged incumbent share",
"(Intercept)" = "Constant")
modelsummary(list("DV: Change score" = m_change, "DV: Levels" = m_levels, "DV: Levels, controlling for LDV" = m_ldv),
statistic = "conf.int",
coef_map = my_cm,
stars = TRUE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment