-
Login or Register
- Log in with
lcol("#ed2939")
lcol("237 41 57")
* Example generated by -dataex-. For more info, type help dataex clear input double cf float(cigsale3 year) 122.09479671055374 123 1970 121.6065529858943 121 1971 123.65496555673786 123.5 1972 124.10483385256285 124.4 1973 126.75462121002437 126.7 1974 126.63825689453941 127.1 1975 127.92824675473713 128 1976 126.4873238266998 126.4 1977 125.37864959522437 126.1 1978 122.34822098598946 121.9 1979 119.928632673551 120.2 1980 119.10175992318514 118.6 1981 115.68795915144617 115.4 1982 111.04282414949492 110.8 1983 104.56636628133799 104.8 1984 102.7682761771388 102.8 1985 99.35677151118881 99.7 1986 97.39989301281054 97.5 1987 91.15104874688336 90.1 1988 88.66315821472102 82.4 1989 85.21665593484636 77.8 1990 80.76789213762831 68.7 1991 79.08976003988303 67.5 1992 79.33037122087953 63.4 1993 76.85184614706827 58.6 1994 74.46827712093958 56.4 1995 73.64585997258112 54.5 1996 73.61649595338298 53.8 1997 71.64467330066938 52.3 1998 70.90756101627477 47.2 1999 65.74723052634468 41.6 2000 end format %ty year cap set scheme gg_w3d if _rc { net install schemepack, /// from("https://raw.githubusercontent.com/asjadnaqvi/stata-schemepack/main/installation/") /// replace } lab var cf "Counterfactual Sales" lab var cig "Real Cigarette Sales" tsset year, y cls tsline cig, lcol("12 10 0") lwidth(thick) || /// Observed Sales tsline cf, lcol("237 41 57") lwidth(medthick) lpat(--),, /// Counterfactual scheme(gg_w3d) /// tline(1989, lcol(blue) lpat(solid) lwid(medthick)) /// legend(ring(0) pos(3)) /// tti(Year) /// yti(Cigarette Sales) /// plotregion(fcol(gs12))
legend(pos(coord(1990, 99.5)))
legend(pos(coord(1970, 45)))
frame change specifications des, varlist local varlist `r(varlist)' forvalues i = 1/`=_N' { foreach arg of local varlist { loc `arg' = `arg'[`i'] } frame default { regress price i.foreign `xvars', vce(`vcetype') frame post results ("`name'") (_b[1.foreign]) (_se[1.foreign]) } }
sysuse auto frame create specifications strL( name xvars vcetype ) frame post specifications ("weight only") ("weight") ("ols") frame post specifications ("weight and length, robust") ("weight length") ("robust") frame post specifications ("weight and mpg, bootstrap") ("weight mpg") ("bootstrap") frame create results strL( name b se ) foreach of frame specifications { regress price i.foreign `xvars', vce(`vcetype') frame post results ("`name'") (_b[1.foreign]) (_se[1.foreign]) }
* Prepare Specs and results frames frame create specifications str64( name xvars vcetype ) frame post specifications ("weight only") ("weight") ("ols") frame post specifications ("weight and length, robust") ("weight length") ("robust") frame post specifications ("weight and mpg, bootstrap") ("weight mpg") ("bootstrap") frame specifications: compress frame create results str64(name) double(b se) // Load data, and step through regressions, driven by the Specs mkf data cwf data sysuse auto frame specifications: local nspecs = _N forval i = 1/`nspecs' { cwf specifications local i_name = "`=name[`i']'" local i_xvars = "`=xvars[`i']'" local i_vce = "`=vcetype[`i']'" cwf data regress price i.foreign `i_xvars', vce(`i_vce') frame post results ("`i_name'") (_b[1.foreign]) (_se[1.foreign]) } cwf results list
sysuse auto frame create specifications strL( name xvars vcetype ) frame post specifications ("weight only") ("weight") ("ols") frame post specifications ("weight and length, robust") ("weight length") ("robust") frame post specifications ("weight and mpg, bootstrap") ("weight mpg") ("bootstrap") frame create results strL( name b se ) foreach of frame specifications { regress price i.foreign `xvars', vce(`vcetype') frame post results ("`name'") (_b[1.foreign]) (_se[1.foreign]) }
Leave a comment: