------------------------------------------------------------------------------- log: I:\Documents and Settings\Documents\Classes\6243\newbroiler.log log type: text opened on: 20 Feb 2008, 15:41:16 . do "H:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\STD02000000.tmp" . use http://www.principlesofeconometrics.com/stata/newbroiler.dta, clear . . gen lq = log(q) . gen lp = log(p) . gen lpf = log(pf) (12 missing values generated) . gen ly = log(y) . gen lqprod = log(qprod) (1 missing value generated) . gen lpb = log(pb) . tsset year time variable: year, 1950 to 2001 delta: 1 unit . . * Least squares . regress lqprod lp lpf year L.lqprod in 11/50 Source | SS df MS Number of obs = 40 -------------+------------------------------ F( 4, 35) = 3102.49 Model | 11.9815945 4 2.99539863 Prob > F = 0.0000 Residual | .03379186 35 .000965482 R-squared = 0.9972 -------------+------------------------------ Adj R-squared = 0.9969 Total | 12.0153864 39 .308086831 Root MSE = .03107 ------------------------------------------------------------------------------ lqprod | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- lp | .0091099 .0679409 0.13 0.894 -.1288175 .1470373 lpf | -.0901945 .0426459 -2.11 0.042 -.1767703 -.0036186 year | .0111706 .0051486 2.17 0.037 .0007183 .0216229 lqprod | L1. | .7326902 .1066347 6.87 0.000 .5162103 .94917 _cons | -19.66188 9.272384 -2.12 0.041 -38.48582 -.8379426 ------------------------------------------------------------------------------ . estimates store ls . . * First stage regression . regress lp ly lpb L.lp popgro lexpts year lpf L.lqprod in 11/50 Source | SS df MS Number of obs = 40 -------------+------------------------------ F( 8, 31) = 49.48 Model | 1.63555802 8 .204444752 Prob > F = 0.0000 Residual | .128092436 31 .004132014 R-squared = 0.9274 -------------+------------------------------ Adj R-squared = 0.9086 Total | 1.76365045 39 .045221807 Root MSE = .06428 ------------------------------------------------------------------------------ lp | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- ly | 1.23557 .6248227 1.98 0.057 -.0387646 2.509904 lpb | .0200865 .210586 0.10 0.925 -.4094064 .4495795 lp | L1. | .3422115 .1532881 2.23 0.033 .0295783 .6548446 popgro | .0611575 .0857773 0.71 0.481 -.1137864 .2361014 lexpts | 1.679846 .7400669 2.27 0.030 .1704694 3.189222 year | -.062288 .0223057 -2.79 0.009 -.1077807 -.0167953 lpf | .1484371 .1008214 1.47 0.151 -.0571895 .3540636 lqprod | L1. | .1608819 .2848705 0.56 0.576 -.4201154 .7418791 _cons | 109.8585 37.98806 2.89 0.007 32.38134 187.3357 ------------------------------------------------------------------------------ . predict yhat, xb (12 missing values generated) . test ly lpb L.lp popgro lexpts ( 1) ly = 0 ( 2) lpb = 0 ( 3) L.lp = 0 ( 4) popgro = 0 ( 5) lexpts = 0 F( 5, 31) = 3.92 Prob > F = 0.0072 This indicates that the instruments are weak since 3.92 is significantly less than 10. Consequently, the IV estimator will be badly biased towards the least squares estimator and the sampling distribution of the IV estimator is unlikely to be close to its asymptotic value. Inference in this model using these data will not be very reliable. . . * IV regression . ivregress 2sls lqprod (lp=ly lpb L.lp popgro lexpts) lpf year L.lqprod in 11/50 Instrumental variables (2SLS) regression Number of obs = 40 Wald chi2(4) = 9554.16 Prob > chi2 = 0.0000 R-squared = 0.9958 Root MSE = .03542 ------------------------------------------------------------------------------ lqprod | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- lp | .2891186 .1244103 2.32 0.020 .0452788 .5329584 lpf | -.1635291 .0548981 -2.98 0.003 -.2711273 -.0559308 year | .0206785 .0067365 3.07 0.002 .0074752 .0338818 lqprod | L1. | .5989759 .1301526 4.60 0.000 .3438815 .8540703 _cons | -37.32766 12.22573 -3.05 0.002 -61.28964 -13.36567 ------------------------------------------------------------------------------ Instrumented: lp Instruments: lpf year L.lqprod ly lpb L.lp popgro lexpts Store these estimates for the Hausman test. . estimates store iv Store the residuals for the regression based Hausman test. . . predict uhat, residuals (12 missing values generated) This duplicates the instrument strength test that I did manually above. It provides some additional information about the size of the bias (relative to LS) due to weak instruments. It is likely to be greater than 30%. . estat firststage First-stage regression summary statistics -------------------------------------------------------------------------- | Adjusted Partial Variable | R-sq. R-sq. R-sq. F(5,31) Prob > F -------------+------------------------------------------------------------ lp | 0.9274 0.9086 0.3876 3.92394 0.0072 -------------------------------------------------------------------------- Minimum eigenvalue statistic = 3.92385 Critical Values # of endogenous regressors: 1 Ho: Instruments are weak # of excluded instruments: 5 --------------------------------------------------------------------- | 5% 10% 20% 30% 2SLS relative bias | 18.37 10.83 6.77 5.25 -----------------------------------+--------------------------------- | 10% 15% 20% 25% 2SLS Size of nominal 5% Wald test | 26.87 15.09 10.98 8.84 LIML Size of nominal 5% Wald test | 4.84 3.56 3.05 2.77 --------------------------------------------------------------------- The Durbin-Wu Hausman test is the regression form of the general Hausman test. Here the null is that regressors are not correlated with errors (use LS). The alternative is that they are (conditional on your available instruments), in which case use IV. . * Durbin-Wu Hausman . regress lqprod lp lpf year L.lqprod yhat in 11/50 Source | SS df MS Number of obs = 40 -------------+------------------------------ F( 5, 34) = 3482.93 Model | 11.9919735 5 2.39839471 Prob > F = 0.0000 Residual | .023412872 34 .000688614 R-squared = 0.9981 -------------+------------------------------ Adj R-squared = 0.9978 Total | 12.0153864 39 .308086831 Root MSE = .02624 ------------------------------------------------------------------------------ lqprod | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- lp | -.1681058 .0733206 -2.29 0.028 -.3171112 -.0191004 lpf | -.1635291 .0406688 -4.02 0.000 -.246178 -.0808801 year | .0206785 .0049904 4.14 0.000 .0105367 .0308203 lqprod | L1. | .5989759 .0964178 6.21 0.000 .4030313 .7949204 yhat | .4572244 .1177714 3.88 0.000 .2178841 .6965646 _cons | -37.32765 9.05689 -4.12 0.000 -55.73347 -18.92184 ------------------------------------------------------------------------------ The coefficient on yhat is significant at the 5% level, indicating that the null of exogeneity is rejected. Use IV (but keep in mind it won't perform well due to the weak instruments). . * Sargan Test for overidentification. Notice this is the same result produced by Stata. Also, the degrees of freedom = # overidentifying restrictions. . regress uhat ly lpb L.lp popgro lexpts lpf year L.lqprod in 11/50 Source | SS df MS Number of obs = 40 -------------+------------------------------ F( 8, 31) = 0.39 Model | .004606815 8 .000575852 Prob > F = 0.9167 Residual | .045584314 31 .001470462 R-squared = 0.0918 -------------+------------------------------ Adj R-squared = -0.1426 Total | .050191129 39 .001286952 Root MSE = .03835 ------------------------------------------------------------------------------ uhat | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- ly | -.1015039 .3727372 -0.27 0.787 -.8617065 .6586987 lpb | .1151339 .1256248 0.92 0.366 -.1410796 .3713474 lp | L1. | -.1053738 .0914438 -1.15 0.258 -.2918748 .0811271 popgro | -.0292123 .0511703 -0.57 0.572 -.1335749 .0751503 lexpts | .5211087 .441486 1.18 0.247 -.379308 1.421525 lpf | -.0202867 .0601449 -0.34 0.738 -.142953 .1023796 year | .0031041 .0133064 0.23 0.817 -.0240345 .0302428 lqprod | L1. | -.1809304 .1699392 -1.06 0.295 -.5275236 .1656628 _cons | -3.528442 22.66173 -0.16 0.877 -49.74735 42.69047 ------------------------------------------------------------------------------ . scalar nr2 = e(N)*e(r2) . scalar chic = invchi2tail(4,.05) . scalar pvalue = chi2tail(4,nr2) . di "NR^2 test of overidentifying restriction = " nr2 NR^2 test of overidentifying restriction = 3.6714177 . di "Chi-square critical value 4 df, .05 level = " chic Chi-square critical value 4 df, .05 level = 9.487729 . di "p value for overidentifying test 4 df, .05 level = " pvalue p value for overidentifying test 4 df, .05 level = .4522967 Overidentification test via the canned software. . estat overid Tests of overidentifying restrictions: Sargan (score) chi2(4) = 3.67142 (p = 0.4523) Basmann chi2(4) = 3.1329 (p = 0.5358) . This is the "vector of contrasts" variant of the Hausman test. This is the classic version that has been generalized to work in other situations. Be careful to count the correct degrees of freedom and watch for singularity of the difference in covariance matrices. . * Hausman Test . * Notes: use constant option . * Notes: sigmamore uses variance estimate from LS in both covarainces . hausman iv ls, constant sigmamore Note: the rank of the differenced variance matrix (1) does not equal the number of coefficients being tested (5); be sure this is what you expect, or there may be problems computing the test. Examine the output of your estimators for anything unexpected and possibly consider scaling your variables so that the coefficients are on a similar scale. ---- Coefficients ---- | (b) (B) (b-B) sqrt(diag(V_b-V_B)) | iv ls Difference S.E. -------------+---------------------------------------------------------------- lp | .2891186 .0091099 .2800087 .0854016 lpf | -.1635291 -.0901945 -.0733346 .0223668 year | .0206785 .0111706 .0095078 .0028999 L.lqprod | .5989759 .7326902 -.1337143 .0407824 _cons | -37.32766 -19.66188 -17.66577 5.387994 ------------------------------------------------------------------------------ b = consistent under Ho and Ha; obtained from ivregress B = inconsistent under Ha, efficient under Ho; obtained from regress Test: Ho: difference in coefficients not systematic chi2(1) = (b-B)'[(V_b-V_B)^(-1)](b-B) = 10.75 Prob>chi2 = 0.0010 (V_b-V_B is not positive definite) . . * Reduce instruments . ivregress 2sls lqprod (lp=ly L.lp lexpts) lpf year L.lqprod in 11/50 Instrumental variables (2SLS) regression Number of obs = 40 Wald chi2(4) = 9473.08 Prob > chi2 = 0.0000 R-squared = 0.9958 Root MSE = .03557 ------------------------------------------------------------------------------ lqprod | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- lp | .2927605 .127081 2.30 0.021 .0436864 .5418347 lpf | -.1644829 .0554668 -2.97 0.003 -.2731959 -.0557699 year | .0208021 .006811 3.05 0.002 .0074527 .0341515 lqprod | L1. | .5972367 .1311777 4.55 0.000 .3401332 .8543402 _cons | -37.55743 12.36501 -3.04 0.002 -61.7924 -13.32246 ------------------------------------------------------------------------------ Instrumented: lp Instruments: lpf year L.lqprod ly L.lp lexpts . estat firststage First-stage regression summary statistics -------------------------------------------------------------------------- | Adjusted Partial Variable | R-sq. R-sq. R-sq. F(3,33) Prob > F -------------+------------------------------------------------------------ lp | 0.9258 0.9124 0.3746 6.5901 0.0013 -------------------------------------------------------------------------- Minimum eigenvalue statistic = 6.59001 Critical Values # of endogenous regressors: 1 Ho: Instruments are weak # of excluded instruments: 3 --------------------------------------------------------------------- | 5% 10% 20% 30% 2SLS relative bias | 13.91 9.08 6.46 5.39 -----------------------------------+--------------------------------- | 10% 15% 20% 25% 2SLS Size of nominal 5% Wald test | 22.30 12.83 9.54 7.80 LIML Size of nominal 5% Wald test | 6.46 4.36 3.69 3.32 --------------------------------------------------------------------- . estat overid Tests of overidentifying restrictions: Sargan (score) chi2(2) = 2.5892 (p = 0.2740) Basmann chi2(2) = 2.28393 (p = 0.3192) . . ivregress liml lqprod (lp=ly L.lp lexpts) lpf year L.lqprod in 11/50 Instrumental variables (LIML) regression Number of obs = 40 Wald chi2(4) = 8298.06 Prob > chi2 = 0.0000 R-squared = 0.9952 Root MSE = .03801 ------------------------------------------------------------------------------ lqprod | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- lp | .3478826 .1438048 2.42 0.016 .0660304 .6297348 lpf | -.1789194 .0605509 -2.95 0.003 -.2975971 -.0602417 year | .0226738 .0074532 3.04 0.002 .0080658 .0372819 lqprod | L1. | .5709139 .1419789 4.02 0.000 .2926405 .8491874 _cons | -41.03508 13.54575 -3.03 0.002 -67.58427 -14.48589 ------------------------------------------------------------------------------ Instrumented: lp Instruments: lpf year L.lqprod ly L.lp lexpts . estat firststage First-stage regression summary statistics -------------------------------------------------------------------------- | Adjusted Partial Variable | R-sq. R-sq. R-sq. F(3,33) Prob > F -------------+------------------------------------------------------------ lp | 0.9258 0.9124 0.3746 6.5901 0.0013 -------------------------------------------------------------------------- Minimum eigenvalue statistic = 6.59001 Critical Values # of endogenous regressors: 1 Ho: Instruments are weak # of excluded instruments: 3 --------------------------------------------------------------------- | 5% 10% 20% 30% 2SLS relative bias | 13.91 9.08 6.46 5.39 -----------------------------------+--------------------------------- | 10% 15% 20% 25% 2SLS Size of nominal 5% Wald test | 22.30 12.83 9.54 7.80 LIML Size of nominal 5% Wald test | 6.46 4.36 3.69 3.32 --------------------------------------------------------------------- . estat overid Tests of overidentifying restrictions: Anderson-Rubin chi2(2) = 2.59667 (p = 0.2730) Basmann F(2, 34) = 1.10358 (p = 0.3433) . end of do-file . log close log: I:\Documents and Settings\Documents\Classes\6243\newbroiler.log log type: text closed on: 20 Feb 2008, 15:41:26 -------------------------------------------------------------------------------