Skip to content

Instantly share code, notes, and snippets.

View nazlialagoz's full-sized avatar

Nazli M. Alagoz nazlialagoz

View GitHub Profile
# Install and load the required packages
# devtools::install_github("synth-inference/synthdid")
library(synthdid)
library(ggplot2)
library(fixest) # Fixed-effects regression
library(data.table)
# Set seed for reproducibility
set.seed(12345)
@nazlialagoz
nazlialagoz / did.R
Last active February 24, 2023 00:38
Difference-in-differences with variation in treatment timing - Analysis
# Simulation study for the DiD article:
rm(list = ls())
library(data.table)
library(fastDummies) # Create dummy variables
library(fixest) # Fixed-effects regression
library(kableExtra) # Make nice tables
library(bacondecomp) # Goodman-Bacon Decomposition
library(did) # Difference-in-differences
@nazlialagoz
nazlialagoz / sim_data.R
Last active February 17, 2023 13:18
Difference-in-differences with variation in treatment timing - Simulation
# Simulate the data
# The simulaiton part of the code is adapted from Andrew Baker's awesome blog:
# https://andrewcbaker.netlify.app/2020/06/27/how-to-create-relative-time-indicators/
# Also see a relevant package and blog by Sant'Anna & Callaway:
# https://bcallaway11.github.io/did/articles/pre-testing.html
rm(list = ls())
library(data.table)
@nazlialagoz
nazlialagoz / Event_Study_Medium_Article.R
Created January 1, 2023 20:23
Simulation study for the Medium article: Event Studies for Causal Inference: The Dos and Don'ts - A guide to avoiding the common pitfalls of event studies
# Simulation study for the Medium article:
# Event Studies for Causal Inference: The Dos and Don'ts -
# A guide to avoiding the common pitfalls of event studies
# This code simulates a panel dataset and then runs event studies
# Different scenarios are created to demonstrate pitfalls of event studies
# The simulaiton part of the code is adapted from Andrew Baker's awesome blog:
# https://andrewcbaker.netlify.app/2020/06/27/how-to-create-relative-time-indicators/
# Also see a relevant package and blog by Sant'Anna & Callaway: