Import Dataset

RENT.merge<-read_xlsx("MSA-RENT merge All.xlsx")
RENT.merge$treat<-ifelse(RENT.merge$state=="LA",1,0)

## Cleaning Dataset
colnames(RENT.merge)
##  [1] "FirstNAME"           "AREANAME"            "RENT_0"             
##  [4] "RENT_1"              "RENT_2"              "RENT_3"             
##  [7] "RENT_4"              "YEAR"                "NAME.x"             
## [10] "state"               "Unemployee.Rate"     "Personal.Income"    
## [13] "Resident.Population" "nyear"               "MSA"                
## [16] "MSA.Code"            "Price"               "Change"             
## [19] "NAME.y"              "treat"
# Remove NA
RENT.merge<-RENT.merge%>%
  group_by(MSA)%>%
  filter(!any(is.na(Unemployee.Rate)))

# ADD STATE NUM
statepop<-usmap::statepop[,1:2]
statepop$fips<-as.numeric(statepop$fips)

RENT.merge<-left_join(RENT.merge,statepop,by=c("state"="abbr"))

RENT.merge<-data.frame(RENT.merge)

Ballace Dataset

MSA<-RENT.merge%>%
  group_by(MSA.Code)%>%
  mutate(nyear=n())%>%
  filter(nyear==15)

MSA<-data.frame(MSA)

## NEW ORLEAN AS SAMPLE
stc<-unique(MSA $MSA.Code)
stc<-stc[stc!=35380] #exclude LA MSA from control unit

Single Treat

RENT 0

## Single Treated Unit (New Orleans)
Sn.RENT<-dataprep(
  foo = RENT.merge,
  predictors = c("Unemployee.Rate","Personal.Income","Resident.Population"),
  predictors.op = "mean",
  dependent = "RENT_0",
  unit.variable = "MSA.Code", # UNIQ CODE (ID)
  time.variable = "YEAR",
  treatment.identifier = 35380,
  controls.identifier = stc,
  time.predictors.prior = c(2001:2005), 
  time.optimize.ssr = c(2001:2010),
  unit.names.variable = "MSA", 
  time.plot = 2001:2010)


synth.out <- synth(Sn.RENT)
## 
## X1, X0, Z1, Z0 all come directly from dataprep object.
## 
## 
## **************** 
##  searching for synthetic control unit  
##  
## 
## **************** 
## **************** 
## **************** 
## 
## MSPE (LOSS V): 22843.7 
## 
## solution.v:
##  0.7428384 0.0111094 0.2460522 
## 
## solution.w:
##  0.004307925 0.005078608 0.004771279 0.00459698 0.005056786 0.004757677 0.004098294 0.005259614 0.003690634 0.004698843 0.00448885 0.003765542 0.00547303 0.004868562 0.006941448 0.004995965 0.005179242 0.005211411 0.003532331 0.004622133 0.004518932 0.001956742 0.004095966 0.004353143 0.004576955 0.005210961 0.005204398 0.003644476 0.004147106 0.004017936 0.004855879 0.002874909 0.004079907 0.007252531 0.005654157 0.004884405 0.003415296 0.004911348 0.004881141 0.005118408 0.004638899 0.006051841 0.004929491 0.005511709 0.005202551 0.003755088 0.00620844 0.004299715 0.003919853 0.004016798 0.004447815 0.004291741 0.004955928 0.005981483 0.005078207 0.005616828 0.005215425 0.005884176 0.006114916 0.005451463 0.004554549 0.007804259 0.005032975 0.002681213 0.004271907 0.005003735 0.004481432 0.004064073 0.004558988 0.004491348 0.005233098 0.004422623 0.004386119 0.004465682 0.005984642 0.004211716 0.004582143 1.8778e-06 0.005451643 0.004647002 0.004857521 0.004181583 0.00511247 0.004994264 0.00540593 0.004614454 0.004522499 0.005304031 0.004850806 0.004211741 0.005233217 0.004685232 0.00504997 0.003815041 0.005343528 0.005025761 0.003667118 0.003765235 0.004243089 0.005205554 0.003150564 0.005018801 0.00405171 0.004356451 0.003401238 0.005440322 0.005577209 0.00767926 0.005152097 0.005011211 0.003774381 0.005073826 0.006754151 0.004807148 0.004590138 0.005014585 0.005006411 0.04446862 0.004392667 0.03939964 0.003975339 0.004802545 0.004291805 0.005140483 0.004315458 0.004876308 0.004054471 0.00400928 0.004684349 0.005075358 0.00568697 0.005185386 0.004263991 0.02611663 0.005455126 0.004100486 0.00521341 0.002666027 0.004772264 0.00568922 0.004192661 0.004184367 0.003913345 0.003670938 0.004701409 0.005545478 0.006069794 0.005018882 0.004179166 0.005528917 0.006344759 0.003904001 0.004132271 0.004198099 0.005071751 0.004593455 0.005663223 0.004377989 0.004229715 0.003978019 0.006408174 0.006059826 0.004662688 0.003477388 0.005165149 0.005412765 0.004621411 0.004280483 0.004574702 0.004407054 0.004379045 0.004760381 0.00455576 0.004584171 0.004694228 0.004186289 0.004951056 0.004557483 0.004930644 0.004803288 0.006645578 0.004314708 0.005579861 0.007289753 0.02966236
#round(synth.out$solution.w,2)

