## Rent data with only Common Control MSA
## and 8 LA MSA
rent.df <- read.csv("(157 Control + 8 LA MSA) Rent Data.csv")
## Adding Lat and Long to our rent data
lat_lng <- read.csv("rent data new.csv") %>%
distinct(X, Y, GEOID) %>%
rename(MSA.Code = GEOID)
df <- rent.df %>%
group_by(MSA) %>%
filter(!any(is.na(Unemployee.Rate))) %>%
ungroup() %>%
merge(lat_lng, by = "MSA.Code") %>%
as.data.frame() %>%
arrange(MSA, YEAR) %>%
mutate(treat = ifelse(state == "LA", 1, 0))
dloop <- data.frame(YEAR = unique(df$YEAR))
## YEAR DUMMY
for (i in 1:nrow(dloop)) {
df[paste0("d.", dloop$YEAR[i])] <- as.numeric(df$YEAR == unique(df$YEAR)[i])
}
Rent 0
cse <- conleyreg(log(RENT_0) ~ Price + Unemployee.Rate +
Personal.Income + Resident.Population +
treat:(d.2001 + d.2002 + d.2003 +
d.2005 + d.2006 + d.2007 + d.2008 +
d.2009 + d.2010 + d.2011 + d.2012 +
d.2013 + d.2014 + d.2015) | MSA + YEAR,
data = df,
dist_cutoff = 300,
st_distance = TRUE,
lat = "Y",
lon = "X"
)
## Checking spatial attributes
## Estimating model
## Estimating distance matrix and addressing spatial correlation
colnames(cse)[2] <- "Conley SE"
stargazer(cse[1:9, 1:2], type = "text")
##
## ======================================
## Estimate Conley SE
## --------------------------------------
## Price 0.001 0.0003
## Unemployee.Rate 0.010 0.004
## Personal.Income 0.00000 0.00000
## Resident.Population -0.0002 0.00004
## treat:d.2001 -0.033 0.019
## treat:d.2002 0.004 0.003
## treat:d.2003 0.001 0.002
## treat:d.2005 0.067 0.029
## treat:d.2006 0.156 0.052
## --------------------------------------
coef_df <- cse[,] %>%
as_tibble() %>%
mutate(variables = rownames(cse))
coef_df <- coef_df[5:18,]
event_df <- data.frame(time = 1:nrow(coef_df),
coef = coef_df$Estimate,
cse = coef_df$`Conley SE`)
event_df <- rbind(event_df, c("time" = 3.5, "coef" = 0, "cse" = 0))
event_df <- arrange(event_df, time)
# Calculate confidence intervals
event_df$ci_upper <- event_df$coef + 1.96 * event_df$cse
event_df$ci_lower <- event_df$coef - 1.96 * event_df$cse
# Extract dates from row names of coef_df
##dates <- as.Date(paste0(row.names(coef_df),"0101"), format = "treat:YEAR%Y%m%d")
dates<-seq.Date(from = as.Date("2001-01-01"),as.Date("2015-01-01"),by="year")
# Define start and end dates for plot
start_date <- as.Date("2001-01-01")
end_date <- as.Date("2015-01-01")
# Create sequence of dates for x-axis
dates_seq <- seq(from = start_date, to = end_date, by = "year")
# Subset event_df to only include dates after or equal to start_date
event_df_sub <- event_df[dates >= start_date, ]
plot.theme <- theme(axis.text.x = element_text(angle = 45, hjust = 1),
plot.title = element_text(size = 18, face = "bold", hjust = 0.5),
axis.title.x = element_blank(),
axis.title.y = element_text(size = 18, face = "bold"),
axis.text = element_text(size = 14, face = "bold"),
legend.text = element_text(size = 12),
plot.caption = element_text(size = 12, face = c("italic", "bold")),
axis.line = element_line(color = "black", size = 0.5),
panel.background = element_blank(),
panel.grid.major = element_line(color = "black", size = 0.1))
pl <- ggplot(event_df, aes(x = dates, y = coef)) +
geom_point() + geom_line() +
#geom_errorbar(aes(ymin = ci_lower, ymax = ci_upper), width = 0.2) +
geom_ribbon(aes(ymin = ci_lower, ymax = ci_upper), alpha = 0.2) +
geom_hline(yintercept = 0, linetype = "dashed", color = "red") +
geom_vline(xintercept = as.Date("2005-01-01"), linetype = "dashed", color = "blue") +
scale_y_continuous(labels = function(x) paste0(x * 100, "%"),
breaks = seq(-0.1, 0.3, 0.05)) +
scale_x_date(date_labels = "%Y", limits = c(start_date, end_date), breaks = "5 year") +
labs(title = "Panel A: Rent 0", y = "Percentage") + plot.theme
pl

