~~~~~~~~~~~~~~~~~~~~~~~~~ PROGRAM: locmtest.ado ~~~~~~~~~~~~~~~~~~~~~~~~~ Written by Javier Cano Urbina August 31, 2009 Updated: May 31, 2012. --> It produces saved results and saved matrices just like any other Stata command. Performs Wald-Test Statistic developed in Lochner & Moretti (2008,2011) and some additional test including: + The Hausman Test for Endogeneity as in Davidson and Makkinnon (1993) and Wooldridge (2002) + The Hausman Test for Specification + A Wald Statistic: [(b_iv - b_ols)/SD(b_iv - b_ols)]^2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ I. INSTALLING THE PROGRAM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ There are two options: (1) Save the ado file in the folder "C:\ado\personal" (recommended) (2) Save the ado file in the folder of preference, e.g. "C:\Documents and Settings\My Documents\MyFolder" The first option is recommended since the file must be loaded only one time and then used in future Stata sessions (see Section II for loading instructions). Make sure you save the file as an ado-file: "locmtest.ado" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ II. LOADING THE PROGRAM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Before running the test for the first time, you must run it to load it. If you used option (1) in Section I: (1) Open the ado file in the directory "C:\ado\personal" using the Do-file Editor in STATA (2) Just click on the "Do" button in the menu. Alternatively you can type in the command window: do "C:\ado\personal\locmtest.ado." Any of these two procedures will load the test. The program is then saved in Stata's memory, so in the next Stata session you will be able to use the program without doing this procedure again. If you used option (2) in Section II: (1) Open the ado file in the directory "C:\Documents and Settings\My Documents\MyFolder" using the Do-file Editor in STATA (2) Just click on the "Do" button in the menu. Alternatively you can type in the command window: do "C:\Documents and Settings\My Documents\MyFolder\locmtest.ado." Any of these two procedures will load the test. If you do this, the program is saved in Stata's memory only for current Stata session. Next time you open Stata and want to use the program again, you will have to follow the same instructions before running the program. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ III. MAKING CHANGES TO THE PROGRAM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ If any change is made in the program, it must be loaded again so that the changes take effect. Then, when making changes to the program follow these steps: 1) Do whatever changes you prefer. 2) Save the changes. 3) Load the program following any of the instructions in Section II. ~~~~~~~~~~~~~~ IV. SYNTAX ~~~~~~~~~~~~~~ The syntax is specified in the top of the program, but it is repeated here for convenience. SYNTAX: locmtest y s "x" "z" where x is x_1 x_2 ... x_k z is z_1 z_2 ... z_l NOTE 1: The program assumes that the potentially endogenous variable "s" is already in discrete format. If it is not the case, the user must change it to a discrete variable before running the program. NOTE 2: If x and/or z are composed by more than one variable (apart from the constant) it is important to type the " " when calling the program NOTE 3: If x is composed of one variable only (apart from the constant), x = x_1, then Sintax locmtest y s "x" "z" is equivalent to syntax locmtest y s x "z" NOTE 4: If z is composed of one variable only, z = z_1, then Sintax locmtest y s "x" "z" is equivalent to syntax locmtest y s "x" z NOTE 5: If there is no other covariates apart from the constant, then the syntax should be: locmtest y s " " z so that the only covariate is the constant ~~~~~~~~~~~~~~~~~~~~ V. SAVED RESULTS ~~~~~~~~~~~~~~~~~~~~ (1) Scalars: e(BLols) OLS of Linear Equation e(SDBLols) Standard Error of OLS of Linear Equation e(BLiv) 2SLS of Linear Equation e(SDBLiv) Standard Error of 2SLS of Linear Equation e(DIVOLS) Difference: BLiv - BLols e(SDDIVOLS) Standard Error of Difference: BLiv - BLols e(WBols) Re-weighted OLS e(SDWBols) Standard Error of Re-weighted OLS e(T) Difference: BLiv - WBols e(SDT) Standard Error of Difference: BLiv - WBols e(wm) Lochner-Moretti Wald Test Statistic e(pwm) p-value of Lochner-Moretti Wald Test Statistic e(pebyw) Percent Explained by Weights (2) Matrices: e(B) OLS on Dummies in Non-linear Equation e(W) 2SLS Weights e(THETA) Vector of Estimates in System GMM e(VarTHETA) Variance Matrix of Estimates in System GMM