synth.tables <- synth.tab(
  dataprep.res = Sn.RENT,
  synth.res = synth.out)

#print(synth.tables)


## plot in levels (treated and synthetic)
path.plot(dataprep.res = Sn.RENT,synth.res = synth.out)##+ggtitle(label = "RENT_0")

## plot the gaps (treated - synthetic)
gaps.plot(dataprep.res = Sn.RENT,synth.res = synth.out)##+ggtitle(label = "RENT_0")

RENT 1

## Single Treated Unit (New Orleans)
Sn.RENT<-dataprep(
  foo = RENT.merge,
  predictors = c("Unemployee.Rate","Personal.Income","Resident.Population"),
  predictors.op = "mean",
  dependent = "RENT_1",
  unit.variable = "MSA.Code", # UNIQ CODE (ID)
  time.variable = "YEAR",
  treatment.identifier = 35380,
  controls.identifier = stc,
  time.predictors.prior = c(2001:2005), 
  time.optimize.ssr = c(2001:2010),
  unit.names.variable = "MSA", 
  time.plot = 2001:2010)


synth.out <- synth(Sn.RENT)
## 
## X1, X0, Z1, Z0 all come directly from dataprep object.
## 
## 
## **************** 
##  searching for synthetic control unit  
##  
## 
## **************** 
## **************** 
## **************** 
## 
## MSPE (LOSS V): 26713.35 
## 
## solution.v:
##  0.7452357 0.2547362 2.81234e-05 
## 
## solution.w:
##  0.003841465 0.00484605 0.004042938 0.004124307 0.004560756 0.004286389 0.00379812 0.00578401 0.004569961 0.004058052 0.004069494 0.003541073 0.004183484 0.004677418 0.005657619 0.004792361 0.004566186 0.004715796 0.00361309 0.004124282 0.004303802 0.003483066 0.003688539 0.00412194 0.005267014 0.005321029 0.004718362 0.004250884 0.004196725 0.003921691 0.004384627 0.004164685 0.00434873 0.003417107 0.004958814 0.004733993 0.003613343 0.004456756 0.004413987 0.00454611 0.00454833 0.004092517 0.004293169 0.005401433 0.005166467 0.004160477 0.004902893 0.003904531 0.003824578 0.003825424 0.004160371 0.004014889 0.004382801 0.003786648 0.004518225 0.005092016 0.004485473 0.005253664 0.00542679 0.00457259 0.004304211 0.007081696 0.004200385 0.00322823 0.003912039 0.004321907 0.004148359 0.003842041 0.004009508 0.00444587 0.004615239 0.004064489 0.003764358 0.003930274 0.004361996 0.004112699 0.004355769 0.003656418 0.004797616 0.004181392 0.004202337 0.004030745 0.00461845 0.004638263 0.004740414 0.00390412 0.003934769 0.004785675 0.004309518 0.003814231 0.004885842 0.004158992 0.004350338 0.003927649 0.0732136 0.004002851 0.003586735 0.003580161 0.004218955 0.0046006 0.003783032 0.004445973 0.003658397 0.003918074 0.004249873 0.004818546 0.005155764 0.006598147 0.003564209 0.005003434 0.003643585 0.004134184 0.006120417 0.004096795 0.004241963 0.004376561 0.004351059 0.04591672 0.004242971 0.05713581 0.003563516 0.004057134 0.00392356 0.005197999 0.003490469 0.004335879 0.0039166 0.003671533 0.004417783 0.003537332 0.004525518 0.004530869 0.00374777 0.005820474 0.004679842 0.003835834 0.005202374 0.003635694 0.004654038 0.005273392 0.004939205 0.004358204 0.003943665 0.004163406 0.004371155 0.005128407 0.005439506 0.004707748 0.003946755 0.004717386 0.006715538 0.004395822 0.004006209 0.004287347 0.004388912 0.004304788 0.005030121 0.004427337 0.003833329 0.003807191 0.005842531 0.004962127 0.004280147 0.003548189 0.004389623 0.005015523 0.004377895 0.004549015 0.003954033 0.004061365 0.003850716 0.004573049 0.003999229 0.004346815 0.004016242 0.004112915 0.004705568 0.00421862 0.004373552 0.004501799 0.005690798 0.00431285 0.004894546 0.00689488 0.02732674
#round(synth.out$solution.w,2)