Rent 1
cse.01 <- conleyreg(log(RENT_1) ~ Price + Unemployee.Rate +
Personal.Income + Resident.Population +
treat:(d.2001 + d.2002 + d.2003 +
d.2005 + d.2006 + d.2007 + d.2008 +
d.2009 + d.2010 + d.2011 + d.2012 +
d.2013 + d.2014 + d.2015) | MSA + YEAR,
data = df,
dist_cutoff = 300,
st_distance = TRUE,
lat = "Y",
lon = "X",
)
## Checking spatial attributes
## Estimating model
## Estimating distance matrix and addressing spatial correlation
colnames(cse.01)[2] <- "Conley SE"
stargazer(cse.01[1:9, 1:2], type = "text")
##
## ======================================
## Estimate Conley SE
## --------------------------------------
## Price 0.001 0.0003
## Unemployee.Rate 0.012 0.003
## Personal.Income 0.00000 0.00000
## Resident.Population -0.0001 0.00004
## treat:d.2001 -0.030 0.019
## treat:d.2002 0.004 0.003
## treat:d.2003 0.0004 0.003
## treat:d.2005 0.040 0.017
## treat:d.2006 0.135 0.048
## --------------------------------------
coef_df1 <- cse.01[,] %>%
as_tibble() %>%
mutate(variables = rownames(cse.01))
coef_df1 <- coef_df1[5:18,]
event_df1 <- data.frame(time = 1:nrow(coef_df1),
coef = coef_df1$Estimate,
cse = coef_df1$`Conley SE`)
event_df1 <- rbind(event_df1, c("time" = 3.5, "coef" = 0, "cse" = 0))
event_df1 <- arrange(event_df1, time)
# Calculate confidence intervals
event_df1$ci_upper <- event_df1$coef + 1.96 * event_df1$cse
event_df1$ci_lower <- event_df1$coef - 1.96 * event_df1$cse
# Subset event_df to only include dates after or equal to start_date
event_df_sub1 <- event_df1[dates >= start_date, ]
pl1 <- ggplot(event_df1, aes(x = dates, y = coef)) +
geom_point() + geom_line() +
#geom_errorbar(aes(ymin = ci_lower, ymax = ci_upper), width = 0.2) +
geom_ribbon(aes(ymin = ci_lower, ymax = ci_upper), alpha = 0.2) +
geom_hline(yintercept = 0, linetype = "dashed", color = "red") +
geom_vline(xintercept = as.Date("2005-01-01"), linetype = "dashed", color = "blue") +
scale_y_continuous(labels = function(x) paste0(x * 100, "%"),
breaks = seq(-0.1, 0.3, 0.05)) +
scale_x_date(date_labels = "%Y", limits = c(start_date, end_date), breaks = "5 year") +
labs(title = "Panel B: Rent 1", y = "Percentage") + plot.theme
pl1

