library(tidyverse)
library(haven)
library(Synth)
library(devtools)
library(SCtools)

read_data <- function(df) {
  full_path <- paste("https://github.com/scunning1975/mixtape/raw/master/", 
                     df, sep = "")
  df <- read_dta(full_path)
  return(df)
}

texas <- read_data("texas.dta") %>%
  as.data.frame(.)

Data Preparation

dataprep_out <- dataprep(
  foo = texas,
  predictors = c("poverty", "income"),
  predictors.op = "mean",
  time.predictors.prior = 1985:1993,
  special.predictors = list(
    list("bmprison", c(1988, 1990:1992), "mean"),
    list("alcohol", 1990, "mean"),
    list("aidscapita", 1990:1991, "mean"),
    list("black", 1990:1992, "mean"),
    list("perc1519", 1990, "mean")),
  dependent = "bmprison",
  unit.variable = "statefip",
  unit.names.variable = "state",
  time.variable = "year",
  treatment.identifier = 48,
  controls.identifier = c(1,2,4:6,8:13,15:42,44:47,49:51,53:56),
  time.optimize.ssr = 1985:1993,
  time.plot = 1985:2000
)

synth_out <- synth(data.prep.obj = dataprep_out)
## 
## X1, X0, Z1, Z0 all come directly from dataprep object.
## 
## 
## **************** 
##  searching for synthetic control unit  
##  
## 
## **************** 
## **************** 
## **************** 
## 
## MSPE (LOSS V): 2015107 
## 
## solution.v:
##  0.07154915 0.02736536 0.8923763 5.5e-09 2.42e-08 0.008709159 7.6e-09 
## 
## solution.w:
##  3.1624e-06 2.409e-07 2.1267e-06 1.84496e-05 0.3414498 5.67e-07 2.118e-07 2.353e-07 5.36e-08 0.2981352 3.819e-07 2.736e-07 1.27466e-05 8.934e-07 1.9113e-06 1.6149e-06 8.583e-07 1.13756e-05 0.3599649 1.8153e-06 2.789e-07 3.058e-07 4.3669e-06 5.491e-07 7.4e-09 1.5586e-06 1.03716e-05 9.868e-07 4.019e-07 3.65e-07 3.756e-07 8.8487e-06 5.029e-07 9.835e-07 7.0083e-06 1.03244e-05 4.9236e-06 1.1965e-06 1.7016e-06 4.911e-07 3.1e-09 5.3498e-06 1.4134e-06 0.000262627 1.2619e-06 4.661e-07 5.808e-07 6.369e-05 1.1599e-06 1.1983e-06

TASK 2: Standard Synthetic Control Plot and Gaps Plot

path.plot(synth_out, dataprep_out)

gaps.plot(synth_out, dataprep_out)

Generate Placebos

