-------------------------------------------------------------------------------------------- name: log: c:\Users\ccameron\Dropbox\Desktop\TEACHING\190\Causal Methods Slides\synth.txt log type: text opened on: 28 Nov 2023, 17:11:23 . . ********** OVERVIEW OF synth.do ********** . . * Example of synthetic control . . * Program by A. Colin Cameron Dept. of Economics Univ. of California - Davis . * Used for ECN 190 Research with Economics Data . . * To run you need file . * mus225smoking.dta . * in your directory . . * You also need the user-written command . * synth . * synth_runner (includes effects_graphs and single_treatment_graphs) . . * The dataset is used in A. Colin Cameron and Pravin K. Trivedi (2022) . * Microeconometrics using Stata, Voulme 2, chapter 25.6.2 . . * The source is Galiani and Quistorff (2017), "The synthrunnerpackage: . * Utilities to automate synthetic control stimation using synth," . * Stata Journal, 834-849. . * based in turn on Abadie, Diamond and Hainmuller (2010), . * "Synthetic control methods for comparative case studies: Estimating the . * effect of California's tobacco control program," JASA, 493-505. . . ********** SETUP ********** . . clear all . set scheme s1mono /* Graphics scheme */ . . ************ SYNTHETIC CONTROL . . use mus225smoking.dta (A.C.Cameron & P.K.Trivedi (2022): Microeconometrics Using Stata, 2e) . * Synthetic control: Smoking dataset and summary . qui use mus225smoking, clear . describe Contains data from mus225smoking.dta Observations: 1,209 A.C.Cameron & P.K.Trivedi (2022): Microeconometrics Using Stata, 2e Variables: 7 1 Sep 2020 16:38 -------------------------------------------------------------------------------------------- Variable Storage Display Value name type format label Variable label -------------------------------------------------------------------------------------------- state long %14.0g state State no year float %9.0g Year cigsale float %9.0g Cigarette sale per capita (in packs) lnincome float %9.0g Log state per capita GDP beer float %9.0g Beer consumption per capita age15to24 float %9.0g Percent of state population aged 15–24 years retprice float %9.0g Retail price of cigarettes -------------------------------------------------------------------------------------------- Sorted by: year . summarize, sep(7) Variable | Obs Mean Std. dev. Min Max -------------+--------------------------------------------------------- state | 1,209 20 11.25929 1 39 year | 1,209 1985 8.947973 1970 2000 cigsale | 1,209 118.8932 32.7674 40.7 296.2 lnincome | 1,014 9.861634 .1706769 9.397449 10.48662 beer | 546 23.4304 4.22319 2.5 40.4 age15to24 | 819 .175472 .0151589 .1294482 .2036753 retprice | 1,209 108.3419 64.38199 27.3 351.2 . . * Synthetic control: synth command . tsset state year Panel variable: state (strongly balanced) Time variable: year, 1970 to 2000 Delta: 1 unit . synth cigsale beer(1984(1)1988) lnincome(1972(1)1988) retprice /// > age15to24 cigsale(1988) cigsale(1980) cigsale(1975), /// > trunit(3) trperiod(1989) figure -------------------------------------------------------------------------------------------- Synthetic Control Method for Comparative Case Studies -------------------------------------------------------------------------------------------- First Step: Data Setup -------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------- Data Setup successful -------------------------------------------------------------------------------------------- Treated Unit: California Control Units: Alabama, Arkansas, Colorado, Connecticut, Delaware, Georgia, Idaho, Illinois, Indiana, Iowa, Kansas, Kentucky, Louisiana, Maine, Minnesota, Mississippi, Missouri, Montana, Nebraska, Nevada, New Hampshire, New Mexico, North Carolina, North Dakota, Ohio, Oklahoma, Pennsylvania, Rhode Island, South Carolina, South Dakota, Tennessee, Texas, Utah, Vermont, Virginia, West Virginia, Wisconsin, Wyoming -------------------------------------------------------------------------------------------- Dependent Variable: cigsale MSPE minimized for periods: 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 Results obtained for periods: 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 -------------------------------------------------------------------------------------------- Predictors: beer(1984(1)1988) lnincome(1972(1)1988) retprice age15to24 cigsale(1988) cigsale(1980) cigsale(1975) -------------------------------------------------------------------------------------------- Unless period is specified predictors are averaged over: 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 -------------------------------------------------------------------------------------------- Second Step: Run Optimization -------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------- Optimization done -------------------------------------------------------------------------------------------- Third Step: Obtain Results -------------------------------------------------------------------------------------------- Loss: Root Mean Squared Prediction Error --------------------- RMSPE | 1.943233 --------------------- -------------------------------------------------------------------------------------------- Unit Weights: ---------------------------- Co_No | Unit_Weight ---------------+------------ Alabama | 0 Arkansas | 0 Colorado | .285 Connecticut | .101 Delaware | 0 Georgia | 0 Idaho | 0 Illinois | 0 Indiana | 0 Iowa | 0 Kansas | 0 Kentucky | 0 Louisiana | 0 Maine | 0 Minnesota | 0 Mississippi | 0 Missouri | 0 Montana | 0 Nebraska | 0 Nevada | .245 New Hampshire | 0 New Mexico | 0 North Carolina | 0 North Dakota | 0 Ohio | 0 Oklahoma | 0 Pennsylvania | 0 Rhode Island | 0 South Carolina | 0 South Dakota | 0 Tennessee | 0 Texas | 0 Utah | .369 Vermont | 0 Virginia | 0 West Virginia | 0 Wisconsin | 0 Wyoming | 0 ---------------------------- -------------------------------------------------------------------------------------------- Predictor Balance: ------------------------------------------------------ | Treated Synthetic -------------------------------+---------------------- beer(1984(1)1988) | 24.28 23.22596 lnincome(1972(1)1988) | 10.03176 9.867266 retprice | 66.63684 65.40743 age15to24 | .1786624 .1825559 cigsale(1988) | 90.1 92.6063 cigsale(1980) | 120.2 120.3907 cigsale(1975) | 127.1 126.7094 ------------------------------------------------------ -------------------------------------------------------------------------------------------- . . * Synthetic control: synth_runner command . synth_runner cigsale beer(1984(1)1988) lnincome(1972(1)1988) retprice /// > age15to24 cigsale(1988) cigsale(1980) cigsale(1975), /// > trunit(3) trperiod(1989) gen_vars Estimating the treatment effects Estimating the possible placebo effects (one set for each of the 1 treatment periods) | | Total: 38 .....................................| 10.00s elapsed. Conducting inference: 5 steps, and 38 placebo averages Step 1... Finished Step 2... Finished Step 3... Finished Step 4... Finished Step 5... Finished Post-treatment results: Effects, p-values, standardized p-values | estimates pvals pvals_std -------------+-------------------------------- c1 | -7.887098 .1315789 0 c2 | -9.693599 .1842105 0 c3 | -13.8027 .2105263 0 c4 | -13.344 .1315789 0 c5 | -17.0624 .1052632 0 c6 | -20.8943 .0789474 0 c7 | -19.8568 .1315789 .0263158 c8 | -21.0405 .1578947 0 c9 | -21.4914 .1052632 .0263158 c10 | -19.1642 .1842105 .0263158 c11 | -24.554 .1052632 0 c12 | -24.2687 .1052632 .0263158 . . * Synthetic control: synth_runner postestimation command effect_graphs . effect_graphs, trlinediff(-1) tc_options(ti("Treated & control outcomes")) /// > effect_options(title("Difference between treated & control")) . . * Synthetic control: synth_runner postestimation command single_treatment_graphs . single_treatment_graphs, trlinediff(-1) effects_ylabels(-50(10)50) /// > do_color(gs11) effects_ymax(50) effects_ymin(-50) /// > raw_options(title("Treated & donor outcomes")) /// > effects_options(title("Difference between treated & donor outcomes")) (6 real changes made) (0 real changes made) . . * Kentucky (state 13) for example had poor pretreatment fit . capture drop lead effect cigsale_* effect pre_rmspe post_rmspe . synth_runner cigsale beer(1984(1)1988) lnincome(1972(1)1988) retprice /// > age15to24 cigsale(1988) cigsale(1980) cigsale(1975), /// > trunit(13) trperiod(1989) gen_vars Estimating the treatment effects Estimating the possible placebo effects (one set for each of the 1 treatment periods) | | Total: 38 .....................................| 10.00s elapsed. Conducting inference: 5 steps, and 38 placebo averages Step 1... Finished Step 2... Finished Step 3... Finished Step 4... Finished Step 5... Finished Post-treatment results: Effects, p-values, standardized p-values | estimates pvals pvals_std -------------+-------------------------------- c1 | 13.95121 .0789474 .7368421 c2 | 40.1468 0 .2631579 c3 | 32.93509 0 .5526316 c4 | 32.46151 0 .5789474 c5 | 28.42731 .0526316 .5526316 c6 | 28.3148 .0789474 .5526316 c7 | 30.0179 .0789474 .6842105 c8 | 35.9687 .0526316 .7105263 c9 | 28.41041 .0789474 .8157895 c10 | 12.7882 .3947368 .9210526 c11 | 11.97311 .4210526 .9210526 c12 | 21.66969 .1578947 .7368421 . effect_graphs, trlinediff(-1) tc_options(ti("Treated & control outcomes")) /// > effect_options(title("Difference between treated & control")) . . end of do-file . exit, clear