Rent 2
cse.02 <- conleyreg(log(RENT_2) ~ Price + Unemployee.Rate +
Personal.Income + Resident.Population +
treat:(d.2001 + d.2002 + d.2003 +
d.2005 + d.2006 + d.2007 + d.2008 +
d.2009 + d.2010 + d.2011 + d.2012 +
d.2013 + d.2014 + d.2015) | MSA + YEAR,
data = df,
dist_cutoff = 300,
st_distance = TRUE,
lat = "Y",
lon = "X",
)
## Checking spatial attributes
## Estimating model
## Estimating distance matrix and addressing spatial correlation
colnames(cse.02)[2] <- "Conley SE"
stargazer(cse.02[1:9, 1:2], type = "text")
##
## ======================================
## Estimate Conley SE
## --------------------------------------
## Price 0.001 0.0003
## Unemployee.Rate 0.009 0.003
## Personal.Income 0.00000 0.00000
## Resident.Population -0.0001 0.00004
## treat:d.2001 -0.028 0.019
## treat:d.2002 0.003 0.003
## treat:d.2003 0.001 0.002
## treat:d.2005 0.019 0.016
## treat:d.2006 0.112 0.047
## --------------------------------------
coef_df2 <- cse.02[,] %>%
as_tibble() %>%
mutate(variables = rownames(cse.02))
coef_df2 <- coef_df2[5:18,]
event_df2 <- data.frame(time = 1:nrow(coef_df2),
coef = coef_df2$Estimate,
cse = coef_df2$`Conley SE`)
event_df2 <- rbind(event_df2, c("time" = 3.5, "coef" = 0, "cse" = 0))
event_df2 <- arrange(event_df2, time)
# Calculate confidence intervals
event_df2$ci_upper <- event_df2$coef + 1.96 * event_df2$cse
event_df2$ci_lower <- event_df2$coef - 1.96 * event_df2$cse
# Subset event_df to only include dates after or equal to start_date
event_df_sub2 <- event_df2[dates >= start_date, ]
pl2 <- ggplot(event_df2, aes(x = dates, y = coef)) +
geom_point() +
geom_line() +
#geom_errorbar(aes(ymin = ci_lower, ymax = ci_upper), width = 0.2) +
geom_ribbon(aes(ymin = ci_lower, ymax = ci_upper), alpha = 0.2) +
geom_hline(yintercept = 0, linetype = "dashed", color = "red") +
geom_vline(xintercept = as.Date("2005-01-01"), linetype = "dashed", color = "blue") +
scale_y_continuous(labels = function(x) paste0(x * 100, "%"),
breaks = seq(-0.1, 0.3, 0.05)) +
scale_x_date(date_labels = "%Y", limits = c(start_date, end_date), breaks = "5 year") +
labs(title = "Panel C: RENT 2", y = "Percentage") + plot.theme
pl2