placebos <- generate.placebos(dataprep_out, synth_out, Sigf.ipop = 3)
## 
## X1, X0, Z1, Z0 all come directly from dataprep object.
## 
## 
## **************** 
##  searching for synthetic control unit  
##  
## 
## **************** 
## **************** 
## **************** 
## 
## MSPE (LOSS V): 45681.9 
## 
## solution.v:
##  0.06748428 0.02474086 0.9018141 6e-10 0.0006277061 0.003742051 0.001591043 
## 
## solution.w:
##  0.003778043 0.006258287 0.01045484 0.005359059 0.004762802 0.003254921 0.004258525 0.002471576 0.005764268 0.008610203 0.00395104 0.008540652 0.005989193 0.007198224 0.006072961 0.005497835 0.008918081 0.387823 0.006029948 0.004247942 0.003842094 0.01232426 0.004725588 0.1872741 0.006532765 0.007273528 0.005714779 0.004275647 0.00426751 0.003773225 0.00781867 0.002610985 0.008881017 0.007141505 0.01051835 0.007891166 0.005376059 0.006348851 0.004724991 0.1324897 0.007071146 0.007476571 0.01470988 0.005820269 0.005554114 0.004702185 0.009562053 0.005878726 0.006178851 
## 
## 
## X1, X0, Z1, Z0 all come directly from dataprep object.
## 
## 
## **************** 
##  searching for synthetic control unit  
##  
## 
## **************** 
## **************** 
## **************** 
## 
## MSPE (LOSS V): 925.6949 
## 
## solution.v:
##  3.51993e-05 1.72857e-05 0.9211308 0.0009428709 0.07776696 9.10773e-05 1.58052e-05 
## 
## solution.w:
##  0.001018933 0.002480651 0.001853742 0.0002135165 0.003078122 0.001750996 0.002702807 0.001084662 0.0003783088 0.0007084764 0.04834502 0.005904547 0.0006122616 0.001676191 0.003176115 0.002554029 0.002169927 0.0007488416 0.01095032 0.000778779 0.002358869 0.0005210446 0.003502537 0.001460512 0.001331904 0.01443802 0.003411757 0.003365749 0.4414528 0.0007962347 0.005356388 0.000313653 0.0009109444 0.3545026 0.0006137389 0.001820489 0.00400764 0.0008334889 0.004360358 0.0009296217 0.005816605 0.001666839 0.004219108 0.02964801 0.0008969827 0.002973555 0.004013821 0.002078811 0.01021176 
## 
## 
## X1, X0, Z1, Z0 all come directly from dataprep object.
## 
## 
## **************** 
##  searching for synthetic control unit  
##  
## 
## **************** 
## **************** 
## **************** 
## 
## MSPE (LOSS V): 3336.617 
## 
## solution.v:
##  2.2595e-05 3.008e-06 0.8833976 0.04563797 0.0004080119 0.06977544 0.0007553297 
## 
## solution.w:
##  0.005359012 0.008967972 0.006731061 0.008620843 0.01452732 0.01069817 0.006058648 0.002859163 0.007293589 0.005119666 0.007816799 0.04956971 0.006995813 0.01073983 0.01638589 0.01069434 0.01056344 0.004662865 0.1956318 0.005336678 0.01530618 0.007202683 0.01708472 0.004165911 0.009434002 0.1597771 0.01075614 0.006113958 0.1656874 0.008384064 0.01154144 0.006909199 0.005802446 0.007666327 0.008798764 0.01035451 0.02608536 0.01031357 0.01302156 0.004838277 0.006681154 0.006924064 6.1971e-06 0.02660789 0.006349995 0.01748714 0.007807538 0.01299484 0.01126492 
## 
## 
## X1, X0, Z1, Z0 all come directly from dataprep object.
## 
## 
## **************** 
##  searching for synthetic control unit  
##  
## 
## **************** 
## **************** 
## **************** 
## 
## MSPE (LOSS V): 25979.06 
## 
## solution.v:
##  0.003895003 0.04588188 0.8024623 0.04032648 0.007366592 1.42e-08 0.1000678 
## 
## solution.w:
##  0.004231755 0.0004704427 0.00141006 0.001295936 0.001027389 0.0005427843 0.0006560551 0.0002817262 0.1295271 0.001603026 0.0007535502 1.0557e-06 0.001082612 0.001031873 0.001674359 0.002206374 0.00276507 0.005976919 0.001512934 0.001009307 0.0006131886 0.001467526 0.0009933521 0.0008025057 0.002374009 8.387e-06 0.001230339 0.0006549632 0.0004900217 0.0006933451 0.001597326 0.000984009 0.00254375 0.002012535 0.002440028 0.006927867 0.001752732 0.002360784 0.0007954599 0.001727754 0.002418518 0.002821626 0.03507047 0.0007680132 0.001200082 0.001124804 0.7636314 0.001034242 0.0004006448 
## 
## 
## X1, X0, Z1, Z0 all come directly from dataprep object.
## 
## 
## **************** 
##  searching for synthetic control unit  
##  
## 
## **************** 
## **************** 
## **************** 
## 
## MSPE (LOSS V): 19104707 
## 
## solution.v:
##  2.2e-09 5.27e-08 0.9999992 9.55e-08 3.865e-07 1.813e-07 3.28e-08 
## 
## solution.w:
##  7.4243e-06 4.495e-07 1.4097e-06 2.2791e-06 1.0572e-06 2.8307e-06 1.3474e-06 7.3115e-06 6.90558e-05 1.51704e-05 3.844e-07 3.367e-07 2.01599e-05 2.788e-06 6.814e-07 1.2366e-06 1.6275e-06 1.36261e-05 3.369e-07 1.27965e-05 1.6828e-06 2.77388e-05 7.199e-07 3.7144e-06 4.4585e-06 3.342e-07 6.315e-07 1.0161e-06 3.509e-07 1.22787e-05 4.514e-07 0.9997139 9.262e-06 3.284e-07 1.99308e-05 2.3812e-06 6.694e-07 1.10206e-05 6.481e-07 8.9576e-06 3.401e-07 2.8598e-06 4.095e-07 3.261e-07 9.622e-06 1.0689e-06 4.141e-07 1.813e-06 3.46e-07 
## 
## 
## X1, X0, Z1, Z0 all come directly from dataprep object.
## 
## 
## **************** 
##  searching for synthetic control unit  
##  
## 
## **************** 
## **************** 
## **************** 
## 
## MSPE (LOSS V): 37132.83 
## 
## solution.v:
##  0.0001039003 0.0001977963 0.9976114 0.0001417537 0.0003614102 0.00129594 0.0002878482 
## 
## solution.w:
##  0.00594833 0.01541839 0.01187003 0.009416502 0.001758768 0.00992062 0.01161867 0.006156171 0.002743123 0.004451477 0.3628798 0.006872681 0.004003317 0.009085595 0.01514392 0.01306945 0.01079074 0.004589841 0.06291005 0.004914639 0.01211129 0.003486638 0.01616484 0.00729559 0.007692191 0.02442269 0.01480026 0.01282919 0.004789779 0.005103749 0.01102821 0.002389976 0.00550841 0.0374177 0.004030604 0.009750201 0.01736219 0.00528019 0.01643634 0.005450793 0.01927186 0.008865357 0.008412092 0.1166774 0.00551714 0.01441354 0.01075291 0.01064672 0.008530023 
## 
## 
## X1, X0, Z1, Z0 all come directly from dataprep object.
## 
## 
## **************** 
##  searching for synthetic control unit  
##  
## 
## **************** 
## **************** 
## **************** 
## 
## MSPE (LOSS V): 44280.98 
## 
## solution.v:
##  0.008668802 0.0001534973 0.8385697 5.12961e-05 0.1288274 0.02285984 0.0008694664 
## 
## solution.w:
##  0.002672897 0.004719709 0.002439128 0.002142788 0.003208395 0.003066781 0.01984298 0.02553507 0.004045816 0.004031551 0.005024149 0.001947234 0.004392087 0.003665064 0.003128336 0.004550611 0.002041295 0.00238885 0.002499338 0.01952615 0.005246678 0.004110412 0.003224635 0.001947343 0.003571822 0.001977412 0.003472079 0.004223598 0.550346 0.2332554 0.001508482 0.002701214 0.00455464 0.002563061 0.004609327 0.002424589 0.002758878 0.005942824 0.003840909 0.003478561 0.002164712 0.002614795 0.002264468 0.003271555 0.009284081 0.003981341 0.001561318 0.005383247 0.00284835 
## 
## 
## X1, X0, Z1, Z0 all come directly from dataprep object.
## 
## 
## **************** 
##  searching for synthetic control unit  
##  
## 
## **************** 
## **************** 
## **************** 
## 
## MSPE (LOSS V): 1286.642 
## 
## solution.v:
##  4.18e-07 0.0009250228 0.9508513 1.5986e-06 0.04714404 0.0006606376 0.0004169999 
## 
## solution.w:
##  0.008076336 0.3338611 0.008112692 0.012855 0.001848382 0.00723334 0.00731698 0.04877718 0.00269098 0.00524204 0.3198692 0.003692638 0.004153061 0.008973721 0.009187072 0.01066735 0.01060613 0.005962031 7.5762e-06 0.005616504 0.0067572 0.00364592 0.008525587 0.02045607 0.007511428 0.002715222 0.01047074 0.007868075 5.7051e-05 0.004512622 0.004944713 0.002303391 0.006689209 0.004858904 0.004033091 0.009345764 0.005688248 0.004973425 0.005616715 0.007645683 0.004691219 0.01150643 0.004769036 0.0001757239 0.006228173 0.007618368 0.006431128 0.009702645 0.005508894 
## 
## 
## X1, X0, Z1, Z0 all come directly from dataprep object.
## 
## 
## **************** 
##  searching for synthetic control unit  
##  
## 
## **************** 
## **************** 
## **************** 
## 
## MSPE (LOSS V): 205449 
## 
## solution.v:
##  0.01992648 0.006677554 0.9232715 0.04938071 0.0007323313 2.93e-08 1.14234e-05 
## 
## solution.w:
##  0.0005180406 0.001083028 0.0004833246 0.0004720707 0.1725198 0.000493421 0.000621851 0.0005175342 0.0006011859 0.000515253 0.0006138591 0.0003462252 0.0008709755 0.0003515146 0.0003295566 0.0003278001 0.0004455078 0.192485 0.0003634534 0.0005925393 0.0006686516 0.0004187976 0.0005260626 0.0003901286 0.0004762043 0.0004103341 0.0003541357 0.6087311 0.0002930878 0.0007858551 0.0007390893 0.005216551 0.0003636869 0.0003209208 0.000336842 0.0004297295 0.0003933933 0.0003706537 0.0003927335 0.0003854062 0.0003776339 0.0005350033 0.0002203426 0.0003241361 0.0003952921 0.0004389632 0.0004473031 0.0003460764 0.0003598777 
## 
## 
## X1, X0, Z1, Z0 all come directly from dataprep object.
## 
## 
## **************** 
##  searching for synthetic control unit  
##  
## 
## **************** 
## **************** 
## **************** 
## 
## MSPE (LOSS V): 980408 
## 
## solution.v:
##  7.92874e-05 6.65509e-05 0.8985833 3.3634e-06 0.05480646 0.0363684 0.0100926 
## 
## solution.w:
##  0.005020389 0.002525016 0.00315159 0.003256167 0.3818703 0.003089687 0.003860919 0.003225624 1.30602e-05 0.007918804 0.002600661 0.002026983 0.01105177 0.0034753 0.002578131 0.003069269 0.002866267 0.006973312 0.002372781 0.1023074 0.003569816 0.01128076 0.002755677 0.003114493 0.004890692 0.002345685 0.00255719 0.0023977 0.002466601 0.007943986 0.002318139 0.3315114 0.006299989 0.002284019 0.0102831 0.003461384 0.002795857 0.008274303 0.002700068 0.005505656 0.002298981 0.003664945 0.001787671 0.002284874 0.0072339 0.003102113 0.002142224 0.003332051 0.002143241 
## 
## 
## X1, X0, Z1, Z0 all come directly from dataprep object.
## 
## 
## **************** 
##  searching for synthetic control unit  
##  
## 
## **************** 
## **************** 
## **************** 
## 
## MSPE (LOSS V): 46292.9 
## 
## solution.v:
##  0.01459984 0.02709475 0.83409 0.0425504 9.0137e-06 0.04826969 0.03338628 
## 
## solution.w:
##  0.002629265 0.0007685465 0.0008654585 0.001130999 0.0001111701 0.0009929746 0.001342963 0.001219475 0.002468477 0.001737052 0.0008992957 0.0008484516 0.002277241 0.001402071 0.001026479 0.001292169 0.001017464 1.9982e-06 0.000877024 0.0007545206 0.001033787 0.002639339 0.0008824294 0.1425113 0.001319721 0.0007392754 0.001011026 0.0006362587 0.0006714664 0.002102058 0.0006568604 0.2872597 0.102872 0.0008320914 0.002426724 0.001190649 0.0008925031 0.00196296 0.0009989262 0.412712 0.0008198365 0.001335886 0.001848366 0.0008599797 0.00250218 0.0009788063 0.000810726 0.0009585939 0.0008715324 
## 
## 
## X1, X0, Z1, Z0 all come directly from dataprep object.
## 
## 
## **************** 
##  searching for synthetic control unit  
##  
## 
## **************** 
## **************** 
## **************** 
## 
## MSPE (LOSS V): 2586.81 
## 
## solution.v:
##  0.01668576 1.9e-08 0.9598762 0.0227824 0.0003138415 5.54448e-05 0.000286366 
## 
## solution.w:
##  0.0005973371 0.004765495 0.001602056 0.001091643 0.0001331156 0.002679988 0.001439169 0.002095802 0.0006284525 0.0002387943 0.0004312809 0.000602631 0.0003771839 0.001121083 0.003816261 0.002602245 0.001329485 0.0004236897 0.1090022 0.0005155286 0.001867452 0.0003186904 0.003576202 0.0007293274 0.0008626105 0.002279891 0.004046579 0.001323265 0.07929863 0.000531292 0.00152303 0.0001986162 0.0005722581 0.001703092 0.0003859041 0.001184367 0.004685441 0.0005486034 0.00590493 0.0005429892 0.002227406 0.00103022 5.6378e-05 0.7421899 0.0005917757 0.002895223 0.001419124 0.001450843 0.0005625965 
## 
## 
## X1, X0, Z1, Z0 all come directly from dataprep object.
## 
## 
## **************** 
##  searching for synthetic control unit  
##  
## 
## **************** 
## **************** 
## **************** 
## 
## MSPE (LOSS V): 6662.461 
## 
## solution.v:
##  0.002382444 0.001882359 0.9578672 0.00231003 0.001176087 0.03438186 3.6e-09 
## 
## solution.w:
##  0.0002637587 0.0005173882 0.0006213698 0.0004982069 5.08909e-05 0.0006774718 0.0004073993 0.0005242337 0.0002172919 9.62652e-05 0.0001800493 0.0005767533 0.000157701 0.0004510536 0.000887815 0.0006687153 0.0006234645 0.0001900363 0.001281367 0.0001925404 0.0005304769 0.0001350068 0.000742183 0.0003585113 0.000350486 0.2513073 0.0008283448 0.0005413465 0.0001720605 0.0002019662 0.001116519 7.90344e-05 0.0002349136 0.02506088 0.0001622717 0.000503327 0.0008209927 0.0002215272 0.0007381533 0.0002333405 0.5843419 0.0004342307 0.1127002 0.0006149278 0.0002286488 0.0006700711 0.006410676 0.0005276321 0.0006493026 
## 
## 
## X1, X0, Z1, Z0 all come directly from dataprep object.
## 
## 
## **************** 
##  searching for synthetic control unit  
##  
## 
## **************** 
## **************** 
## **************** 
## 
## MSPE (LOSS V): 1262119 
## 
## solution.v:
##  9.001e-07 2.7412e-06 0.9809281 4.59019e-05 0.003575064 0.01167188 0.003775451 
## 
## solution.w:
##  0.0142144 0.007718753 0.007679343 0.009106612 0.2861594 0.007474538 0.01083317 0.008765386 4.2646e-06 0.04227584 0.01243652 0.007116267 0.005638736 0.008818441 0.007329354 0.008512013 0.00763274 0.1884297 0.006698757 0.03406458 0.008212397 0.03761259 0.007778409 3.6716e-06 0.01187462 0.006819576 0.007368889 0.008479187 0.007268147 0.01495867 0.006235293 0.0152395 0.01987015 0.006838199 0.02699211 0.008888068 0.007341423 0.01877488 0.006859347 0.0131574 0.006803872 0.01007876 0.004601099 0.006465368 0.02132354 0.007964309 0.005913444 0.009176188 0.00619212 
## 
## 
## X1, X0, Z1, Z0 all come directly from dataprep object.
## 
## 
## **************** 
##  searching for synthetic control unit  
##  
## 
## **************** 
## **************** 
## **************** 
## 
## MSPE (LOSS V): 41981.89 
## 
## solution.v:
##  0.01882426 0.02517315 0.245677 0.02945462 0.182888 0.1998065 0.2981765 
## 
## solution.w:
##  0.006645731 0.02223036 0.009720947 0.02031247 0.004052602 0.01034097 0.01270774 0.009944644 0.001744611 0.003544647 0.004573825 0.01105023 0.0031832 0.005039216 0.02223678 0.02674928 0.01164274 0.002738154 0.01627053 0.001398851 0.009840069 6.72878e-05 0.02065365 5.57e-06 0.01129328 0.01893237 0.02137594 0.008687938 0.01386001 0.005983979 0.009262877 0.003789055 0.146848 0.02308836 0.07945897 0.01373186 0.01286128 0.009404995 0.01042297 0.003748565 0.02398598 0.01744266 0.265371 0.01241692 0.004676069 0.01263828 0.007367854 0.01675813 0.009898449 
## 
## 
## X1, X0, Z1, Z0 all come directly from dataprep object.
## 
## 
## **************** 
##  searching for synthetic control unit  
##  
## 
## **************** 
## **************** 
## **************** 
## 
## MSPE (LOSS V): 1763.756 
## 
## solution.v:
##  0.0007293111 0.0124726 0.8602986 0.002834 0.01545234 0.1034213 0.004791873 
## 
## solution.w:
##  0.002753611 0.007282699 0.005143106 0.004174658 0.001137933 0.007144647 0.006442134 0.004016352 0.001161618 0.001541995 0.002085218 0.005093174 2.91907e-05 0.002269114 0.005333683 0.01002526 0.006003805 0.001985626 0.6146177 0.002392789 0.007001486 0.0021062 0.01217347 0.0024374 0.004163929 3.5409e-06 0.01086485 0.002734905 0.001151141 0.002696442 0.00210147 0.001355737 0.002772655 0.04118898 0.002558877 0.005593391 0.007944856 0.003311643 0.007355304 0.002279553 0.1154247 0.004216676 0.0424144 4.2827e-06 0.002968926 0.008392025 0.004728037 0.005410089 0.00401075 
## 
## 
## X1, X0, Z1, Z0 all come directly from dataprep object.
## 
## 
## **************** 
##  searching for synthetic control unit  
##  
## 
## **************** 
## **************** 
## **************** 
## 
## MSPE (LOSS V): 57441.34 
## 
## solution.v:
##  0.001672834 0.01702462 0.9057488 0.0003452465 0.02682204 0.04686857 0.001517878 
## 
## solution.w:
##  0.005828398 0.01767183 0.007801074 0.008713561 0.001966771 0.0115865 0.009258731 0.01206762 0.003913715 0.003085313 0.0045238 0.03953209 0.0006194934 0.003966865 0.007764914 0.03419276 0.007376571 0.00431581 1.1637e-06 0.006025572 0.007778908 0.003578161 0.007926671 0.005345366 0.00793211 0.001724259 0.6188021 0.006156126 0.003195858 0.004980227 0.002722771 0.002437052 0.00629972 5.9421e-05 0.004349388 0.009021381 0.02937793 0.005987317 0.01062319 0.005393896 0.00221165 0.008384449 0.002039004 0.01506407 0.00652064 0.01797086 0.00314897 0.00918217 0.00157378 
## 
## 
## X1, X0, Z1, Z0 all come directly from dataprep object.
## 
## 
## **************** 
##  searching for synthetic control unit  
##  
## 
## **************** 
## **************** 
## **************** 
## 
## MSPE (LOSS V): 3702.053 
## 
## solution.v:
##  0.01659815 0.0004327956 0.3632621 0.06086847 0.3766292 0.113763 0.06844631 
## 
## solution.w:
##  7.4586e-06 0.003777812 0.002544462 0.2293835 0.001405627 0.002686353 0.003097111 0.002101552 0.0004899223 0.001786867 0.001801286 0.002534576 2.5987e-06 0.002478222 0.002891827 0.00868476 0.01140631 0.001926084 0.004736663 0.00239556 0.002312216 0.003554655 0.0063074 0.001814572 0.004592567 0.006721325 0.005958317 0.00170888 0.002044791 0.001661518 0.001342085 0.001210393 0.003184446 0.006988889 0.05844707 0.01022983 0.003765297 0.005154564 0.002178881 0.001982637 0.01394317 0.008938952 0.0786417 0.002322262 0.00333415 0.00352567 0.467009 0.003402406 0.00158375 
## 
## 
## X1, X0, Z1, Z0 all come directly from dataprep object.
## 
## 
## **************** 
##  searching for synthetic control unit  
##  
## 
## **************** 
## **************** 
## **************** 
## 
## MSPE (LOSS V): 624688.4 
## 
## solution.v:
##  0.003493718 0.02117972 0.9241462 0.0127485 0.002162474 0.006929816 0.02933957 
## 
## solution.w:
##  0.0001822565 0.0005953041 0.0006794355 0.0003883089 0.1734588 0.0005414281 0.0005231972 0.000652646 0.00330532 0.1766217 0.0008519701 0.0005713985 0.0003283322 0.001267361 0.0004584015 0.000454261 0.0004558695 0.0003728749 0.0004936402 0.0009881164 0.0005429193 0.001174592 0.0005532725 0.6185036 0.0007009326 0.0006111064 0.0004847078 0.001460322 0.000809624 0.0008160264 0.0006038031 0.0013394 0.000665803 0.000534851 0.0008217952 0.0004546443 0.000572916 0.0007705561 0.0005098407 0.0005683042 0.000501193 0.0005191893 2.623e-07 0.0005267639 0.000742357 0.000562406 0.0002752163 0.0007348051 0.0004480595 
## 
## 
## X1, X0, Z1, Z0 all come directly from dataprep object.
## 
## 
## **************** 
##  searching for synthetic control unit  
##  
## 
## **************** 
## **************** 
## **************** 
## 
## MSPE (LOSS V): 10597.27 
## 
## solution.v:
##  0.0002750058 0.01302768 0.9343017 0.0003581923 0.05076141 0.0008416242 0.0004344019 
## 
## solution.w:
##  0.0003503615 0.001763456 0.0008942442 0.0006586444 7.11569e-05 0.001189126 0.0006171673 0.0009252017 0.0003851908 0.0001272331 0.000241276 0.1921095 0.1047021 0.000206386 0.0005972536 0.00136857 0.0009932969 0.0007938025 0.0002532421 0.0002653007 0.0008530743 0.0001745282 0.001389908 0.0004957037 0.0004680435 0.1578504 0.001442243 0.001001156 0.00120232 0.0002749491 0.001849012 0.0001073446 0.0003124011 0.386978 0.0002080284 0.000661295 0.001709657 0.000287557 0.001813242 0.0003155283 0.02892613 0.000589299 0.004971252 0.08822363 0.0003073996 0.001137448 0.00229165 0.0007230661 0.004923188 
## 
## 
## X1, X0, Z1, Z0 all come directly from dataprep object.
## 
## 
## **************** 
##  searching for synthetic control unit  
##  
## 
## **************** 
## **************** 
## **************** 
## 
## MSPE (LOSS V): 245381.9 
## 
## solution.v:
##  8.727e-07 4.41491e-05 0.9241187 0.02097808 0.001954459 0.05214937 0.0007543959 
## 
## solution.w:
##  0.06659584 0.003415958 0.003562541 0.006945207 0.03769921 0.004220193 0.007229748 0.005314559 0.1233383 0.03519213 0.1249134 0.00410584 0.002714333 0.0136607 0.004537287 0.004039007 0.00630811 0.004323643 0.09282934 0.00346178 0.004297592 0.01291308 0.00402022 2.84511e-05 0.006781871 0.00320703 0.00402139 0.002910044 0.002590992 0.0102144 0.003026368 0.09382165 0.1185884 0.003243616 0.01588128 0.005536484 0.003895087 0.01236103 0.003635478 0.0110907 0.00340306 0.007864013 0.002449227 0.002961809 0.09255763 0.004345023 0.003322954 0.003776362 0.002847671 
## 
## 
## X1, X0, Z1, Z0 all come directly from dataprep object.
## 
## 
## **************** 
##  searching for synthetic control unit  
##  
## 
## **************** 
## **************** 
## **************** 
## 
## MSPE (LOSS V): 22573.31 
## 
## solution.v:
##  0.0005925217 1.28486e-05 0.5948939 0.05434985 0.2000817 0.03212049 0.1179487 
## 
## solution.w:
##  0.00279818 0.00459981 0.006390986 0.003451621 0.00484453 1.75698e-05 0.03079705 0.004944921 0.04156979 0.00988065 0.003276846 0.0002534592 0.003117412 0.004589821 0.004073843 0.005112648 0.0008104057 0.003705083 0.002475238 0.005840693 0.006960189 0.003574477 0.008739998 0.001431022 0.005772232 0.005221698 0.00533172 0.03556757 0.001412354 0.01536205 0.00385866 0.01032745 0.003691829 0.004697911 0.004691501 0.004498056 0.6705542 0.007200682 0.008501355 0.002400671 0.004822301 0.003877954 0.001942475 0.004800765 0.005083242 0.01574031 0.003093746 0.004744905 0.003548147 
## 
## 
## X1, X0, Z1, Z0 all come directly from dataprep object.
## 
## 
## **************** 
##  searching for synthetic control unit  
##  
## 
## **************** 
## **************** 
## **************** 
## 
## MSPE (LOSS V): 176142.9 
## 
## solution.v:
##  0.3380236 0.02773438 0.3156696 0.1814824 0.02868618 0.05961221 0.04879165 
## 
## solution.w:
##  0.004832337 0.002812985 0.002760879 0.004247447 0.3884419 0.002678742 0.003309032 0.003147254 0.0009624537 0.001504762 0.002408661 0.002385769 0.00405972 0.008302215 0.005420918 0.003469417 0.003479853 0.004034241 0.006932274 0.002985298 0.004149388 0.002821598 0.002852198 2.3785e-06 0.003931377 0.002713866 0.003454095 0.001739436 0.00254809 0.003371101 0.002448344 0.0006205179 1.2e-09 0.00326964 0.2395032 0.003941624 0.002575608 0.005384629 0.002936487 0.142009 0.003110785 0.004416937 0.08151227 0.003340899 0.005389585 0.002730741 0.003305375 0.003644881 0.004099791 
## 
## 
## X1, X0, Z1, Z0 all come directly from dataprep object.
## 
## 
## **************** 
##  searching for synthetic control unit  
##  
## 
## **************** 
## **************** 
## **************** 
## 
## MSPE (LOSS V): 180369.2 
## 
## solution.v:
##  0.141637 0.1449429 0.1449998 0.08791047 0.1549178 0.1844985 0.1410935 
## 
## solution.w:
##  0.0009260172 0.1872631 0.001613415 0.002104301 0.000770236 0.003843658 0.1494553 0.000703082 0.0002079912 0.001496696 0.0005789285 0.004126806 0.0008425009 0.001059478 0.001042338 0.002399245 0.01066068 0.002670924 0.0006631243 1.39988e-05 0.0009945471 0.003393119 0.0008406711 0.0003828967 0.002110579 0.02488976 0.002203904 0.0004530587 0.001455858 0.0008129155 0.003779279 0.0007540583 0.0009186809 0.001218515 0.001286585 0.003262018 0.3238808 0.001982458 0.001085399 0.0005001254 0.2277844 0.002010875 0.0002923655 0.0006862062 0.001012973 0.01324743 0.004703998 0.0008876039 0.0007270082 
## 
## 
## X1, X0, Z1, Z0 all come directly from dataprep object.
## 
## 
## **************** 
##  searching for synthetic control unit  
##  
## 
## **************** 
## **************** 
## **************** 
## 
## MSPE (LOSS V): 35075.46 
## 
## solution.v:
##  0.008878273 0.01048457 0.902179 0.06240766 0.01244945 0.0003711498 0.003229878 
## 
## solution.w:
##  1.0697e-06 5.84424e-05 7.93377e-05 1.23271e-05 6.3e-09 2.94071e-05 1.52796e-05 4.13294e-05 0.0001060214 5.9841e-06 7.5151e-06 3.85907e-05 0.0001339786 1.13287e-05 2.12799e-05 2.25522e-05 9.8855e-06 1.66314e-05 0.4168962 4.36029e-05 1.12784e-05 2.63878e-05 3.9514e-06 3.76449e-05 2.26767e-05 0.0001464395 3.12444e-05 0.0001183356 8.37622e-05 1.21852e-05 0.002780591 9.318e-07 7.4289e-06 7.96721e-05 2.5984e-06 8.3122e-06 3.85716e-05 7.302e-06 3.41081e-05 8.7359e-05 7.04991e-05 1.95203e-05 4.3e-09 6.52738e-05 9.2375e-06 2.89262e-05 0.5785781 6.05085e-05 7.63866e-05 
## 
## 
## X1, X0, Z1, Z0 all come directly from dataprep object.
## 
## 
## **************** 
##  searching for synthetic control unit  
##  
## 
## **************** 
## **************** 
## **************** 
## 
## MSPE (LOSS V): 84897.33 
## 
## solution.v:
##  0.03380432 0.002130326 0.9018343 1.6841e-06 0.03566325 0.02656545 7.131e-07 
## 
## solution.w:
##  0.02395773 0.01624859 0.01843354 0.02639601 0.01348942 0.0161978 0.01408465 0.0143822 0.008519448 0.01549876 0.01646314 0.01497677 0.02213228 0.0184115 0.01875247 0.01896849 0.01738573 0.02658707 0.02788723 0.0191113 0.01374588 0.0150204 0.09081386 0.01768924 0.02668529 0.02360199 0.01818537 0.01536406 0.0159946 0.01333747 0.02903901 0.01119225 0.01837952 0.02109348 0.02403571 0.02216991 0.01735322 0.01810307 0.01578404 0.01845573 0.02288809 0.02069535 0.01830836 0.01779893 0.01584221 0.01632954 0.03757958 0.01771258 0.01891717 
## 
## 
## X1, X0, Z1, Z0 all come directly from dataprep object.
## 
## 
## **************** 
##  searching for synthetic control unit  
##  
## 
## **************** 
## **************** 
## **************** 
## 
## MSPE (LOSS V): 20583.52 
## 
## solution.v:
##  0.000580749 0.00651237 0.984594 0.0001149397 0.0006913981 0.001254095 0.006252453 
## 
## solution.w:
##  0.0005905921 0.001212576 0.001442245 0.001130387 0.0001344706 0.001563486 0.0008901463 0.001257231 0.0005845716 0.0002315388 0.000408401 0.00233663 1.1e-09 0.0003540787 0.0009133072 0.001723843 0.001481761 0.001236469 0.0004415344 0.002479052 0.0004510222 0.001135866 0.0003023353 0.001819462 0.000800935 0.0007963826 0.001664944 0.002078153 0.001267907 0.0004525369 0.002827711 0.0001901138 0.0005291857 0.4655884 0.0003585159 0.001082855 0.0025974 0.0004932582 0.001510129 0.0005343188 0.4874635 0.0009716487 9.30514e-05 0.0002114062 0.0005131442 0.0016459 0.0007995296 0.001204331 0.0002037551 
## 
## 
## X1, X0, Z1, Z0 all come directly from dataprep object.
## 
## 
## **************** 
##  searching for synthetic control unit  
##  
## 
## **************** 
## **************** 
## **************** 
## 
## MSPE (LOSS V): 1316.787 
## 
## solution.v:
##  3.6452e-06 8.61288e-05 0.9160864 0.003896324 0.05780093 0.02191738 0.0002091582 
## 
## solution.w:
##  0.00280608 0.1045438 0.003420925 0.006255447 0.0004591329 0.004392662 0.00382667 0.008737319 0.001398804 0.0007677116 0.001604035 0.007696748 0.00160948 0.001331075 0.003714937 0.008551443 0.008239664 0.005284379 0.001804396 0.005441474 0.001848353 0.003663122 0.00115237 0.007008508 0.006303174 0.002942851 0.002043337 0.001730603 0.0005198299 0.001505493 0.00254091 0.0006138332 0.00232895 0.3224794 0.001356071 0.00436391 0.004442221 0.001795571 0.004581784 0.002354221 0.02669337 0.005017551 6.07589e-05 0.0007045115 0.002203171 0.004701474 0.397654 0.003982115 0.001522407 
## 
## 
## X1, X0, Z1, Z0 all come directly from dataprep object.
## 
## 
## **************** 
##  searching for synthetic control unit  
##  
## 
## **************** 
## **************** 
## **************** 
## 
## MSPE (LOSS V): 11924.72 
## 
## solution.v:
##  0.03678836 0.1782561 0.7361965 0.04571133 0.0001555703 0.00288553 6.5549e-06 
## 
## solution.w:
##  0.0001190742 -6e-10 0.0001454889 0.000163976 1.25203e-05 4.83145e-05 1.1853e-06 3.02223e-05 0.06685855 1.5821e-06 7.19102e-05 2.11794e-05 0.0001263083 5.19478e-05 6.44271e-05 6.00879e-05 4.43969e-05 0.0001153696 0.06269389 7.93075e-05 3.29517e-05 1.69671e-05 4.80093e-05 4.99606e-05 0.004029888 7.70746e-05 0.0003117883 5.97005e-05 0.8571363 2.46301e-05 0.006073344 3.22659e-05 6.6458e-05 0.0001315015 4.68849e-05 8.76154e-05 7.24085e-05 4.56803e-05 3.90903e-05 0.0001528695 0.0001269275 9.81893e-05 5.25647e-05 7.42085e-05 4.00765e-05 4.48602e-05 0.0001524316 8.89772e-05 7.66896e-05 
## 
## 
## X1, X0, Z1, Z0 all come directly from dataprep object.
## 
## 
## **************** 
##  searching for synthetic control unit  
##  
## 
## **************** 
## **************** 
## **************** 
## 
## MSPE (LOSS V): 3025.232 
## 
## solution.v:
##  0.001736981 8.6e-09 0.9889157 0.0001910801 0.001219228 0.00782371 0.0001132526 
## 
## solution.w:
##  0.0003382916 0.006373175 0.000737792 0.0004040299 8.20342e-05 0.0008996359 0.0009805821 0.001400651 0.0003881722 0.0001594136 0.0002822505 0.02449427 0 0.0002587435 0.0006274161 0.0005893141 0.0008145331 0.0004212017 0.0002594336 5.6036e-06 0.0003553594 0.001093171 0.0002187826 0.0008161812 0.0003250168 0.0005074632 8e-10 0.0006511843 0.00328065 0.0003731943 3.23486e-05 0.0001273928 0.0003661382 3.6284e-06 0.0002624374 0.0004894404 0.0008289865 0.0003689406 0.001873076 0.0003515165 5e-10 0.000464314 2.09475e-05 0.9448508 0.0004000431 0.001150253 1.34427e-05 0.001092813 0.0001659231 
## 
## 
## X1, X0, Z1, Z0 all come directly from dataprep object.
## 
## 
## **************** 
##  searching for synthetic control unit  
##  
## 
## **************** 
## **************** 
## **************** 
## 
## MSPE (LOSS V): 160392.2 
## 
## solution.v:
##  0.02077074 0.002984019 0.2913672 0.000969642 0.1974904 0.002421398 0.4839966 
## 
## solution.w:
##  0.003093011 0.006331371 0.005457415 0.003094019 0.00439439 0.006701778 0.2623236 0.00928537 0.1157202 0.3648031 0.005719351 0.002284673 0.002649003 0.008288102 0.004980716 0.005554217 0.006628254 0.003138707 0.003095957 0.005233958 0.02291141 0.009363817 0.007318779 0.005769273 0.0009213358 0.006151022 0.00420155 0.005716255 1.05387e-05 0.008737102 0.002991775 9.29843e-05 0.005775476 0.004663843 0.008418033 0.004164781 0.005659274 0.01071069 0.008050755 0.003790292 0.004222305 0.003942747 0.0003910085 0.005954364 0.01115865 0.006342375 0.002368172 0.007152568 0.004270645 
## 
## 
## X1, X0, Z1, Z0 all come directly from dataprep object.
## 
## 
## **************** 
##  searching for synthetic control unit  
##  
## 
## **************** 
## **************** 
## **************** 
## 
## MSPE (LOSS V): 544.2009 
## 
## solution.v:
##  3.708e-05 3.8461e-06 0.9317252 0.02520996 0.04272788 2.459e-07 0.0002957641 
## 
## solution.w:
##  0.0009377417 0.003614332 0.002403037 0.001776154 0.0002032708 0.002808173 0.001478805 0.002382915 0.001504961 0.0003524059 0.0006543327 0.2840525 0.5362113 0.0005514529 0.00151392 0.002660324 0.002109227 0.002106891 0.0007010019 0.0003401135 0.0006987208 0.002092883 0.0004655029 0.002832237 0.001465468 0.001205597 0.0005559478 0.002805282 0.003476932 0.09594242 0.0007345174 0.0002992498 0.0008169432 0.0003751672 0.0005435632 0.001685912 0.003446854 0.0007385452 0.003667245 0.0008611164 0.001504118 0.001543472 0.004521958 0.0009261587 0.0007932162 0.00252742 0.01129978 0.00181729 0.001993625 
## 
## 
## X1, X0, Z1, Z0 all come directly from dataprep object.
## 
## 
## **************** 
##  searching for synthetic control unit  
##  
## 
## **************** 
## **************** 
## **************** 
## 
## MSPE (LOSS V): 2731312 
## 
## solution.v:
##  0.00985594 1.6174e-06 0.9541101 0.0004060953 0.0003601286 5.1232e-06 0.03526095 
## 
## solution.w:
##  0.004252693 0.0019419 0.002399008 0.00271068 0.6363194 0.002309247 0.003046515 0.00231933 0.00651281 0.2015697 0.006657676 0.002000054 0.001738417 0.008836992 0.002677619 0.002046916 0.00234901 0.002385733 0.006378784 0.00191851 0.007193475 0.002538128 0.009667112 0.00214068 0.002734701 0.003683226 0.001952124 0.002017537 0.002264144 0.001791386 0.006994974 0.002005454 0.00496128 0.001872344 0.008262199 0.002772281 0.002143844 0.006151203 0.002019069 0.004516545 0.001922555 0.002946143 0.001517097 0.001808636 0.005338704 0.002312507 0.001908558 0.002431747 0.001761363 
## 
## 
## X1, X0, Z1, Z0 all come directly from dataprep object.
## 
## 
## **************** 
##  searching for synthetic control unit  
##  
## 
## **************** 
## **************** 
## **************** 
## 
## MSPE (LOSS V): 1143376 
## 
## solution.v:
##  0.02247188 0.0136693 0.5397368 0.03853837 0.008488204 0.373041 0.004054479 
## 
## solution.w:
##  0.2684295 0.0008906614 0.001295758 0.003226566 0.001494969 0.00144316 0.001207032 0.001764615 0.0006418052 0.0009098803 0.2727903 0.0011943 0.001627627 0.0014077 0.002881401 0.002186907 0.003520699 0.002128231 0.0002316201 0.001613768 2.749e-07 0.00113602 0.001917797 0.00128053 3.7483e-06 0.00215071 0.001284652 0.001999194 0.0006912556 0.0008287195 0.001289198 0.00105067 0.0003289417 0.001643446 0.005290206 0.002515451 0.001509925 0.003341936 0.001559911 0.02408787 0.001557797 0.002762145 0.02828246 0.001476542 0.3349126 0.001487778 0.001725859 0.001529072 0.001468777 
## 
## 
## X1, X0, Z1, Z0 all come directly from dataprep object.
## 
## 
## **************** 
##  searching for synthetic control unit  
##  
## 
## **************** 
## **************** 
## **************** 
## 
## MSPE (LOSS V): 6715.951 
## 
## solution.v:
##  0.00356619 0.0134338 0.9229588 0.008551692 0.03322462 0.01536293 0.002901993 
## 
## solution.w:
##  0.0003179928 0.0001768452 0.0005179484 0.0005250436 7.14783e-05 0.0003421704 0.0002892029 0.0004177177 0.000100723 0.0001139026 0.0002074698 9.51714e-05 0.02651471 0.0001855118 0.0005141679 0.0007743393 0.0005634169 0.0005657158 0.0002256075 1.41498e-05 0.0002058724 0.0003085038 0.0001741867 0.0003985928 0.00041992 0.0003758627 0.2670363 0.0007152945 0.0004901651 0.002831497 0.0001834397 0.0001366774 8.52148e-05 0.0002955427 0.0002056237 0.0004851867 0.0004160761 0.000257353 0.0003312762 0.0002978923 0.4737762 0.0004461374 0.001589293 0.2083316 0.0002677898 0.0004133523 3.082e-07 0.0007601357 0.006231441 
## 
## 
## X1, X0, Z1, Z0 all come directly from dataprep object.
## 
## 
## **************** 
##  searching for synthetic control unit  
##  
## 
## **************** 
## **************** 
## **************** 
## 
## MSPE (LOSS V): 611989.5 
## 
## solution.v:
##  0.1034813 0.07435648 0.5402837 0.05441008 4.8e-07 0.07843717 0.1490308 
## 
## solution.w:
##  0.003202851 0.001039481 0.002219045 0.003430387 0.1986767 0.003340777 0.003115168 0.002112804 0.0004880895 0.2042316 0.005647081 0.002125003 0.0004015879 0.004452157 0.00312419 0.005044327 0.01708423 0.002527 0.00213386 0.00316273 0.01139911 0.002246652 0.008795234 0.002554217 1.7796e-06 0.005101093 0.002124382 0.003669481 0.0007267687 0.0008918041 0.005129987 0.001213029 0.1186046 0.01473379 0.002521448 0.005114879 0.003913894 0.05404712 0.002831705 0.002042416 0.002617186 0.00357345 0.2477833 0.0018401 0.02039407 0.003792791 0.00153092 0.002244347 0.001001283 
## 
## 
## X1, X0, Z1, Z0 all come directly from dataprep object.
## 
## 
## **************** 
##  searching for synthetic control unit  
##  
## 
## **************** 
## **************** 
## **************** 
## 
## MSPE (LOSS V): 14000.37 
## 
## solution.v:
##  0.01901043 0.06625127 0.7864408 0.01980585 0.07927661 0.02191293 0.007302137 
## 
## solution.w:
##  0.007753601 0.002701175 0.004148738 0.1894915 2.91861e-05 0.005366127 0.004082213 0.003429714 0.002430852 0.003831559 0.00457348 0.003759002 0.003055807 0.003310657 0.006208206 0.006885257 0.1341932 0.01469579 0.001078515 0.005047816 0.004716641 0.004021966 1.89525e-05 0.004584315 0.002543954 0.006425291 0.003310469 0.005498754 0.001990419 0.002027744 0.004466585 0.001867931 0.01545753 0.005235726 0.003784995 0.08951899 0.005183134 0.009173711 0.004340453 0.003100161 0.004485343 0.009838238 0.008219064 0.00341931 0.005583443 0.005054025 0.3733462 0.003343256 0.003370919 
## 
## 
## X1, X0, Z1, Z0 all come directly from dataprep object.
## 
## 
## **************** 
##  searching for synthetic control unit  
##  
## 
## **************** 
## **************** 
## **************** 
## 
## MSPE (LOSS V): 6687.111 
## 
## solution.v:
##  0.04393433 0.0001210801 0.9087114 8.14192e-05 0.04579166 0.001166503 0.0001936546 
## 
## solution.w:
##  0.002486223 0.003813578 0.007493113 0.004374486 0.0007574203 0.009679497 0.004301748 0.004696804 0.004083086 0.001228242 0.001922704 0.4220397 0.001776805 0.001714336 0.004155535 0.008098704 0.006165898 0.005654887 0.001942612 0.3003228 0.00210491 0.006349005 0.001469019 0.008710439 0.002941686 0.003562455 0.03965502 0.006998212 0.008566444 0.02313264 0.002402019 0.02097586 0.001091098 0.002310714 0.004707876 0.001722999 0.00483522 0.002342078 0.01069708 0.002281374 0.005621297 0.003964787 0.005372338 0.004641463 0.002324634 0.008646304 0.007645414 0.004822885 0.003396573 
## 
## 
## X1, X0, Z1, Z0 all come directly from dataprep object.
## 
## 
## **************** 
##  searching for synthetic control unit  
##  
## 
## **************** 
## **************** 
## **************** 
## 
## MSPE (LOSS V): 30870.62 
## 
## solution.v:
##  0.04530967 0.005491949 0.7048628 0.1427154 1.9e-07 0.0007596292 0.1008604 
## 
## solution.w:
##  0.00227096 0.002174982 0.002507883 0.002148752 0.04845776 0.004171286 3.13696e-05 0.003463851 0.001156205 0.005764577 0.003318089 0.003624946 0.001924506 0.003969541 0.00408759 0.005209398 0.3376497 0.002354385 0.001560873 0.00347163 0.1801548 0.004390207 0.00516576 0.0034526 0.0009366788 0.003787534 0.002207701 0.004292702 0.001364283 0.00156894 0.02140106 0.001414124 0.2047258 0.00505747 0.002785908 0.03535408 0.003066744 0.004106888 0.004527533 0.001997147 0.002668081 0.002572019 0.0048539 0.002867725 0.04379788 0.005020591 0.001912308 0.002956979 0.002274237 
## 
## 
## X1, X0, Z1, Z0 all come directly from dataprep object.
## 
## 
## **************** 
##  searching for synthetic control unit  
##  
## 
## **************** 
## **************** 
## **************** 
## 
## MSPE (LOSS V): 7692.122 
## 
## solution.v:
##  3.1188e-06 0.0003667171 0.9809305 0.008118642 0.001271558 0.005801673 0.003507781 
## 
## solution.w:
##  0.002480067 0.006349235 0.005717118 0.004010855 0.0006731424 0.007682271 0.00494755 0.004897824 0.002534004 0.001096342 0.001843482 0.3920438 0.00119226 0.00167466 0.004257639 0.008110268 0.006470451 0.005104018 0.001859405 0.2809913 0.002062948 0.006462214 0.001437453 0.008460461 0.002833842 0.003442667 0.01195394 0.00718064 0.004857226 2.6733e-06 0.002257702 0.004297738 0.0009612278 0.002314162 0.0141795 0.001698428 0.004545165 0.008973823 0.002304893 0.002224246 0.005601933 0.003872857 0.06058738 0.073264 0.002360994 0.007507038 0.002094213 0.00483265 0.003492328 
## 
## 
## X1, X0, Z1, Z0 all come directly from dataprep object.
## 
## 
## **************** 
##  searching for synthetic control unit  
##  
## 
## **************** 
## **************** 
## **************** 
## 
## MSPE (LOSS V): 49819.01 
## 
## solution.v:
##  0.06914471 4.1431e-06 0.8853913 0.007312845 0.02948518 0.002033158 0.006628691 
## 
## solution.w:
##  0.00564791 0.005963178 0.004646188 0.003103529 4.03738e-05 0.00390182 0.004635229 0.007617135 0.03225356 0.004877468 0.03833059 0.004242094 0.005472567 0.009668416 0.005827873 0.003759368 0.003516407 0.003363378 1.09853e-05 0.003798096 0.007312596 0.004681107 0.3576414 0.0038005 0.3102881 0.00453248 0.003672522 0.004129307 0.009879937 0.04022418 0.00637306 0.00309409 0.004804696 0.008445678 0.004328676 0.005761502 0.003440685 0.003660643 0.004928855 0.004842642 0.003605174 0.003913191 0.01158971 0.006033827 0.007491699 0.00389831 0.002662714 0.007409032 0.006877498 
## 
## 
## X1, X0, Z1, Z0 all come directly from dataprep object.
## 
## 
## **************** 
##  searching for synthetic control unit  
##  
## 
## **************** 
## **************** 
## **************** 
## 
## MSPE (LOSS V): 5567.877 
## 
## solution.v:
##  0.01107954 0.006980647 0.9286176 0.0001107774 0.02742474 0.02551369 0.0002730145 
## 
## solution.w:
##  0.0003968191 0.004063343 0.0007938034 0.0007375345 7.65597e-05 0.0008753538 0.0006403543 0.0008034444 0.0002253189 0.000134179 0.0002551227 0.001184466 0.006825032 0.0002331383 0.0006512922 0.001367005 0.0009579157 0.000900875 0.0002797897 0.001550154 0.0002770911 0.0007839281 0.000201206 0.001474668 0.0005586678 0.0005007046 0.647589 0.001446608 0.0008033167 0.002092992 0.0002730614 0.0009264632 0.0001090135 0.0003452022 0.3047804 0.0002380402 0.0007125956 0.0009391068 0.0003163638 0.001002781 0.0003409303 0.0006575714 0.0005973184 0.001278336 0.0003365181 0.0009151619 6.1729e-06 0.0007991075 0.006746179 
## 
## 
## X1, X0, Z1, Z0 all come directly from dataprep object.
## 
## 
## **************** 
##  searching for synthetic control unit  
##  
## 
## **************** 
## **************** 
## **************** 
## 
## MSPE (LOSS V): 76590.09 
## 
## solution.v:
##  0.09461705 0.01024031 0.7581096 0.07588908 0.01815256 0.01832825 0.02466314 
## 
## solution.w:
##  0.0285007 0.004291338 0.004928821 0.6160347 0.004109356 0.008096369 0.008941259 0.005523879 0.004074475 0.004349021 0.007789884 0.006127002 0.00607228 0.005866678 0.008784586 0.01040863 0.02219574 0.02577777 0.006522104 0.00726185 0.008492509 0.006772071 0.005772739 0.007062102 0.0008658024 0.00848257 0.005110192 0.008447425 0.002295175 0.00252956 0.006766885 0.005028782 0.006731639 0.01081021 0.005432626 0.007807154 0.02831318 0.006640519 0.008582908 0.006304005 0.005842963 0.007156087 0.01244496 0.004522091 0.00975884 0.007224529 0.0001445028 0.004117545 0.004884128 
## 
## 
## X1, X0, Z1, Z0 all come directly from dataprep object.
## 
## 
## **************** 
##  searching for synthetic control unit  
##  
## 
## **************** 
## **************** 
## **************** 
## 
## MSPE (LOSS V): 149.5132 
## 
## solution.v:
##  0.1304244 0.1499281 0.2247498 4.2346e-06 0.06558226 0.2182843 0.2110269 
## 
## solution.w:
##  0.0007739735 0.0002895349 0.0002449714 0.0001998477 0.0004267314 0.0002638066 0.0003280554 0.0005165286 0.0002489891 0.0002090679 0.001269695 0.0002430724 0.9781954 0.0004792633 0.0013282 0.0003234417 0.000320758 0.000203426 0.0004772293 0.0002412964 0.0003672279 0.0003350625 0.00093313 0.0002188531 2.03204e-05 0.0003107115 0.0001208005 0.0003612211 0.0001804245 0.000445357 0.0003782898 5.90344e-05 0.0003606853 0.0009712323 0.0002443358 0.000719814 0.0002522486 0.0002022422 0.0004090022 0.000464478 0.002209487 0.0001616903 0.0003116222 0.0006363142 0.0006907732 0.0002492205 1.0894e-06 0.0004856725 0.001316386 
## 
## 
## X1, X0, Z1, Z0 all come directly from dataprep object.
## 
## 
## **************** 
##  searching for synthetic control unit  
##  
## 
## **************** 
## **************** 
## **************** 
## 
## MSPE (LOSS V): 12886.62 
## 
## solution.v:
##  0.001754592 0.03214742 0.8904965 0.0009785042 0.05666216 0.01371731 0.00424349 
## 
## solution.w:
##  0.000234582 0.001240098 0.0005865463 0.0004139667 6.38667e-05 0.0007424522 0.0004041516 0.0006061004 0.0002344697 9.80772e-05 0.0001688643 0.002552023 6.0805e-06 0.0001477239 0.0004007619 0.0008692697 0.0006382987 0.0004927769 0.0001741695 0.2889796 0.000183594 0.0005520158 0.0001287171 0.0008531636 0.0003119277 0.0003143538 1.3799e-06 0.0009163376 0.0007333405 0.2928943 0.0001902669 0.0006163345 8.56012e-05 0.0002152847 0.2419165 0.0001505358 0.0004251414 0.001067444 0.0002017094 0.001203323 0.000216095 0.000631985 0.0003771765 0.1528673 0.0002122321 0.0007413605 0.0004312331 0.0005057667 0.002001693 
## 
## 
## X1, X0, Z1, Z0 all come directly from dataprep object.
## 
## 
## **************** 
##  searching for synthetic control unit  
##  
## 
## **************** 
## **************** 
## **************** 
## 
## MSPE (LOSS V): 48331.25 
## 
## solution.v:
##  0.03430066 0.04301534 0.8503724 0.03738024 0.03160716 0.001243822 0.002080419 
## 
## solution.w:
##  0.001490586 0.0005907524 0.0018066 0.001350019 1.2592e-05 0.0018832 0.2043457 0.001816299 0.0007032503 0.002619985 0.003035044 0.001116891 0.001603438 0.003282279 0.002746496 0.002366587 0.003714894 0.001341757 0.001634047 0.001942707 0.1707907 0.0005554755 6.959e-06 0.001668661 0.001282879 0.002385507 0.001553941 0.002385443 0.001182398 0.00118403 3.833e-07 0.001238188 0.0008240635 0.003096267 0.00196223 0.4481826 0.001545799 0.002105658 0.01313394 0.002402418 0.002380502 0.00162827 0.001615756 0.08699121 0.002416226 0.002193134 0.00112889 0.002713482 0.002041888 
## 
## 
## X1, X0, Z1, Z0 all come directly from dataprep object.
## 
## 
## **************** 
##  searching for synthetic control unit  
##  
## 
## **************** 
## **************** 
## **************** 
## 
## MSPE (LOSS V): 15634.17 
## 
## solution.v:
##  2.2e-09 0.000139339 0.9525549 0.04685461 4.11e-07 2.1679e-06 0.000448564 
## 
## solution.w:
##  0.006277327 0.004124494 0.01062354 0.01030816 0.001930802 0.01500427 0.01061242 0.01108008 0.005644316 0.002871935 0.004582029 0.2611699 0.001712778 0.004095351 0.009280749 0.01878672 0.01685068 0.01153779 0.004667123 0.3179246 0.005163333 0.01193836 0.003594248 0.01687045 0.007496648 0.00798362 0.004708725 0.01706068 0.006224302 0.002366825 0.005228417 0.006318194 0.002538859 0.005788022 0.01288652 0.004203569 0.01065481 0.01851727 0.005537024 0.01510445 0.005475714 0.049602 0.00958799 0.003103503 0.002465781 0.005816632 0.01292906 0.009431448 0.002318452 
## 
## 
## X1, X0, Z1, Z0 all come directly from dataprep object.
## 
## 
## **************** 
##  searching for synthetic control unit  
##  
## 
## **************** 
## **************** 
## **************** 
## 
## MSPE (LOSS V): 1406.102 
## 
## solution.v:
##  1.92658e-05 0.01067273 0.9195942 0.001279275 0.06739488 2.97319e-05 0.00100988 
## 
## solution.w:
##  0.0007098169 4.85529e-05 0.0005247747 0.00226046 0.0001111472 0.0002169585 0.0001583767 0.0001769063 8.83335e-05 0.0001916993 0.0003585604 4.17447e-05 0.00576568 0.0002645032 0.0006606942 0.0004847781 0.0005398078 0.001887746 0.0004898172 3.96023e-05 0.0002467132 0.0001624486 0.0002779798 0.0001643969 0.001752177 0.0005534854 0.4439546 0.0002798672 0.0001316844 3.50963e-05 0.0002015772 0.001246112 0.0001292854 0.0005111804 0.0004550793 0.0003371528 0.001106267 0.0002434774 0.000377668 0.0001159767 0.0005639739 1.0607e-06 0.0008499473 0.5301904 2.23557e-05 0.0003442625 0.0002342535 0.0004812175 1.03673e-05 
## 
## 
## X1, X0, Z1, Z0 all come directly from dataprep object.
## 
## 
## **************** 
##  searching for synthetic control unit  
##  
## 
## **************** 
## **************** 
## **************** 
## 
## MSPE (LOSS V): 27612.6 
## 
## solution.v:
##  0.1713258 0.001840659 0.2764761 0.005266829 0.1432246 0.3174792 0.08438671 
## 
## solution.w:
##  0.009341885 0.003088688 0.00369473 0.006866062 0.002697744 0.003077437 1.75308e-05 0.006921377 0.001393746 0.003285797 0.005551867 0.001964507 0.004359584 0.005600241 0.01091933 0.07765328 0.03149327 0.004764557 0.004603079 0.003047416 0.00814014 0.001983088 0.006115814 0.003338729 0.005796749 0.006067975 0.004011103 0.02154469 0.001701194 0.4620366 0.003168649 0.003566641 0.002161158 0.02824371 0.08925948 0.05703116 0.005248435 0.002502559 0.00623308 0.001219502 0.009201451 0.001804224 0.007968775 0.02262273 9.8494e-06 0.03084523 0.002239277 0.003828722 0.01176717 
## 
## 
## X1, X0, Z1, Z0 all come directly from dataprep object.
## 
## 
## **************** 
##  searching for synthetic control unit  
##  
## 
## **************** 
## **************** 
## **************** 
## 
## MSPE (LOSS V): 5708.693 
## 
## solution.v:
##  0.01213575 0.0273077 0.9032257 0.001480612 0.0003777313 0.05486454 0.0006079395 
## 
## solution.w:
##  0.0002469333 0.1126815 0.0006024132 0.0004261608 6.63722e-05 0.0007766454 0.000518369 0.0005303056 0.0001910632 0.0001046866 0.000176826 4.04e-07 0.2980636 0.0001657699 0.0004493442 0.0009223368 0.0006608831 0.0005718035 0.0001803706 0.0001627832 0.0001954989 0.0007030358 0.000143043 0.001138853 0.0002962948 0.0003448714 0.0005713216 0.0008994664 0.0005708492 0.05652233 0.0002150308 0.0008436161 9.27858e-05 0.0002269455 0.0006624335 0.0001689833 0.0004741448 0.0008084815 0.0002272262 0.001007801 0.0002175093 0.0008598222 0.000403802 0.06755304 0.4449714 0.0002309291 0.0007639389 0.0008612121 0.0005267991

