library(tidyverse)
library(janitor)
library(here)
library(jtools)
library(gt)
library(fixest) # Fast FE estimation
༄ Estimating Difference-in-Difference / Fixed Effects Models
A replication of selected fixed effects analyses using panel data from Stokes, 2015
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.
Read in data
<- read_csv(here("data", "Stokes15_panel_data.csv")) %>%
panel_data 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 levelsyear
: 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)
<- feols(perc_lib ~ proposed_turbine | precinct_id + year,
fe_model 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)
<- feols(
fe_model2 ~ proposed_turbine +
perc_lib + log_pop_denc + unemploy_rate + log_median_inc + p_immigrant
p_uni_degree | 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_degree | 0.084 *** |
(0.015) | |
log_pop_denc | 0.006 *** |
(0.001) | |
unemploy_rate | 0.001 * |
(0.000) | |
log_median_inc | 0.013 * |
(0.006) | |
p_immigrant | 0.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
[1] "HUH! 🚀 Great work 241 - You are tremendous! 💫"
---------
< The End >
---------
\
\
(.)_(.)
_ ( _ ) _
/ \/`-----'\/ \
__\ ( ( ) ) /__
) /\ \._./ /\ (
)_/ /|\ /|\ \_( [nosig]