synth.tables <- synth.tab(
  dataprep.res = Sn.RENT,
  synth.res = synth.out)

#print(synth.tables)


## plot in levels (treated and synthetic)
path.plot(dataprep.res = Sn.RENT,synth.res = synth.out)#+ggtitle(label = "RENT_1")

## plot the gaps (treated - synthetic)
gaps.plot(dataprep.res = Sn.RENT,synth.res = synth.out)#+ggtitle(label = "RENT_1")

RENT 2

## Single Treated Unit (New Orleans)
Sn.RENT<-dataprep(
  foo = RENT.merge,
  predictors = c("Unemployee.Rate","Personal.Income","Resident.Population"),
  predictors.op = "mean",
  dependent = "RENT_2",
  unit.variable = "MSA.Code", # UNIQ CODE (ID)
  time.variable = "YEAR",
  treatment.identifier = 35380,
  controls.identifier = stc,
  time.predictors.prior = c(2001:2005), 
  time.optimize.ssr = c(2001:2010),
  unit.names.variable = "MSA", 
  time.plot = 2001:2010)


synth.out <- synth(Sn.RENT)
## 
## X1, X0, Z1, Z0 all come directly from dataprep object.
## 
## 
## **************** 
##  searching for synthetic control unit  
##  
## 
## **************** 
## **************** 
## **************** 
## 
## MSPE (LOSS V): 35934.56 
## 
## solution.v:
##  0.144881 0.8544599 0.0006590859 
## 
## solution.w:
##  0.003963301 0.005210844 0.004048536 0.004614892 0.004491746 0.004300829 0.004043354 0.006868569 0.005750187 0.004043111 0.004335116 0.003746684 0.007125308 0.004862832 0.005081804 0.006744386 0.004801726 0.004610472 0.003899405 0.004249947 0.005087707 0.003827291 0.003860697 0.004558323 0.007715147 0.005583028 0.004762021 0.004868295 0.004622851 0.00424214 0.004490248 0.004976275 0.004837455 0.01060732 0.004654036 0.005128656 0.003938568 0.004786434 0.005419505 0.004606835 0.004745858 0.007603236 0.00423974 0.005265296 0.007079882 0.004955765 0.007352956 0.004025785 0.004082401 0.004005618 0.004321811 0.004223167 0.004291488 0.004448545 0.004515351 0.004892235 0.004461104 0.004971343 0.0048646 0.004324803 0.004621867 0.005668491 0.004082626 0.003484916 0.004042531 0.004217041 0.004266567 0.004002156 0.004113587 0.004820307 0.004466851 0.004259263 0.003849506 0.004046007 0.007405637 0.004523577 0.005488112 0.004175753 0.004556561 0.004484983 0.004141928 0.004988584 0.004536701 0.004641704 0.004510182 0.003915351 0.004006551 0.004593005 0.004428734 0.004331745 0.004771098 0.004259456 0.004285835 0.004526048 0.004051019 0.004015256 0.003778016 0.003734443 0.00471295 0.004430185 0.004353393 0.004406912 0.003910495 0.004097073 0.005308461 0.004563984 0.004910101 0.005118453 0.007370353 0.006174732 0.003826989 0.004248925 0.005301094 0.004096835 0.004484438 0.004276204 0.004317469 0.02340493 0.005304169 0.03419444 0.003860402 0.00402334 0.004761865 0.005434665 0.005010964 0.00428916 0.004175245 0.00407893 0.004678792 0.006213149 0.004222259 0.005886539 0.003802268 0.03621518 0.004425525 0.00403097 0.005334896 0.004050023 0.004983127 0.004960084 0.006459819 0.005492004 0.004375508 0.004767098 0.005039874 0.004986081 0.004869781 0.005940103 0.00417401 0.004574144 0.006358434 0.005068686 0.004372817 0.004664723 0.004262037 0.004545679 0.004860097 0.004827507 0.004159222 0.004033683 0.005344952 0.004452445 0.004688115 0.003976435 0.004267351 0.005153357 0.004576619 0.01016716 0.00455317 0.004696975 0.003984828 0.004743893 0.004167988 0.004486171 0.00408814 0.004390815 0.005032938 0.004339168 0.004312696 0.004673741 0.004875761 0.004796548 0.004864502 0.005388809 0.0427673
#round(synth.out$solution.w,2)