TASK 3: Aggregate and Average Treatment Effects Per Post-Treatment Year

# Extract treated and synthetic control outcomes directly
treated_actual <- dataprep_out$Y1plot
synthetic <- dataprep_out$Y0plot %*% synth_out$solution.w
years <- as.numeric(rownames(treated_actual))

# Treatment year
treat_year <- 1993
post_idx <- which(years >= treat_year)
post_years <- years[post_idx]

# Calculate treatment effects (gap)
gap <- as.numeric(treated_actual[post_idx]) - as.numeric(synthetic[post_idx])

# Calculate cumulative and average effects
cumulative_effect <- cumsum(gap)
average_effect <- cumulative_effect / (1:length(gap))

# Results table
te_results <- data.frame(
  year = post_years,
  treated_actual = as.numeric(treated_actual[post_idx]),
  synthetic = as.numeric(synthetic[post_idx]),
  gap = gap,
  years_since_treatment = 1:length(gap),
  cumulative_effect = cumulative_effect,
  average_effect = average_effect
)

print(te_results)
##   year treated_actual synthetic       gap years_since_treatment
## 1 1993          29260  27123.09  2136.915                     1
## 2 1994          40451  28470.50 11980.500                     2
## 3 1995          55602  30320.90 25281.100                     3
## 4 1996          55810  31515.61 24294.387                     4
## 5 1997          58393  32971.49 25421.510                     5
## 6 1998          59709  34634.41 25074.590                     6
## 7 1999          60785  35082.65 25702.351                     7
## 8 2000          61861  35701.04 26159.956                     8
##   cumulative_effect average_effect
## 1          2136.915       2136.915
## 2         14117.415       7058.708
## 3         39398.515      13132.838
## 4         63692.902      15923.225
## 5         89114.412      17822.882
## 6        114189.003      19031.500
## 7        139891.354      19984.479
## 8        166051.311      20756.414
# Summary statistics
cat("\nTotal Aggregate Treatment Effect:", round(sum(gap, na.rm = TRUE), 2), "\n")
## 
## Total Aggregate Treatment Effect: 166051.3
cat("Overall Average Treatment Effect:", round(mean(gap, na.rm = TRUE), 2), "\n")
## Overall Average Treatment Effect: 20756.41

