rm(list=ls())
library(stargazer)
library(plyr)
library(lfe)
library(zoo)
library(scales)
library(rdrobust)
library(data.table)
library(ggplot2)
library(dplyr)
library(fst)
library(fixest)
zdata[,Selling_premium:=zdata$sales_price/zdata$adj_purch_price]
zdata[,Renter_fraction:=zdata$renters/zdata$totalpopulation]
zdata[,Purchase_price:=SalesPriceAmount_prev]
zdata[,Listing_price:=listing_amount]
zdata[,Selling_price:=sales_price]
zdata[,Listing_premium:=list_premium]
zdata[,Property_tax_last_year:=prop_tax_prev_year]
zdata[,Property_tax_rate_last_year:=prop_tax_rate]
zdata_reg <- zdata[PurchaseYear<2008 & ListingYear>2013 & house_age>0 ]
zdata_reg[,Time_on_market:=as.numeric(sale_date)-as.numeric(listed_date)+1]
zdata_reg[,zip_list_month:=paste(zip,ListingMonth)]
zdata_reg[,tract_list_month:=paste(GEOID,ListingMonth)]
zdata_reg[,yr:=ifelse(ListingYear>2016,2016,ListingYear)]
hedonicmodel <- feols(data=zdata_reg[sales_price<2000000 & sales_price>100000],log(sales_price)~log(Purchase_price)+log(hpi_inflation)+beds+baths+log(sqft)+log(house_age)+log(LotSizeSquareFeet)+log(sqft)|yr)
hedonicmodelfelm <- felm(data=zdata_reg[sales_price<2000000 & sales_price>100000],log(sales_price)~log(Purchase_price)+log(hpi_inflation)+beds+baths+log(sqft)+log(house_age)+log(LotSizeSquareFeet)|yr)
# zdata_reg[,predprice:=adj_purch_price]#exp(predict(hedonicmodel,newdata = zd))]
zdata_reg[,predprice:=exp(predict(hedonicmodel,newdata = zdata_reg))]#
zdata_reg[,nominalloss:=Purchase_price-predprice]
zdata_reg[,nominalloss:=ifelse(nominalloss<=0,1,nominalloss)]
zdata_reg <- zdata_reg[abs(predprice-sales_price)<400000]
zdata_reg[,lp:=floor(listing_amount/1000)*1000]
temp <- zdata_reg[,.(predprice=mean(predprice,na.rm=T),adj_purc=mean(adj_purch_price,na.rm=T),.N),by=lp]
# ggplot(temp[N>10 & lp<500000],aes(x=lp,y=adj_purc))+geom_point()+geom_smooth(method="lm")+theme_minimal()+labs(x="Listing price",y="Adjusted purchase price")+ scale_x_continuous(labels = scales::comma)+ scale_y_continuous(labels = scales::comma)+labs(title="Adjusted purchase price")
ggplot(temp[N>10 & lp<750000],aes(x=lp,y=predprice))+geom_point()+geom_smooth(method="lm")+theme_minimal()+labs(x="Listing price",y="Predicted price")+ scale_x_continuous(labels = scales::comma)+ scale_y_continuous(labels = scales::comma)#+labs(title="Predicted price")
stargazer(zdata_reg[,c("Purchase_price","predprice","Listing_price","Property_tax_last_year","Property_tax_rate_last_year","purchase_hpi","hpi_inflation","ownership_years","beds","baths","sqft","LotSizeSquareFeet","house_age","LTV_prev","avg_school_rating","avg_school_distance","totalpopulation","medianage","medianhouseholdincome","Renter_fraction","nominalloss")],summary.stat = c("mean","sd","p25","median","p75","n"),digits = 4,type="text")
##
## ===================================================================================================
## Statistic Mean St. Dev. Pctl(25) Median Pctl(75) N
## ---------------------------------------------------------------------------------------------------
## Purchase_price 440,712.8000 322,548.0000 225,000 359,000 565,000 25,451
## predprice 628,367.6000 345,235.8000 399,849.5000 554,027.4000 760,284.3000 25,451
## Listing_price 650,171.0000 411,128.2000 387,075.0000 560,762.5000 789,037.5000 25,451
## Property_tax_last_year 5,569.1920 3,693.5240 3,127.8 4,711 6,955 25,451
## Property_tax_rate_last_year 0.0105 0.0038 0.0082 0.0100 0.0121 25,451
## purchase_hpi 421,006.0000 236,955.0000 249,550 386,200 546,700 25,451
## hpi_inflation 1.4344 0.6123 0.9906 1.2410 1.7013 25,451
## ownership_years 12.5610 2.7586 11 12 14 25,451
## beds 3.4300 0.8630 3 3 4 25,451
## baths 2.4760 0.8664 2 2 3 25,451
## sqft 1,988.4640 817.2647 1,411 1,815 2,392 25,451
## LotSizeSquareFeet 17,511.1600 113,645.7000 5,662 7,200 10,018 25,451
## house_age 39.2895 22.7883 19 36 56 25,451
## LTV_prev 0.6427 0.4166 0.3846 0.7832 0.8000 25,426
## avg_school_rating 6.8731 2.0197 5.3333 7.0000 8.6667 25,422
## avg_school_distance 1.4100 1.0687 0.8000 1.1333 1.6667 25,429
## totalpopulation 5,861.1130 2,905.4210 4,107.5000 5,370.0000 6,776.0000 25,448
## medianage 40.1254 7.7897 34.6000 39.3000 44.5000 25,446
## medianhouseholdincome 81,326.7600 30,895.0100 58,191.0000 76,643.0000 100,147.0000 25,445
## Renter_fraction 0.3214 0.1710 0.1910 0.2927 0.4288 25,446
## nominalloss 7,012.1140 36,643.7000 1 1 1 25,451
## ---------------------------------------------------------------------------------------------------
stargazer(hedonicmodelfelm,no.space = T,align = T,omit.stat=c("ser","f", "rsq"),style = "qje",omit.table.layout = "n", dep.var.labels.include = FALSE,covariate.labels = c("log(Purchase price)","log(HPI inflation)","Number of bedrooms","Number of bathrooms","House area","log(Age of the house)","log(Lot area)"),type="text")
##
## ===============================
## ===============================
## log(Purchase price) 0.649***
## (0.003)
## log(HPI inflation) 0.578***
## (0.005)
## Number of bedrooms 0.041***
## (0.003)
## Number of bathrooms 0.054***
## (0.003)
## House area 0.149***
## (0.006)
## log(Age of the house) 0.161***
## (0.003)
## log(Lot area) -0.010***
## (0.002)
## N 26,489
## Adjusted R2 0.721
## ===============================
controls1 = "log(predprice)+beds+baths+sqft+avg_school_rating+avg_school_distance+walk_score+log(house_age)+log(LotSizeSquareFeet)+LTV_prev+medianage+log(medianhouseholdincome)+Renter_fraction|zip_list_month|"
controls2 = "log(predprice)+beds+baths+sqft+avg_school_rating+avg_school_distance+walk_score+log(house_age)+log(LotSizeSquareFeet)+LTV_prev+medianage+log(medianhouseholdincome)+Renter_fraction|tract_list_month|"
controls3 = "log(predprice)+beds+baths+sqft+avg_school_rating+avg_school_distance+walk_score+log(house_age)+log(LotSizeSquareFeet)+LTV_prev+medianage+log(medianhouseholdincome)+Renter_fraction+log(nominalloss)|tract_list_month|"
cluster = "|zip"
instruments = "ownership_years" #
endo_var = "Property_tax_rate_last_year"
regs <- list()
regs[[1]] <- felm(as.formula(paste("I(prop_tax_rate*100)~ownership_years+",controls1,"0",cluster,sep="")),data=zdata_reg)
regs[[2]] <- felm(as.formula(paste("I(prop_tax_rate*100)~ownership_years+",controls2,"0","|GEOID",sep="")),data=zdata_reg)
# .printtable(regs)
stargazer(regs,no.space = T,align = T,omit.stat=c("ser","f", "rsq"),style = "qje",omit.table.layout = "n", dep.var.labels.include = FALSE,covariate.labels = c("Ownership years","log(Predicted price)","Number of bedrooms","Number of bathrooms","House area","GreatSchools rating","Distance to schools","Distance to amenities","log(Age of the house)","log(Lot area)","Loan-to-value_{Purchase}","Census tract median age","log(Census tract median income)","Census tract fraction of renters"),type="text")
##
## ====================================================
## (1) (2)
## ----------------------------------------------------
## Ownership years -0.061*** -0.059***
## (0.001) (0.001)
## log(Predicted price) -0.953*** -1.021***
## (0.018) (0.026)
## Number of bedrooms 0.057*** 0.057***
## (0.004) (0.007)
## Number of bathrooms 0.053*** 0.055***
## (0.005) (0.008)
## House area 0.0002*** 0.0002***
## (0.00001) (0.00002)
## GreatSchools rating 0.013*** 0.017*
## (0.003) (0.009)
## Distance to schools 0.003 0.001
## (0.005) (0.011)
## Distance to amenities -0.0003* -0.001**
## (0.0001) (0.0003)
## log(Age of the house) 0.048*** 0.035***
## (0.008) (0.012)
## log(Lot area) 0.022*** 0.022**
## (0.006) (0.009)
## Loan-to-valuePurchase 0.026*** 0.020*
## (0.007) (0.010)
## Census tract median age 0.002**
## (0.001) (0.000)
## log(Census tract median income) 0.117***
## (0.020) (0.000)
## Census tract fraction of renters 0.065*
## (0.035) (0.000)
## N 24,380 24,380
## Adjusted R2 0.659 0.685
## ====================================================
olsformula <- as.formula(paste("log(Listing_price)~Property_tax_rate_last_year+",controls1,"0",cluster,sep=""))
ivformula <- as.formula(paste("log(Listing_price)~",controls1,"(",endo_var,"~",instruments,")",cluster,sep=""))
ivformula_tract <-as.formula(paste("log(Listing_price)~",controls2,"(",endo_var,"~",instruments,")","|GEOID",sep=""))
ivformula_tract_loss <-as.formula(paste("log(Listing_price)~",controls3,"(",endo_var,"~",instruments,")","|GEOID",sep=""))
regs <- list()
regs[[1]] <- felm(olsformula,data=zdata_reg)
regs[[2]] <- felm(ivformula,data=zdata_reg)
regs[[3]] <- felm(ivformula_tract,data=zdata_reg)
regs[[4]] <- felm(ivformula_tract_loss,data=zdata_reg)
stargazer(regs,no.space = T,align = T,omit.stat=c("ser","f", "rsq"),style = "qje",omit.table.layout = "n", dep.var.labels.include = FALSE,
covariate.labels = c("Effective tax rate","log(Predicted price)","Number of bedrooms","Number of bathrooms","House area","GreatSchools rating","Distance to schools","Distance to amenities","log(Age of the house)","log(Lot area)","Loan-to-value_{Purchase}","Census tract median age","log(Census tract median income)","Census tract fraction of renters","log(Nominal loss)"),
column.labels=c("OLS","IV"),column.separate=c(1,3),
add.lines = list(c("zipmonth", "Yes", "Yes", "No","No"),
c("tractmonth", "Yes", "Yes", "No","No"),
c("Cond. F. Stat","",round(condfstat(regs[[2]])[[1]],2),round(condfstat(regs[[3]])[[1]],2),round(condfstat(regs[[4]])[[1]],2))),
type="text")#
##
## ============================================================================
## OLS IV
## (1) (2) (3) (4)
## ----------------------------------------------------------------------------
## Effective tax rate 12.886***
## (0.692)
## log(Predicted price) 0.379*** 0.302*** 0.305*** 0.271***
## (0.018) (0.017) (0.024) (0.025)
## Number of bedrooms -0.007** -0.002 0.003 0.007
## (0.003) (0.003) (0.005) (0.005)
## Number of bathrooms 0.002 0.007* 0.001 0.005
## (0.004) (0.004) (0.006) (0.006)
## House area 0.0002*** 0.0002*** 0.0002*** 0.0002***
## (0.00001) (0.00001) (0.00002) (0.00002)
## GreatSchools rating 0.014*** 0.015*** 0.012** 0.012**
## (0.003) (0.003) (0.006) (0.006)
## Distance to schools -0.005* -0.004 0.001 0.002
## (0.003) (0.003) (0.005) (0.005)
## Distance to amenities -0.0004*** -0.0004*** -0.001*** -0.001***
## (0.0001) (0.0001) (0.0002) (0.0002)
## log(Age of the house) -0.045*** -0.044*** -0.063*** -0.052***
## (0.005) (0.005) (0.009) (0.009)
## log(Lot area) 0.064*** 0.065*** 0.064*** 0.063***
## (0.006) (0.006) (0.009) (0.009)
## Loan-to-valuePurchase 0.008** 0.008** 0.004 0.004
## (0.003) (0.003) (0.005) (0.005)
## Census tract median age 0.003*** 0.003***
## (0.0005) (0.001) (0.000) (0.000)
## log(Census tract median income) 0.083*** 0.092***
## (0.012) (0.013) (0.000) (0.000)
## Census tract fraction of renters 0.071*** 0.075***
## (0.021) (0.021) (0.000) (0.000)
## log(Nominal loss) 0.004***
## (0.001)
## `Property_tax_rate_last_year(fit)` 5.257*** 6.274*** 3.895***
## (0.757) (1.203) (1.242)
## zipmonth Yes Yes No No
## tractmonth Yes Yes No No
## Cond. F. Stat 294.37 163.61 130.31
## N 24,380 24,380 24,380 24,380
## Adjusted R2 0.945 0.943 0.950 0.950
## ============================================================================
zhvi <- readRDS("C:/Users/dratnadiwakara2/Documents/OneDrive - Louisiana State University/Raw Data/Zillow Research Data/Zip_Zhvi_SingleFamilyResidence.rds")
zhvi <- data.table(zhvi)
zhvi <- zhvi[state=="CA"]
zhvi <- zhvi[month %in% as.Date(c("2006-01-01","2014-01-01"))]
zhvi <- zhvi[,c("zipcode","month","zhvi")]
zhvi <- dcast(zhvi,zipcode~month,value.var = "zhvi")
names(zhvi) <- c("zipcode","val2006","val2014")
zhvi <- zhvi[complete.cases(zhvi),]
zhvi <- data.table(zhvi)
zhvi[,pricechange:=log(val2014/val2006)]
hist <- ggplot()+geom_histogram(data=zhvi,aes(x=pricechange),fill="dodgerblue4",color="dodgerblue4",alpha=0.75)+labs(x="Price Change 2006 to 2014",y="Number of Zipcodes")+ theme_minimal()+scale_y_continuous(labels = comma)
zhvi[,pricechangeqt:=ntile(pricechange,16)]
zhvi <- zhvi[,c("zipcode","pricechange","pricechangeqt")]
zhvi[,zipcode:=as.numeric(zipcode)]
zdata_reg <- merge(zdata_reg, zhvi, by.x="zip",by.y="zipcode",all.x=T)
# print(hist)
regs <- list()
regs[[1]] <- felm(olsformula,data=zdata_reg[nominalloss>1])
regs[[2]] <- felm(olsformula,data=zdata_reg[nominalloss<=1])
regs[[3]] <- felm(olsformula,data=zdata_reg[pricechangeqt<=4])
regs[[4]] <- felm(olsformula,data=zdata_reg[pricechangeqt %in% 5:16])
regs[[5]] <- felm(ivformula,data=zdata_reg[pricechangeqt<=4])
regs[[6]] <- felm(ivformula,data=zdata_reg[pricechangeqt %in% 5:16])
stargazer(regs,no.space = T,align = T,omit.stat=c("ser","f", "rsq"),style = "qje",omit.table.layout = "n", dep.var.labels.include = FALSE,
covariate.labels = c("Effective tax rate","log(Predicted price)"),
column.labels=c("OLS","IV"),column.separate=c(4,2),
add.lines = list(c("Controls", "Yes", "Yes", "Yes","Yes","Yes","Yes"),c("zipmonth", "Yes", "Yes", "Yes","Yes","Yes","Yes"),c("Cond. F. Stat","","","","",round(condfstat(regs[[5]])[[1]],2),round(condfstat(regs[[6]])[[1]],2))),
keep=c("Property_tax_rate_last_year","predprice"),
type="text")#
##
## ===========================================================================================
## OLS IV
## (1) (2) (3) (4) (5) (6)
## -------------------------------------------------------------------------------------------
## Effective tax rate 9.093** 12.308*** 13.641*** 12.507***
## (3.719) (0.679) (1.886) (0.736)
## log(Predicted price) 0.866*** 0.346*** 0.490*** 0.357*** 0.388*** 0.283***
## (0.136) (0.017) (0.054) (0.019) (0.065) (0.018)
## `Property_tax_rate_last_year(fit)` 6.327** 4.920***
## (2.620) (0.798)
## Controls Yes Yes Yes Yes Yes Yes
## zipmonth Yes Yes Yes Yes Yes Yes
## Cond. F. Stat 18.84 287.73
## N 2,358 22,022 3,773 20,587 3,773 20,587
## Adjusted R2 0.946 0.946 0.860 0.929 0.857 0.927
## ===========================================================================================
regs <- list()
regs[[1]] <- felm(ivformula,data=zdata_reg[Listing_price<listing_q2])
regs[[2]] <- felm(ivformula,data=zdata_reg[Listing_price>listing_q2])
CA <- read_fst("C:/Users/dratnadiwakara2/Documents/OneDrive - Louisiana State University/Projects/Sunk Cost/Processed Data/all_homes_prev/CA_all_homes_prev.fst",columns = c("BuildingAreaSqFt","zip","Bedrooms"),as.data.table = T)
CA_summary <- CA[,.(
sqft_lb=quantile(BuildingAreaSqFt,0.25, na.rm=T),
sqft_hb=quantile(BuildingAreaSqFt,0.75, na.rm=T)),
by=zip]
temp <- CA[,.(
beds_lb=quantile(Bedrooms,0.25, na.rm=T),
beds_hb=floor(quantile(Bedrooms,0.75, na.rm=T)+0.99)),
by=zip]
CA_summary <- merge(CA_summary,temp,by="zip")
zdata_reg <- merge(zdata_reg,CA_summary,by="zip",all.x=T)
zdata_reg[,outlider_sqft:=ifelse(sqft>sqft_hb ,1,0)]
zdata_reg[,outlider_beds:=ifelse(beds>beds_hb,1,0)]
regs[[3]] <- felm(ivformula,data=zdata_reg[outlider_sqft==0 & outlider_beds==0])
regs[[4]] <- felm(ivformula,data=zdata_reg[outlider_sqft==1 | outlider_beds==1])
redfin <- read.csv("C:/Users/dratnadiwakara2/Documents/Research/UH computer27/sunkcost_2019/home_sales_redfin.csv")
redfin$month <- as.Date(redfin$month,origin="1900-01-01")
redfin <- data.table(redfin)
redfin <- redfin[redfin$month<="2016-01-01"]
redfin <- redfin[,.(median_home_sales=median(home_sales)),by=list(zip)]
redfin[,low_activiy:=ifelse(redfin$median_home_sales<quantile(redfin$median_home_sales,0.75),1,0)]
names(redfin) <- c("zip","median_home_sales_2","low_activity_2")
zdata_reg <- merge(zdata_reg,redfin,by="zip",all.x=TRUE)
regs[[5]] <- felm(ivformula,data=zdata_reg[low_activiy==1])
regs[[6]] <- felm(ivformula,data=zdata_reg[low_activiy==0])
temp <- zdata_reg[!duplicated(zdata_reg$GEOID)]
median_age <- median(temp$medianage,na.rm = TRUE)
regs[[7]] <- felm(ivformula,data=zdata_reg[medianage<=median_age])
regs[[8]] <- felm(ivformula,data=zdata_reg[medianage>median_age])
medincome <- median(temp$medianhouseholdincome,na.rm = TRUE)
regs[[9]] <- felm(ivformula,data=zdata_reg[medianhouseholdincome<=medincome])
regs[[10]] <- felm(ivformula,data=zdata_reg[medianhouseholdincome>medincome])
median_renterfrac <- median(temp$Renter_fraction,na.rm = TRUE)
regs[[11]] <- felm(ivformula,data=zdata_reg[Renter_fraction<=median_renterfrac])
regs[[12]] <- felm(ivformula,data=zdata_reg[Renter_fraction>median_renterfrac])
stargazer(regs,no.space = T,align = T,omit.stat=c("ser","f", "rsq"),style = "qje",omit.table.layout = "n", dep.var.labels.include = FALSE,
covariate.labels = c("Effective tax rate"),
column.labels=c("L Pr.","H Pr","L Sz","H Sz","L Act","H Act","L Ag","H Ag","L Inc","H Inc","L Ren","H Ren"),
add.lines = list(
c("Controls", rep("Yes",12)),
c("zipmonth", rep("Yes",12)),
c("Cond. F. Stat",round(c(condfstat(regs[[1]])[[1]],condfstat(regs[[2]])[[1]],condfstat(regs[[3]])[[1]],condfstat(regs[[4]])[[1]],condfstat(regs[[5]])[[1]],condfstat(regs[[6]])[[1]],condfstat(regs[[7]])[[1]],condfstat(regs[[8]])[[1]],condfstat(regs[[9]])[[1]],condfstat(regs[[10]])[[1]],condfstat(regs[[11]])[[1]],condfstat(regs[[12]])[[1]]),2))),
keep=c("Property_tax_rate_last_year"), flip=T,
type="text")#
##
## ============================================================================================================================
## L Pr. H Pr L Sz H Sz L Act H Act L Ag H Ag L Inc H Inc L Ren H Ren
## (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) (11) (12)
## ----------------------------------------------------------------------------------------------------------------------------
## Effective tax rate 1.289 7.201*** 4.596*** 8.508*** 4.809*** 5.081*** 2.508** 6.816*** 9.241*** 3.971*** 4.579*** 7.339***
## (0.912) (1.140) (0.884) (1.666) (1.157) (1.006) (1.237) (1.055) (1.485) (0.891) (1.033) (1.302)
## Controls Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes
## zipmonth Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes
## Cond. F. Stat 165.39 133.91 222.15 97.18 139.83 174.18 83.19 205.25 66.82 243.76 183.78 97.7
## N 12,428 11,834 15,687 8,693 10,560 12,556 9,405 14,975 8,485 15,895 15,758 8,622
## Adjusted R2 0.957 0.954 0.941 0.943 0.934 0.941 0.941 0.936 0.922 0.933 0.944 0.940
## ============================================================================================================================
regs <- list()
regs[[1]] <- felm(as.formula(paste("log(sales_price)~Property_tax_rate_last_year+",controls1,"0",cluster,sep="")),data=zdata_reg)
regs[[2]] <- felm(as.formula(paste("log(sales_price)~",controls1,"(",endo_var,"~",instruments,")",cluster,sep="")),data=zdata_reg)
regs[[3]] <- felm(as.formula(paste("log(Time_on_market)~Property_tax_rate_last_year+",controls1,"0",cluster,sep="")),data=zdata_reg)
regs[[4]] <- felm(as.formula(paste("log(Time_on_market)~",controls1,"(",endo_var,"~",instruments,")",cluster,sep="")),data=zdata_reg)
stargazer(regs,no.space = T,align = T,omit.stat=c("ser","f", "rsq"),style = "qje",omit.table.layout = "n", dep.var.labels.include = FALSE,
covariate.labels = c("Effective tax rate","log(Predicted price)"),
column.labels=c("log(Sales price)","log(Days on market)"),column.separate=c(2,2),
add.lines = list(c("Controls", "Yes", "Yes", "Yes","Yes","Yes","Yes"),c("zipmonth", "Yes", "Yes", "Yes","Yes","Yes","Yes"),c("Cond. F. Stat","",round(condfstat(regs[[2]])[[1]],2),"",round(condfstat(regs[[4]])[[1]],2))),
keep=c("Property_tax_rate_last_year","predprice"),
type="text")#
##
## =========================================================================
## log(Sales price) log(Days on market)
## (1) (2) (3) (4)
## -------------------------------------------------------------------------
## Effective tax rate 13.097*** -0.563
## (0.694) (1.642)
## log(Predicted price) 0.383*** 0.306*** -0.057** 0.014
## (0.018) (0.018) (0.028) (0.035)
## `Property_tax_rate_last_year(fit)` 5.501*** 6.408**
## (0.811) (2.668)
## Controls Yes Yes Yes Yes
## zipmonth Yes Yes Yes Yes
## Cond. F. Stat 294.37 294.37
## N 24,380 24,380 24,380 24,380
## Adjusted R2 0.940 0.939 0.337 0.336
## =========================================================================
temp <- zdata_reg
temp[,purch_month_no:=as.numeric(format(temp$PurchaseMonth,"%m"))]
temp[,sale_month_no:=as.numeric(format(temp$sale_date,"%m"))]
temp <- temp[!is.na(temp$predprice) & !is.na(temp$GEOID)]
temp[,zip_purch_list:=paste(temp$zip,temp$purchase_list_year)]
adj_proptax <- felm(Property_tax_rate_last_year~log(predprice)|zip_purch_list,data=temp)
adj_proptax_resid <- data.frame(adj_proptax$residuals)
names(adj_proptax_resid) <- c("adj_proptax_resid")
adj_list <- felm(log(Listing_price)~log(predprice)|zip_purch_list,data=temp)
adj_list_resid <- data.frame(adj_list$residuals)
names(adj_list_resid) <- c("adj_list_resid")
adj_sale <- felm(log(Selling_price)~log(predprice)|zip_purch_list,data=temp)
adj_sale_resid <- data.frame(adj_sale$residuals)
names(adj_sale_resid) <- c("adj_sale_resid")
adj_purch <- felm(log(Purchase_price)~0|zip_purch_list,data=temp)
adj_purch_resid <- data.frame(adj_purch$residuals)
names(adj_purch_resid) <- c("adj_purch_resid")
temp <- cbind(temp,adj_proptax_resid)
temp <- cbind(temp,adj_list_resid)
temp <- cbind(temp,adj_sale_resid)
temp <- cbind(temp,adj_purch_resid)
temp[,DocumentDate_prev:=as.Date(temp$DocumentDate_prev,origin = "1970-01-01")]
temp[,purch_week:=as.numeric(strftime(temp$DocumentDate_prev,format="%V"))-20]
temp[,postJune:=ifelse(purch_week>-2,1,0)]
temp[,zip_purch_year:=paste(zip,PurchaseYear)]
dscregs <- list()
dscregs[[1]] <- felm(log(Purchase_price)~postJune|zip_purch_year|0|zip,data=temp)
dscregs[[2]] <- felm(beds~postJune|zip_purch_year|0|zip,data=temp)
dscregs[[3]] <- felm(baths~postJune|zip_purch_year|0|zip,data=temp)
dscregs[[4]] <- felm(log(sqft)~postJune|zip_purch_year|0|zip,data=temp)
dscregs[[5]] <- felm(log(house_age)~postJune|zip_purch_year|0|zip,data=temp)
# dscregs[[6]] <- felm(log(0.0001+LTV_prev)~postJune|zip_purch_year|0|zip,data=temp)
stargazer(dscregs,no.space = T,align = T,omit.stat=c("ser","f", "rsq"),style = "qje",omit.table.layout = "n", dep.var.labels.include = F,
covariate.labels = c("Purchased after June 01"),
add.lines = list(c("zippurchmonth", "Yes", "Yes", "Yes","Yes","Yes","Yes")),
column.labels=c("log(Purchase price)","No beds","No baths","log(House area)","log(Age of house)","log(Loan-to-value)"),
# keep=c("Property_tax_rate_last_year","predprice"),
type="text")#
##
## =================================================================================================
## log(Purchase price) No beds No baths log(House area) log(Age of house)
## (1) (2) (3) (4) (5)
## -------------------------------------------------------------------------------------------------
## Purchased after June 01 0.045*** -0.033*** -0.033*** -0.021*** 0.008
## (0.006) (0.012) (0.011) (0.006) (0.007)
## zippurchmonth Yes Yes Yes Yes Yes
## N 25,448 25,448 25,448 25,448 25,448
## Adjusted R2 0.616 0.178 0.233 0.184 0.494
## =================================================================================================
regs = list()
regs[[1]] = felm(Property_tax_rate_last_year~postJune+purch_week+log(predprice)+beds+baths+sqft+avg_school_rating+avg_school_distance+walk_score+log(house_age)+log(LotSizeSquareFeet)+LTV_prev+medianage+log(medianhouseholdincome)+Renter_fraction|zip_purch_list|0|zip,data=temp)
regs[[2]] = felm(log(Listing_price)~postJune+purch_week+log(predprice)+beds+baths+sqft+avg_school_rating+avg_school_distance+walk_score+log(house_age)+log(LotSizeSquareFeet)+LTV_prev+medianage+log(medianhouseholdincome)+Renter_fraction|zip_purch_list|0|zip,data=temp)
regs[[3]] = felm(log(Selling_price)~postJune+purch_week+log(predprice)+beds+baths+sqft+avg_school_rating+avg_school_distance+walk_score+log(house_age)+log(LotSizeSquareFeet)+LTV_prev+medianage+log(medianhouseholdincome)+Renter_fraction|zip_purch_list|0|zip,data=temp)
stargazer(regs,no.space = T,align = T,omit.stat=c("ser","f", "rsq"),style = "qje",omit.table.layout = "n", dep.var.labels.include = FALSE,
covariate.labels = c("Purchased after June 01","Week of purchase","log(Predicted price)"),
column.labels=c("Effective tax rate","log(Listing price)","log(Selling price)"),
add.lines = list(c("Controls", "Yes", "Yes", "Yes","Yes","Yes","Yes"),c("zippurchmonth", "Yes", "Yes", "Yes","Yes","Yes","Yes")),
keep=c("postJune","predprice","purch_week"),
type="text")#
##
## ================================================================================
## Effective tax rate log(Listing price) log(Selling price)
## (1) (2) (3)
## --------------------------------------------------------------------------------
## Purchased after June 01 -0.0001** -0.010** -0.010**
## (0.0001) (0.004) (0.005)
## Week of purchase 0.00001*** 0.0002* 0.0002
## (0.00000) (0.0001) (0.0002)
## log(Predicted price) -0.009*** 0.249*** 0.259***
## (0.0002) (0.014) (0.015)
## Controls Yes Yes Yes
## zippurchmonth Yes Yes Yes
## N 24,380 24,380 24,380
## Adjusted R2 0.684 0.940 0.933
## ================================================================================
regs = list()
regs[[1]] = felm(Property_tax_rate_last_year~postJune+purch_week+I(purch_week^2)+log(predprice)+beds+baths+sqft+avg_school_rating+avg_school_distance+walk_score+log(house_age)+log(LotSizeSquareFeet)+LTV_prev+medianage+log(medianhouseholdincome)+Renter_fraction|zip_purch_list|0|zip,data=temp)
regs[[2]] = felm(log(Listing_price)~postJune+purch_week+I(purch_week^2)+log(predprice)+beds+baths+sqft+avg_school_rating+avg_school_distance+walk_score+log(house_age)+log(LotSizeSquareFeet)+LTV_prev+medianage+log(medianhouseholdincome)+Renter_fraction|zip_purch_list|0|zip,data=temp)
regs[[3]] = felm(log(Selling_price)~postJune+purch_week+I(purch_week^2)+log(predprice)+beds+baths+sqft+avg_school_rating+avg_school_distance+walk_score+log(house_age)+log(LotSizeSquareFeet)+LTV_prev+medianage+log(medianhouseholdincome)+Renter_fraction|zip_purch_list|0|zip,data=temp)
stargazer(regs,no.space = T,align = T,omit.stat=c("ser","f", "rsq"),style = "qje",omit.table.layout = "n", dep.var.labels.include = FALSE,
covariate.labels = c("Purchased after June 01","Week of purchase","Week of purchase^{2}","log(Predicted price)"),
column.labels=c("Effective tax rate","log(Listing price)","log(Selling price)"),
add.lines = list(c("Controls", "Yes", "Yes", "Yes","Yes","Yes","Yes"),c("zippurchmonth", "Yes", "Yes", "Yes","Yes","Yes","Yes")),
keep=c("postJune","predprice","purch_week"),
type="text")#
##
## ================================================================================
## Effective tax rate log(Listing price) log(Selling price)
## (1) (2) (3)
## --------------------------------------------------------------------------------
## Purchased after June 01 -0.0001* -0.011** -0.011**
## (0.0001) (0.005) (0.005)
## Week of purchase 0.00001*** 0.0003 0.0003
## (0.00000) (0.0002) (0.0002)
## Week of purchase2 0.00000 -0.00000 -0.00000
## (0.00000) (0.00001) (0.00001)
## log(Predicted price) -0.009*** 0.249*** 0.259***
## (0.0002) (0.014) (0.015)
## Controls Yes Yes Yes
## zippurchmonth Yes Yes Yes
## N 24,380 24,380 24,380
## Adjusted R2 0.684 0.940 0.933
## ================================================================================
Local linear running variable (3-months)
regs = list()
regs[[1]] = felm(Property_tax_rate_last_year~postJune+purch_week+log(predprice)+beds+baths+sqft+avg_school_rating+avg_school_distance+walk_score+log(house_age)+log(LotSizeSquareFeet)+LTV_prev+medianage+log(medianhouseholdincome)+Renter_fraction|zip_purch_list|0|zip,data=temp[abs(purch_week)<=12])
regs[[2]] = felm(log(Listing_price)~postJune+purch_week+log(predprice)+beds+baths+sqft+avg_school_rating+avg_school_distance+walk_score+log(house_age)+log(LotSizeSquareFeet)+LTV_prev+medianage+log(medianhouseholdincome)+Renter_fraction|zip_purch_list|0|zip,data=temp[abs(purch_week)<=12])
regs[[3]] = felm(log(Selling_price)~postJune+purch_week+log(predprice)+beds+baths+sqft+avg_school_rating+avg_school_distance+walk_score+log(house_age)+log(LotSizeSquareFeet)+LTV_prev+medianage+log(medianhouseholdincome)+Renter_fraction|zip_purch_list|0|zip,data=temp[abs(purch_week)<=12])
stargazer(regs,no.space = T,align = T,omit.stat=c("ser","f", "rsq"),style = "qje",omit.table.layout = "n", dep.var.labels.include = FALSE,
covariate.labels = c("Purchased after June 01","Week of purchase","log(Predicted price)"),
column.labels=c("Effective tax rate","log(Listing price)","log(Selling price)"),
add.lines = list(c("Controls", "Yes", "Yes", "Yes","Yes","Yes","Yes"),c("zippurchmonth", "Yes", "Yes", "Yes","Yes","Yes","Yes")),
keep=c("postJune","predprice","purch_week"),
type="text")#
##
## ================================================================================
## Effective tax rate log(Listing price) log(Selling price)
## (1) (2) (3)
## --------------------------------------------------------------------------------
## Purchased after June 01 -0.0002* -0.010 -0.013*
## (0.0001) (0.007) (0.007)
## Week of purchase 0.00002** 0.0002 0.0004
## (0.00001) (0.001) (0.001)
## log(Predicted price) -0.009*** 0.239*** 0.244***
## (0.0002) (0.016) (0.017)
## Controls Yes Yes Yes
## zippurchmonth Yes Yes Yes
## N 12,882 12,882 12,882
## Adjusted R2 0.691 0.938 0.935
## ================================================================================