Rent 3
cse.03 <- conleyreg(log(RENT_3) ~ Price + Unemployee.Rate +
Personal.Income + Resident.Population +
treat:(d.2001 + d.2002 + d.2003 +
d.2005 + d.2006 + d.2007 + d.2008 +
d.2009 + d.2010 + d.2011 + d.2012 +
d.2013 + d.2014 + d.2015) | MSA + YEAR,
data = df,
dist_cutoff = 300,
st_distance = TRUE,
lat = "Y",
lon = "X",
)
## Checking spatial attributes
## Estimating model
## Estimating distance matrix and addressing spatial correlation
colnames(cse.03)[2] <- "Conley SE"
stargazer(cse.03[1:9, 1:2], type = "text")
##
## ======================================
## Estimate Conley SE
## --------------------------------------
## Price 0.001 0.0002
## Unemployee.Rate 0.007 0.003
## Personal.Income 0.00000 0.00000
## Resident.Population -0.0001 0.00005
## treat:d.2001 -0.026 0.019
## treat:d.2002 0.004 0.002
## treat:d.2003 0.002 0.002
## treat:d.2005 -0.042 0.011
## treat:d.2006 0.055 0.047
## --------------------------------------
coef_df3 <- cse.03[,] %>%
as_tibble() %>%
mutate(variables = rownames(cse.03))
coef_df3 <- coef_df3[5:18,]
event_df3 <- data.frame(time = 1:nrow(coef_df3),
coef = coef_df3$Estimate,
cse = coef_df3$`Conley SE`)
event_df3 <- rbind(event_df3, c("time" = 3.5, "coef" = 0, "cse" = 0))
event_df3 <- arrange(event_df3, time)
# Calculate confidence intervals
event_df3$ci_upper <- event_df3$coef + 1.96 * event_df3$cse
event_df3$ci_lower <- event_df3$coef - 1.96 * event_df3$cse
# Subset event_df to only include dates after or equal to start_date
event_df_sub3 <- event_df3[dates >= start_date, ]
pl3 <- ggplot(event_df3, aes(x = dates, y = coef)) +
geom_point() +
geom_line() +
#geom_errorbar(aes(ymin = ci_lower, ymax = ci_upper), width = 0.2) +
geom_ribbon(aes(ymin = ci_lower, ymax = ci_upper), alpha = 0.2) +
geom_hline(yintercept = 0, linetype = "dashed", color = "red") +
geom_vline(xintercept = as.Date("2005-01-01"), linetype = "dashed", color = "blue") +
scale_y_continuous(labels = function(x) paste0(x * 100, "%"),
breaks = seq(-0.1, 0.3, 0.05)) +
scale_x_date(date_labels = "%Y", limits = c(start_date, end_date), breaks = "5 year") +
labs(title = "Panel D: RENT 3", y = "Percentage") + plot.theme
pl3

Rent 4
cse.04 <- conleyreg(log(RENT_4) ~ Price + Unemployee.Rate +
Personal.Income + Resident.Population +
treat:(d.2001 + d.2002 + d.2003 +
d.2005 + d.2006 + d.2007 + d.2008 +
d.2009 + d.2010 + d.2011 + d.2012 +
d.2013 + d.2014 + d.2015) | MSA + YEAR,
data = df,
dist_cutoff = 300,
st_distance = TRUE,
lat = "Y",
lon = "X",
)
## Checking spatial attributes
## Estimating model
## Estimating distance matrix and addressing spatial correlation
colnames(cse.04)[2] <- "Conley SE"
stargazer(cse.04[1:9, 1:2], type = "text")
##
## ======================================
## Estimate Conley SE
## --------------------------------------
## Price 0.001 0.0003
## Unemployee.Rate 0.004 0.004
## Personal.Income 0.00000 0.00000
## Resident.Population -0.0001 0.0001
## treat:d.2001 -0.041 0.023
## treat:d.2002 0.005 0.002
## treat:d.2003 0.003 0.002
## treat:d.2005 -0.022 0.039
## treat:d.2006 0.052 0.056
## --------------------------------------
coef_df4 <- cse.04[,] %>%
as_tibble() %>%
mutate(variables = rownames(cse.04))
coef_df4 <- coef_df4[5:18,]
event_df4 <- data.frame(time = 1:nrow(coef_df4),
coef = coef_df4$Estimate,
cse = coef_df4$`Conley SE`)
event_df4 <- rbind(event_df4, c("time" = 3.5, "coef" = 0, "cse" = 0))
event_df4 <- arrange(event_df4, time)
# Calculate confidence intervals
event_df4$ci_upper <- event_df4$coef + 1.96 * event_df4$cse
event_df4$ci_lower <- event_df4$coef - 1.96 * event_df4$cse
# Subset event_df to only include dates after or equal to start_date
event_df_sub4 <- event_df4[dates >= start_date, ]
pl4 <- ggplot(event_df4, aes(x = dates, y = coef)) +
geom_point() +
geom_line() +
#geom_errorbar(aes(ymin = ci_lower, ymax = ci_upper), width = 0.2) +
geom_ribbon(aes(ymin = ci_lower, ymax = ci_upper), alpha = 0.2) +
geom_hline(yintercept = 0, linetype = "dashed", color = "red") +
geom_vline(xintercept = as.Date("2005-01-01"), linetype = "dashed", color = "blue") +
scale_y_continuous(labels = function(x) paste0(x * 100, "%"),
breaks = seq(-0.1, 0.3, 0.05)) +
scale_x_date(date_labels = "%Y", limits = c(start_date, end_date), breaks = "5 year") +
labs(title = "Panel E: RENT 4", y = "Percentage") + plot.theme
pl4