TASK 4: Placebo Plots (In Space and Time)

Placebo in Space

# Created custom placebo plot with corrected legend
df <- placebos$df
years <- df$year

# Texas gap
texas_gap <- df$Y1 - df$synthetic.Y1

# Control unit gaps
synth_cols <- grep("^synthetic\\.", names(df), value = TRUE)
donor_ids <- sub("^synthetic\\.", "", synth_cols)

gaps_mat <- sapply(donor_ids, function(id) {
  actual_col <- id
  synth_col <- paste0("synthetic.", id)
  if(!(actual_col %in% names(df)) || !(synth_col %in% names(df))) {
    return(rep(NA_real_, nrow(df)))
  }
  df[[actual_col]] - df[[synth_col]]
})

treat_year <- 1993

# Plot
ylim <- range(c(gaps_mat, texas_gap), na.rm = TRUE)
plot(years, texas_gap, type = "n", ylim = ylim,
     xlab = "", ylab = "Gap in Black Male Incarceration",
     main = "")
abline(v = treat_year, lty = 2)
abline(h = 0, lty = 2, col = "gray")

# Plot control units in black
for(j in seq_len(ncol(gaps_mat))) {
  g <- gaps_mat[, j]
  ok <- !is.na(g)
  if(any(ok)) lines(years[ok], g[ok], col = "gray70", lwd = 1)
}

