༄ Estimating Difference-in-Difference / Fixed Effects Models

A replication of selected fixed effects analyses using panel data from Stokes, 2015

Author

EDS 241

Published

February 4, 2025


Study & data source:

Electoral Backlash against Climate Policy: A Natural Experiment on Retrospective Voting and Local Resistance to Public Policy.

Stokes, 2016: https://doi.org/10.1111/ajps.12220

Data source: Dataverse-Stokes2015

NOTE: Replication of fixed effects model results is approximate.


library(tidyverse)
library(janitor)
library(here)         
library(jtools) 
library(gt)
library(fixest) # Fast FE estimation

Read in data

panel_data <- read_csv(here("data", "Stokes15_panel_data.csv")) %>%
  mutate(across(c(precinct_id, year), as.factor))

We could run our FE models with lm() except…

  • N = 18,558
  • precinct_id: Factor with 6186 precinct levels
  • year: Factor with 3 year-level time points

‘mod_1 <- lm(perc_lib ~ prop + factor(precinct_id) + factor(year), data=divisions)’

length(unique(panel_data$precinct_id))
[1] 6186
length(unique(panel_data$year))
[1] 3

Fixed effects panel model for turbine proposal (without controls)

📜 Documentation - fixest

fe_model <- feols(perc_lib ~ proposed_turbine | precinct_id + year,
                   data = panel_data,
                   cluster = ~precinct_id)

export_summs(fe_model, digits = 3, statistics = "none",
             model.names = c("Outcome: Turbine Proposal"))
Outcome: Turbine Proposal
proposed_turbine-0.042 ***
(0.008)   
*** p < 0.001; ** p < 0.01; * p < 0.05.

Fixed effects panel model for turbine proposal (with controls)

fe_model2 <- feols(
    perc_lib ~ proposed_turbine + 
    p_uni_degree + log_pop_denc + unemploy_rate + log_median_inc + p_immigrant
    | precinct_id + year,
 data = panel_data,
 cluster = ~precinct_id)

export_summs(fe_model2, digits = 3, statistics = "none",
             model.names = c("Outcome: Turbine Proposal"))
Outcome: Turbine Proposal
proposed_turbine-0.039 ***
(0.008)   
p_uni_degree0.084 ***
(0.015)   
log_pop_denc0.006 ***
(0.001)   
unemploy_rate0.001 *  
(0.000)   
log_median_inc0.013 *  
(0.006)   
p_immigrant0.074 ***
(0.022)   
*** p < 0.001; ** p < 0.01; * p < 0.05.

Fixed effects model results (Stokes, 2015):

Table 1: Effects of Proposed Wind Turbines on Incumbent Party Vote Share

📜 Stokes, 2020; Page 10


[1] "HUH! 🚀 Great work 241 - You are tremendous! 💫"

 --------- 
< The End >
 --------- 
     \
      \

        (.)_(.)
     _ (   _   ) _
    / \/`-----'\/ \
  __\ ( (     ) ) /__
  )   /\ \._./ /\   (
   )_/ /|\   /|\ \_(  [nosig]