synth.tables <- synth.tab(
  dataprep.res = Sn.RENT,
  synth.res = synth.out)

#print(synth.tables)


## plot in levels (treated and synthetic)
path.plot(dataprep.res = Sn.RENT,synth.res = synth.out)#+ggtitle(label = "RENT_2")

## plot the gaps (treated - synthetic)
gaps.plot(dataprep.res = Sn.RENT,synth.res = synth.out)#+ggtitle(label = "RENT_2")

RENT 3

## Single Treated Unit (New Orleans)
Sn.RENT<-dataprep(
  foo = RENT.merge,
  predictors = c("Unemployee.Rate","Personal.Income","Resident.Population"),
  predictors.op = "mean",
  dependent = "RENT_3",
  unit.variable = "MSA.Code", # UNIQ CODE (ID)
  time.variable = "YEAR",
  treatment.identifier = 35380,
  controls.identifier = stc,
  time.predictors.prior = c(2001:2005), 
  time.optimize.ssr = c(2001:2010),
  unit.names.variable = "MSA", 
  time.plot = 2001:2010)


synth.out <- synth(Sn.RENT)
## 
## X1, X0, Z1, Z0 all come directly from dataprep object.
## 
## 
## **************** 
##  searching for synthetic control unit  
##  
## 
## **************** 
## **************** 
## **************** 
## 
## MSPE (LOSS V): 51234.02 
## 
## solution.v:
##  0.1012706 0.8962391 0.002490294 
## 
## solution.w:
##  0.004035626 0.005105015 0.00398498 0.004562064 0.00447156 0.004347581 0.004178925 0.00627327 0.005792898 0.004035584 0.004380752 0.003861783 0.006281976 0.004893869 0.004514135 0.006424768 0.004632325 0.004548184 0.004118967 0.004282546 0.005070372 0.003959844 0.003932299 0.004644466 0.006944398 0.00545226 0.004660251 0.005060365 0.004813464 0.00443615 0.004485016 0.004875219 0.005053105 0.007873323 0.00446059 0.00510188 0.004140235 0.004708132 0.005199266 0.004512562 0.004872131 0.006211932 0.004210245 0.005106134 0.006558942 0.00509612 0.006221488 0.004142643 0.004298303 0.004211787 0.004453958 0.00436869 0.004286847 0.003899066 0.004454241 0.004694689 0.004327025 0.004681744 0.004561666 0.00415604 0.00469585 0.004962376 0.003975635 0.003649232 0.004176759 0.004169833 0.004389884 0.00420094 0.00413703 0.004943638 0.00438659 0.004359633 0.003767745 0.004079233 0.006212424 0.004675438 0.005403626 0.05665064 0.004423098 0.004475062 0.004120571 0.005015612 0.004502319 0.004651153 0.004387736 0.003843614 0.004016261 0.004519188 0.004400257 0.004340463 0.004726127 0.004276818 0.004212113 0.004682762 0.003547145 0.003779618 0.00399863 0.003904206 0.004857451 0.004367808 0.004390981 0.004370382 0.003974782 0.004172976 0.005244941 0.004443026 0.004749155 0.004526409 0.00717027 0.005929702 0.004042569 0.00404578 0.004790309 0.004042401 0.004542744 0.004239434 0.004259065 0.00839238 0.005292827 0.03822524 0.003853813 0.00395636 0.004707707 0.005352112 0.004484843 0.004302129 0.00437482 0.004142087 0.004731084 0.00511819 0.003964844 0.005466093 0.003791815 0.003393353 0.004276062 0.004198892 0.005246721 0.004063717 0.005019716 0.004769002 0.006376812 0.005576939 0.004568738 0.004956169 0.004969968 0.004807959 0.004586969 0.005672199 0.0043419 0.004365612 0.005671588 0.005259867 0.00453734 0.004872194 0.004205018 0.004621617 0.004628428 0.00498935 0.004221377 0.004233244 0.004880921 0.004155741 0.004674028 0.004120756 0.004160283 0.004953118 0.00467054 0.007735688 0.004412142 0.00468559 0.00401597 0.004818029 0.004171611 0.004610326 0.004041999 0.004593026 0.004984687 0.004444336 0.004310758 0.00470817 0.004449774 0.004937505 0.004620815 0.004825147 0.0536888
#round(synth.out$solution.w,2)

synth.tables <- synth.tab(
  dataprep.res = Sn.RENT,
  synth.res = synth.out)

#print(synth.tables)