# Plot Texas in gray
ok_t <- !is.na(texas_gap)
lines(years[ok_t], texas_gap[ok_t], col = "black", lwd = 2)

# Legend with corrected labels
legend("topleft", 
       legend = c("Control units", "Texas"),
       col = c("gray70", "black"),
       lty = 1,
       lwd = c(1, 2),
       bty = "n")

mspe.plot(placebos, discard.extreme = TRUE, mspe.limit = 1, plot.hist = TRUE)

Placebo in Time

# Test different treatment years (placebo in time)
# Original treatment year is 1993
# Test earlier years: 1989-1992 (skip 1988 due to insufficient pre-treatment periods)

placebo_years <- 1989:1992
placebo_effects <- list()

for(placebo_year in placebo_years) {
  # Get valid bmprison years (must be before placebo treatment year)
  bmprison_years <- c(1988, 1990:1992)
  valid_bmprison <- bmprison_years[bmprison_years < placebo_year]
  
  # Skip if no valid bmprison years
  if(length(valid_bmprison) == 0) {
    next
  }
  
  # Build special predictors list conditionally
  special_preds <- list(
    list("bmprison", valid_bmprison, "mean")
  )
  
  # Add other predictors only if they fall in pre-treatment period
  if(1990 < placebo_year) {
    special_preds <- c(special_preds, list(
      list("alcohol", 1990, "mean"),
      list("aidscapita", 1990:1991, "mean"),
      list("black", 1990:1992, "mean"),
      list("perc1519", 1990, "mean")
    ))
  }
  
  # Create new dataprep with placebo treatment year
  dataprep_placebo <- dataprep(
    foo = texas,
    predictors = c("poverty", "income"),
    predictors.op = "mean",
    time.predictors.prior = 1985:(placebo_year - 1),
    special.predictors = special_preds,
    dependent = "bmprison",
    unit.variable = "statefip",
    unit.names.variable = "state",
    time.variable = "year",
    treatment.identifier = 48,
    controls.identifier = c(1,2,4:6,8:13,15:42,44:47,49:51,53:56),
    time.optimize.ssr = 1985:(placebo_year - 1),
    time.plot = 1985:2000
  )
  
  # Run synth for this placebo
  synth_placebo <- synth(data.prep.obj = dataprep_placebo)
  
  # Store the gap
  treated <- dataprep_placebo$Y1plot
  synthetic <- dataprep_placebo$Y0plot %*% synth_placebo$solution.w
  gap <- as.numeric(treated) - as.numeric(synthetic)
  years <- as.numeric(rownames(treated))
  
  placebo_effects[[as.character(placebo_year)]] <- data.frame(
    year = years,
    gap = gap,
    placebo_treatment_year = placebo_year
  )
}
## 
## X1, X0, Z1, Z0 all come directly from dataprep object.
## 
## 
## **************** 
##  searching for synthetic control unit  
##  
## 
## **************** 
## **************** 
## **************** 
## 
## MSPE (LOSS V): 2872605 
## 
## solution.v:
##  1.1e-09 0.1032039 0.8967961 
## 
## solution.w:
##  0.0003020269 7.30264e-05 0.0001268522 0.0001807535 0.3790534 0.0001055924 8.5774e-05 0.0001013238 0.0001391393 0.0007024102 0.0004119703 8.89102e-05 0.000124574 0.0002830433 0.0001587111 0.0001138576 0.0001209962 0.0001602982 0.6123175 0.0001093742 0.000185628 9.16619e-05 0.000490481 9.84106e-05 5.324e-07 0.0001849916 0.0001220908 0.0001102667 0.000103178 8.38365e-05 0.000157542 0.0001270082 0.0004789074 0.0003331506 0.0001178138 0.0003821035 0.0001629406 0.0001135854 0.0002734167 9.91866e-05 0.000329936 0.0001201053 0.0001632764 0.0001250688 0.0001063513 0.0001984103 0.0001076537 0.0001345633 0.0001309503 0.0001073797 
## 
## 
## X1, X0, Z1, Z0 all come directly from dataprep object.
## 
## 
## **************** 
##  searching for synthetic control unit  
##  
## 
## **************** 
## **************** 
## **************** 
## 
## MSPE (LOSS V): 2360803 
## 
## solution.v:
##  8.1e-09 0.09598841 0.9040116 
## 
## solution.w:
##  0.0001442665 3.73133e-05 6.33434e-05 8.75983e-05 0.3777635 5.25977e-05 4.25214e-05 5.00623e-05 6.88737e-05 0.000333183 0.0002006769 4.3689e-05 6.04312e-05 0.0001412235 7.80477e-05 5.62621e-05 6.06614e-05 7.80336e-05 0.6180113 5.34169e-05 9.31787e-05 4.57588e-05 0.0002426742 4.89041e-05 2.617e-07 9.23171e-05 5.96331e-05 5.46986e-05 5.13016e-05 4.17391e-05 7.84544e-05 6.24282e-05 0.0002288425 0.0001615252 5.82712e-05 0.0001887807 8.07578e-05 5.59083e-05 0.000134356 4.86309e-05 0.0001570722 5.88878e-05 7.99773e-05 6.15364e-05 5.18918e-05 9.88432e-05 5.33176e-05 6.51808e-05 6.48112e-05 5.30353e-05 
## 
## 
## X1, X0, Z1, Z0 all come directly from dataprep object.
## 
## 
## **************** 
##  searching for synthetic control unit  
##  
## 
## **************** 
## **************** 
## **************** 
## 
## MSPE (LOSS V): 2778585 
## 
## solution.v:
##  0.1863889 0.02472158 0.5474339 0.1051722 0.1362792 4.2363e-06 1.197e-07 
## 
## solution.w:
##  7.1847e-06 1.85269e-05 4.50355e-05 0.0001546951 0.5532344 3.42312e-05 2.33456e-05 2.77648e-05 1.20017e-05 0.0001990043 0.0002560846 2.45264e-05 7.59745e-05 7.76124e-05 8.57268e-05 5.39378e-05 5.82526e-05 0.0001222703 0.03819854 4.90966e-05 4.96464e-05 2.50767e-05 0.000425642 3.16871e-05 0.3010235 7.60216e-05 5.68772e-05 4.65283e-05 2.03305e-05 2.11033e-05 3.82106e-05 4.94361e-05 5.74185e-05 0.0007026559 6.27036e-05 0.101071 0.0001023217 4.38371e-05 0.0001284338 3.34663e-05 1.3075e-06 6.43228e-05 8.16821e-05 0.002667551 4.18994e-05 7.15154e-05 3.64509e-05 0.0001210083 4.62349e-05 4.38572e-05 
## 
## 
## X1, X0, Z1, Z0 all come directly from dataprep object.
## 
## 
## **************** 
##  searching for synthetic control unit  
##  
## 
## **************** 
## **************** 
## **************** 
## 
## MSPE (LOSS V): 1025604 
## 
## solution.v:
##  0.07043932 0.02364166 0.9030326 3.78e-08 1.8e-08 0.002886367 4e-10 
## 
## solution.w:
##  0.0001363707 1.74026e-05 5.51607e-05 0.0001415291 0.3383653 3.12593e-05 2.01786e-05 2.18602e-05 1.40257e-05 0.2271647 8.92205e-05 2.03744e-05 0.0001041134 7.98355e-05 7.06187e-05 4.71781e-05 4.06152e-05 0.0001198055 0.4313281 4.65913e-05 3.94531e-05 2.29686e-05 0.0002365103 2.85919e-05 1.362e-07 7.06737e-05 8.82549e-05 3.9214e-05 2.68755e-05 2.16909e-05 4.02799e-05 7.50564e-05 6.73449e-05 0.0001082392 8.16446e-05 0.0002634546 9.01666e-05 4.28097e-05 9.84649e-05 2.7463e-05 4.093e-07 7.62249e-05 6.41189e-05 0.000106215 4.14876e-05 4.99436e-05 3.19997e-05 0.0001545644 5.01025e-05 4.13789e-05
# Plot placebo in time
plot(NULL, xlim = c(1985, 2000), ylim = c(-10000, 30000),
     xlab = "Year", ylab = "Gap in Black Male Incarceration",
     main = "Placebo Tests in Time")