House Price Index
cse.prc <- conleyreg(log(Price) ~ Unemployee.Rate +
Personal.Income + Resident.Population +
treat:(d.2001 + d.2002 + d.2003 +
d.2005 + d.2006 + d.2007 + d.2008 +
d.2009 + d.2010 + d.2011 + d.2012 +
d.2013 + d.2014 + d.2015) | MSA + YEAR,
data = df,
dist_cutoff = 300,
st_distance = TRUE,
lat = "Y",
lon = "X",
)
## Checking spatial attributes
## Estimating model
## Estimating distance matrix and addressing spatial correlation
colnames(cse.prc)[2] <- "Conley SE"
stargazer(cse.prc[1:9, 1:2], type = "text")
##
## ======================================
## Estimate Conley SE
## --------------------------------------
## Unemployee.Rate -0.014 0.005
## Personal.Income 0.00002 0.00000
## Resident.Population 0.00001 0.00004
## treat:d.2001 0.012 0.013
## treat:d.2002 -0.003 0.010
## treat:d.2003 0.010 0.009
## treat:d.2005 -0.015 0.013
## treat:d.2006 -0.055 0.018
## treat:d.2007 -0.050 0.025
## --------------------------------------
coef_df5 <- cse.prc[,] %>%
as_tibble() %>%
mutate(variables = rownames(cse.prc))
coef_df5 <- coef_df5[5:18,]
event_df5 <- data.frame(time = 1:nrow(coef_df5),
coef = coef_df5$Estimate,
cse = coef_df5$`Conley SE`)
event_df5 <- rbind(event_df5, c("time" = 3.5, "coef" = 0, "cse" = 0))
event_df5 <- arrange(event_df5, time)
# Calculate confidence intervals
event_df5$ci_upper <- event_df5$coef + 1.96 * event_df5$cse
event_df5$ci_lower <- event_df5$coef - 1.96 * event_df5$cse
# Subset event_df to only include dates after or equal to start_date
event_df_sub5 <- event_df5[dates >= start_date, ]
pl5 <- ggplot(event_df5, aes(x = dates, y = coef)) +
geom_point() +
geom_line() +
#geom_errorbar(aes(ymin = ci_lower, ymax = ci_upper), width = 0.2) +
geom_ribbon(aes(ymin = ci_lower, ymax = ci_upper), alpha = 0.2) +
geom_hline(yintercept = 0, linetype = "dashed", color = "red") +
geom_vline(xintercept = as.Date("2005-01-01"), linetype = "dashed", color = "blue") +
scale_y_continuous(labels = function(x) paste0(x * 100, "%"),
breaks = seq(-0.1, 0.3, 0.05)) +
scale_x_date(date_labels = "%Y", limits = c(start_date, end_date), breaks = "5 year") +
labs(title = "Panel F: House Price Index", y = "Percentage") + plot.theme
pl5

All Plots
grid.arrange(pl + labs(title = "Panel A: Rent 0", x = "", y = ""),
pl1 + labs(title = "Panel B: Rent 1", x = "", y = ""),
pl2 + labs(title = "Panel C: Rent 2", x = "", y = ""),
pl3 + labs(title = "Panel D: Rent 3", x = "", y = ""),
pl4 + labs(title = "Panel E: Rent 4", x = "", y = ""),
pl5 + labs(title = "Panel F: House Price Index", x = "", y = ""),
bottom = textGrob("Year", gp = gpar(fontface = "bold", fontsize = 18)),
left = textGrob("Percentage", rot = 90, gp = gpar(fontface = "bold", fontsize = 18)),
nrow = 2)