## plot in levels (treated and synthetic)
path.plot(dataprep.res = Sn.RENT,synth.res = synth.out)#+ggtitle(label = "RENT_3")

## plot the gaps (treated - synthetic)
gaps.plot(dataprep.res = Sn.RENT,synth.res = synth.out)#+ggtitle(label = "RENT_3")

RENT 4

## Single Treated Unit (New Orleans)
Sn.RENT<-dataprep(
  foo = RENT.merge,
  predictors = c("Unemployee.Rate","Personal.Income","Resident.Population"),
  predictors.op = "mean",
  dependent = "RENT_4",
  unit.variable = "MSA.Code", # UNIQ CODE (ID)
  time.variable = "YEAR",
  treatment.identifier = 35380,
  controls.identifier = stc,
  time.predictors.prior = c(2001:2005), 
  time.optimize.ssr = c(2001:2010),
  unit.names.variable = "MSA", 
  time.plot = 2001:2010)


synth.out <- synth(Sn.RENT)
## 
## X1, X0, Z1, Z0 all come directly from dataprep object.
## 
## 
## **************** 
##  searching for synthetic control unit  
##  
## 
## **************** 
## **************** 
## **************** 
## 
## MSPE (LOSS V): 49846.52 
## 
## solution.v:
##  0.0005782983 0.9946985 0.004723242 
## 
## solution.w:
##  0.004339629 0.005390362 0.004162327 0.004843529 0.004633914 0.004571442 0.004558796 0.007798761 0.006728909 0.00423733 0.004674709 0.004275969 0.006464006 0.005185167 0.004081601 0.007107062 0.004780934 0.004681455 0.004687469 0.004532064 0.005437664 0.004832149 0.004276443 0.005003575 0.009964862 0.005899649 0.004812263 0.005733252 0.005265011 0.004872167 0.004699297 0.00592116 0.005583117 0.007966529 0.004452096 0.005432102 0.004766633 0.00493753 0.005499413 0.004661007 0.005220532 0.006361695 0.00437056 0.005321361 0.007629174 0.005731047 0.006532722 0.004462655 0.004749793 0.004621894 0.004773111 0.004717731 0.004450275 0.003735446 0.004605934 0.004741991 0.004422817 0.00464415 0.004427559 0.004164719 0.005016269 0.004108421 0.004082108 0.004375635 0.004508719 0.00430546 0.004692264 0.004595552 0.004386943 0.005331268 0.004487438 0.00467118 0.004009686 0.004347182 0.006441855 0.005081799 0.005790771 0.005173752 0.004468012 0.004737765 0.004289946 0.005427502 0.004654647 0.004861824 0.004440284 0.004043535 0.0042619 0.004623148 0.00460337 0.004699587 0.004892456 0.00450914 0.004339719 0.005215323 0.00354084 0.003870375 0.004483029 0.004327975 0.005281608 0.004474144 0.005226973 0.004526846 0.004339929 0.004480552 0.006205547 0.004494868 0.004824121 0.003787041 0.006176391 0.006543605 0.004500682 0.0041496 0.00446245 0.004216498 0.004832169 0.004380536 0.004404057 0.0006269831 0.00569667 0.03727868 0.004217561 0.004122125 0.005065791 0.005755925 0.00478032 0.004488687 0.004793527 0.004542729 0.00502725 0.005239089 0.003885833 0.005751307 0.00406306 0.00368218 0.004298472 0.004581561 0.005587414 0.004994104 0.00535925 0.004816946 0.007616228 0.006109617 0.005053863 0.005597031 0.005284178 0.004903599 0.004473247 0.006084193 0.004719339 0.004378149 0.005978058 0.005894245 0.004949099 0.005328038 0.004326288 0.004923031 0.004646346 0.005418943 0.004567323 0.004657421 0.004710324 0.00398139 0.004957796 0.004728507 0.004250291 0.005115718 0.004976037 0.01808854 0.00468043 0.005025058 0.00429905 0.005120327 0.004425747 0.004919035 0.00424596 0.00500375 0.005267721 0.004733421 0.004483793 0.004973418 0.004114454 0.005360158 0.004659802 0.004249577 0.05162518
#round(synth.out$solution.w,2)

synth.tables <- synth.tab(
  dataprep.res = Sn.RENT,
  synth.res = synth.out)

#print(synth.tables)


## plot in levels (treated and synthetic)
path.plot(dataprep.res = Sn.RENT,synth.res = synth.out)#+ggtitle(label = "RENT_4")

## plot the gaps (treated - synthetic)
gaps.plot(dataprep.res = Sn.RENT,synth.res = synth.out)#+ggtitle(label = "RENT_4")