abline(h = 0, lty = 2, col = "gray")

# Plot each placebo
colors <- rainbow(length(placebo_years))
for(i in seq_along(placebo_years)) {
  py <- placebo_years[i]
  if(!as.character(py) %in% names(placebo_effects)) next
  df <- placebo_effects[[as.character(py)]]
  lines(df$year, df$gap, col = colors[i], lty = 2)
  abline(v = py, col = colors[i], lty = 3, lwd = 0.5)
}

# Plot actual treatment (1993)
treated_actual <- dataprep_out$Y1plot
synthetic_actual <- dataprep_out$Y0plot %*% synth_out$solution.w
gap_actual <- as.numeric(treated_actual) - as.numeric(synthetic_actual)
years_actual <- as.numeric(rownames(treated_actual))
lines(years_actual, gap_actual, col = "black", lwd = 3)
abline(v = 1993, col = "black", lty = 1, lwd = 2)

legend("topleft",
       legend = c("Actual (1993)", paste0("Placebo (", placebo_years, ")")),
       col = c("black", colors),
       lty = c(1, rep(2, length(placebo_years))),
       lwd = c(3, rep(1, length(placebo_years))),
       bty = "n",
       cex = 0.8)

TASK 5: Recreate Figures 10.11 and 10.12

Figure 10.11: MSPE Ratio Histogram with Texas Label

mspe.plot(placebos, discard.extreme = TRUE, mspe.limit = 1, plot.hist = TRUE)

Figure 10.12: Placebo Gaps with Worst-Fitting Annotated

df <- placebos$df
years <- df$year

treated_actual <- "Y1"
treated_synth  <- "synthetic.Y1"

synth_cols <- grep("^synthetic\\.", names(df), value = TRUE)
donor_ids  <- sub("^synthetic\\.", "", synth_cols)

gaps_mat <- sapply(donor_ids, function(id) {
  actual_col <- id
  synth_col  <- paste0("synthetic.", id)
  if(!(actual_col %in% names(df)) || !(synth_col %in% names(df))) {
    return(rep(NA_real_, nrow(df)))
  }
  df[[actual_col]] - df[[synth_col]]
})
colnames(gaps_mat) <- donor_ids

treated_gap <- df[[treated_actual]] - df[[treated_synth]]

treat_year <- dataprep_out$tag$treatment.period
if(is.null(treat_year)) {
  warning("dataprep_out$tag$treatment.period missing; assuming 1994 if present, else median(years).")
  treat_year <- ifelse(1994 %in% years, 1994, median(years, na.rm = TRUE))
}
pre_idx  <- which(years < treat_year)
post_idx <- which(years >= treat_year)

