*! version 1.0 06jan2020

Title

multicoefplot -- Advanced repeated cross-section graphical analysis

Syntax

multicoefplot
[if] [in]
[, options]

Namelist is the constant part of the outcome variable's name. E.g. for vars gdp1999, gdp2000, gdp2001, the namelist must be "gdp".
Multicoefplot runs a reghdfe by default, however, it runs with ivreghdfe if its syntax is used in the namelist: (varlist2_instrumented=varlist_iv).
If the instrumented variable or the instruments are time varying then they must be specified in the varying() option: (varlist_instrumented=varlist_iv, varying(varlist_varying))
and only the constant part of their variables name must be included, as for the outcome variable.

options

Required options
window(string) range of period of analysis, see forvalues for range type. E.g. 1999 to 2010 "1999/2010"

WARNING: timevarying variables included in the analysis should exist for all values of the window

treatment1(string) treatment variable to be plotted, if the varying(varlist) option is included, varlist variables in treatment are treated as time-varying and follow the window: e.g. treatment1(varname, varying(varname)). Interactions are not allowed.

Treatment1 MUST be specified

Other options
command shows the implied regression command; recommended for first-time users

noconstant no constant included in all specifications

level(#) set confidence level; default is level(95)

first when included, ivreghdfe includes first stage estimation

Specifications comparison options
The following options can be used to compare up to 3 models, by adding the model number at the end, e.g.: treatment1() treatment2() treatment3().

If the number is not specified, the option is used for model 1 (e.g. controls()=controls1()). Depending on the syntax models can use reghdfe or ivreghdfe.

treatment#(string) treatment variable to be plotted. If any option for models 2/3 is specified and treatment 2/3 is not, treatment 2/3 is set equal to treatment1. (see opt treatment1 for time-varying treatments)

absorb#(string) fixed effects to be included in the regression (controls should always be included in the controls opt)

controls#(varlist) control variables to be included in the regression

timeabsorb#(varlist) time varying fixed effect to be included in the regression (include only constant part of the name). Interactions are not allowed.

timecontrols#(varlist) time varying control variables to be included in the regression (include only constant part of the name). Interactions are not allowed.

cluster#(varname) clustered standard errors

vce#(robust) robust standard errors

aweight#(varname) include aweights

fweight#(varname) include fweights

Robustness tests options - CAN BE COMPUTATIONALLY INTENSIVE

Multicoefplot can potentially compare thousands of specifications, with an easy to read graphical output. If the number of specifications/estimates exceeds the limit, consider reducing it by grouping or creating random subsamples.

The tests options refer to the options for specification 1.

display regressions are not run quietly, for tests, when this option is included

fstat(globalsnames) plots the Kleibergen-Paap rk Wald statistic instead of coefficients for the included specifications

multitest(globalsnames) plots the regressions including separately the set of controls included in the list. Elements of the list must be names of globals previously saved

tuplestest(varlist) plots the regressions including separately all the possible tuples of the variables in varlist

leaveoneouttest(varlist) plots the regressions excluding one of the controls from the list at the time

perturbationtest(varname) plots the regressions dropping from the sample each time a different "levelsof" varname and generates a diagnostics table on the stability of the sample

Graph options
Multicoefplot specific options

time(string) automatic labelling for the x-axis, can be year, month, week, day. More detailed labels have to be entered through xlabel()

speccolor#(color) changes color for specification#

symbols when included, the specifications use different symbols (black and white friendly)

symbol# changes symbol for the # spec, can be used together with symbols

testcicolor(color) color of the confidence intervals for the tests

testcoefcolor(color) color of the coefficients in the tests

{synopt :General graph options

Note that x-axis options are based on the matrix position (that is 1,..,number of estimates), not the label value

offset(filename) set offset between specifications in the basic comparison

legend(filename) controls legend. Default is: legend(1 "Specification 1" 2 "Specification 2" 3 "Specification 3"). Input "off" to turn off default lines

title(string) controls axis titles, standard options apply

label(string) controls axis labels, standard options apply e.g. label(1 "1" 2 "2" 3 "3" 4 "4" 5 "5")

line(string) adds xlines or ylines, standard suboptions apply. Input "off" to turn off default lines

size(string) regulates length and height of the graph

Save Output
savegraph(file) saves all the tables, file has to be of format path/filename.csv

savetex(file) saves a table in .tex format; not allowed for tests; file has to be of format path/filename

Examples of main features

I recommend users to look at these examples directly from the package example .do file

Load and prepare data

webuse nlswork, clear

* For the time being multicoefplot works only on "regular" periods, irregular periods can be saved as regular in a new var, then used e.g. 1=68 2=69 3=71.. etc.

keep if inlist(year, 69,71,73,75,77)

reshape wide birth_yr age race msp nev_mar grade collgrad not_smsa c_city south ind_code occ_code union wks_ue ttl_exp tenure hours wks_work ln_wage, i(idcode) j(year)

gen c_race=race69

gen c_birth_yr=birth_yr69

gen c_collgrad=collgrad69

gen c_south=south69

drop race* birth_yr* collgrad* south*

* Examples of specifications comparison

* Command is a first-time-users friendly option to show in the console a draft of the regression(s) being run. Varying(tenure) tells multicoefplot the treatment is timevarying.

multicoefplot ln_wage, window(69(2)77) command noconstant legend(off) treatment(tenure, varying(tenure)) controls(c_race c_birth_yr c_collgrad c_south) timecontrols(age ttl_exp not_smsa)

* Comparing first spec to a second one adding time-varying FE's

multicoefplot ln_wage, window(69(2)77) command noconstant treatment1(tenure, varying(tenure)) controls1(c_race c_birth_yr c_collgrad c_south) timecontrols1(age ttl_exp not_smsa) treatment2(tenure, varying(tenure)) controls2(c_race c_birth_yr c_collgrad c_south) timecontrols2(age ttl_exp not_smsa) timeabsorb2(occ_code)

* Comparing first and second specs to a third one adding time-varying FE's and using robust S.E.. Symbols is a black and white friendly option.

multicoefplot ln_wage, window(69(2)77) command noconstant symbols treatment1(tenure, varying(tenure)) controls1(c_race c_birth_yr c_collgrad c_south) timecontrols1(age ttl_exp not_smsa) treatment2(tenure, varying(tenure)) controls2(c_race c_birth_yr c_collgrad c_south) timecontrols2(age ttl_exp not_smsa) timeabsorb2(occ_code) treatment3(tenure, varying(tenure)) controls3(c_race c_birth_yr c_collgrad c_south) timecontrols3(age ttl_exp not_smsa) timeabsorb3(occ_code) vce3(robust) legend(1 "Baseline" 2 "Occupation FE's" 3 "Occupation FE's + Robust S.E.") xlabel(1 "1969" 2 "1971" 3 "1973" 4 "1975" 5 "1977")

* Tests

* Tuplestest runs all the tuples of the included controls, separately. They have to be constant, for the time being

multicoefplot ln_wage, window(69(2)77) command noconstant legend(off) treatment(tenure, varying(tenure)) timecontrols(age ttl_exp not_smsa) tuplestest(c_race c_birth_yr c_collgrad c_south)

* Leaveoneouttest leaves out one of the controls at the time

multicoefplot ln_wage, window(69(2)77) command noconstant legend(off) treatment(tenure, varying(tenure)) timecontrols(age ttl_exp not_smsa) leaveoneouttest(c_race c_birth_yr c_collgrad c_south)

* Multitest includes one set of controls at the time

global cov1 "c_race c_south"

global cov2 "c_birth_yr c_collgrad"

multicoefplot ln_wage, window(69(2)77) command noconstant legend(off) treatment(tenure, varying(tenure)) timecontrols(age ttl_exp not_smsa) multitest(cov1 cov2)

* Perturbationtest excludes one sub-sample at the time, based on the levelsof() of the variable. Tests look can be adjusted

multicoefplot ln_wage, window(69(2)77) command noconstant legend(off) treatment(tenure, varying(tenure)) controls(c_race c_birth_yr c_collgrad c_south) timecontrols(age ttl_exp not_smsa) perturbationtest(c_birth_yr) testcicolor(navy) testcoefcolor(black)

* Instrumental variable - Variables can be instrumented, and reduced forms and second stages can be put together in the same graph

* Looking at the Diagnostics Table of the Perturbationtest, we see that the minimum sample drop required to change the significance of estimates is roughly 8% of the sample

multicoefplot ln_wage, window(69(2)77) command noconstant symbols treatment1(tenure=age, varying(tenure age)) controls1(c_race c_birth_yr c_collgrad c_south) timecontrols1(ttl_exp not_smsa) treatment2(tenure=age, varying(tenure age)) controls2(c_race c_birth_yr c_collgrad c_south) timecontrols2(ttl_exp not_smsa) timeabsorb2(occ_code) treatment3(tenure=age, varying(tenure age)) controls3(c_race c_birth_yr c_collgrad c_south) timecontrols3(ttl_exp not_smsa) timeabsorb3(occ_code) vce3(robust) legend(1 "Baseline" 2 "Occupation FE's" 3 "Occupation FE's + Robust S.E.") xlabel(1 "1969" 2 "1971" 3 "1973" 4 "1975" 5 "1977")

Description

multicoefplot runs regressions and generates graphs for repeated cross-section analysis, with extensive options for multiple specifications comparison, and specification and sample robustness-checks.

Repeated cross-sections are a useful tool of analysis of panel data. In such context, researchers are often in need of comparing specifications varying the choice of controls, fixed effects or cluster standard errors, or in the framework of instrumental variables, to compare Two Stages Least Squares estimates to OLS or Reduce Forms. Multicoefplot offers an easy way to compare up to three specifications, furthermore: the multitest option allows to compare any number of groups of controls by including one group at the time; the leaveoneouttest option allows to check for estimates robustness by leaving out one control at the time; the tuplestest option checks that results are robust to including any tuples of a set of controls and finally the perturbationtest option checks that results are not driven by specific sub-samples, by singularly dropping all different values of the indicated variable. The perturbationtest includes a Diagnostics Table of the heterogeneity of results across subsamples, e.g. the Minimum Perturbation: the minimum sample drop that changes at least one estimate's significance/sign.

Author

Matteo Pinna (matteo.pinna@gess.ethz.ch)