rmspe_fun <- function(vec, idx) {
  v <- vec[idx]
  v <- v[!is.na(v)]
  if(length(v) == 0) return(NA_real_)
  sqrt(mean(v^2))
}

rmspe_pre  <- apply(gaps_mat, 2, function(g) rmspe_fun(g, pre_idx))
rmspe_post <- apply(gaps_mat, 2, function(g) rmspe_fun(g, post_idx))

eps <- .Machine$double.eps
rmspe_ratio <- rmspe_post / (rmspe_pre + eps)

valid <- which(is.finite(rmspe_ratio) & !is.na(rmspe_ratio))
if(length(valid) == 0) stop("No valid donors with finite RMSPE ratio found.")

worst_idx <- valid[which.max(rmspe_ratio[valid])]
worst_unit <- names(rmspe_ratio)[worst_idx]

cat("Worst-by-ratio donor:", worst_unit, "ratio =", round(rmspe_ratio[worst_idx], 4), "\n")
## Worst-by-ratio donor: 13 ratio = 19.9114
ylim <- range(c(gaps_mat, treated_gap), na.rm = TRUE)
plot(years, treated_gap, type = "n", ylim = ylim,
     xlab = "Year", ylab = "Gap (Actual - Synthetic)",
     main = "Placebo gaps - thin donors; bold: treated (black) & worst (red)")
abline(v = treat_year, lty = 2)
abline(h = 0, lty = 2)

for(j in seq_len(ncol(gaps_mat))) {
  g <- gaps_mat[, j]
  ok <- !is.na(g)
  if(any(ok)) lines(years[ok], g[ok], col = "gray80", lwd = 1)
}

ok_t <- !is.na(treated_gap)
lines(years[ok_t], treated_gap[ok_t], col = "black", lwd = 3)

g_w <- gaps_mat[, worst_idx]
ok_w <- !is.na(g_w)
lines(years[ok_w], g_w[ok_w], col = "red", lwd = 3)

nudge_x <- max(years) - 0.2
if(any(ok_t)) text(nudge_x, tail(treated_gap[ok_t],1), 
                    labels = "Texas (treated)", col = "black", adj = c(0.8,2))
if(any(ok_w)) text(nudge_x, tail(g_w[ok_w],1), 
                    labels = paste0("Worst-fitting: Georgia"),
                    col = "red", adj = c(1,-2))

TASK 6: Summary Paragraph

[Write your summary paragraph here discussing the results]