ClearView News.

Trusted, concise news and insight for informed readers.

culture

Exporting specific Stata output from ivreg2 to LaTeX ·

By James Austin

I am trying to export results of the Sanderson-Windmeijer multivariate F test of excluded instruments from Stata. Consider the following working example:

use clear ivreg2 lwage exper expersq (educ hours =age kidslt6 kidsge6), first 

Among the output can be found

 (Underid) (Weak id) Variable | F( 3, 422) P-val | SW Chi-sq( 2) P-val | SW F( 2, 422) educ | 4.34 0.0050 | 13.17 0.0014 | 6.49 hours | 6.44 0.0003 | 19.50 0.0001 | 9.61 

and

 Number of obs = 428 F( 4, 423) = 5.47 Prob > F = 0.0003 Total (centered) SS = 223.3274513 Centered R2 = 0.1151 Total (uncentered) SS = 829.594813 Uncentered R2 = 0.7618 Residual SS = 197.6266298 Root MSE = .6795 ------------------------------------------------------------------------------ lwage | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- educ | .1016889 .0836986 1.21 0.224 -.0623574 .2657351 hours | .0001501 .0002139 0.70 0.483 -.0002691 .0005692 exper | .0337614 .0186123 1.81 0.070 -.002718 .0702407 expersq | -.000703 .0004682 -1.50 0.133 -.0016206 .0002145 _cons | -.5677476 1.067838 -0.53 0.595 -2.660671 1.525176 ------------------------------------------------------------------------------ Underidentification test (Anderson canon. corr. LM statistic): 12.773 Chi-sq(2) P-val = 0.0017 ------------------------------------------------------------------------------ Weak identification test (Cragg-Donald Wald F statistic): 4.327 Stock-Yogo weak ID test critical values: 10% maximal IV size 13.43 15% maximal IV size 8.18 20% maximal IV size 6.40 25% maximal IV size 5.45 Source: Stock-Yogo (2005). Reproduced by permission. ------------------------------------------------------------------------------ Sargan statistic (overidentification test of all instruments): 0.177 Chi-sq(1) P-val = 0.6738 ------------------------------------------------------------------------------ 

I would like to output a table with two panels:

  • the top panel has the coefficients for educ, hours, expert, expersq, and cons
  • the bottom panel presents the R^2, and the Sanderson-Windmeijer F test for each regressor.
  • And I would like the code to be "scalable" so that if I were to run another regression, say,

    ivreg2 lwage exper (educ hours =age kidslt6 kidsge6), first 

    I can just append the estimates for this column.

    I know eststo can help with this and I checked this thread on Statalist, but when I run ereturn list I cannot find the required F-test for each variable.

    0

    1 Answer

    The Sanderson-Windmeijer F test is in a stored matrix. It can be found if you run mat list e(first) after your regression:

    . mat list e(first) e(first)[21,2] educ hours rmse 2.2586145 725.75198 sheapr2 .02984566 .04363689 pr2 .02994351 .04377996 F 4.3420709 6.4403383 df 3 3 df_r 422 422 pvalue .00498557 .00028482 SWF 6.4910143 9.6119846 SWFdf1 2 2 SWFdf2 422 422 SWFp .00167294 .00008277 SWchi2 13.166607 19.497296 SWchi2p .00138327 .00005837 SWr2 .02984498 .04356964 APF 6.4602774 9.5821494 APFdf1 2 2 APFdf2 422 422 APFp .00172358 .00008516 APchi2 13.104259 19.436777 APchi2p .00142707 .00006017 APr2 .02970785 .04344028 

    Here's a working example that would add these F-stats to the stored estimates and make a table containing them, using the two regressions you mentioned:

    use clear eststo: ivreg2 lwage exper expersq (educ hours =age kidslt6 kidsge6), first estadd scalar f_test_educ = e(first)[8,1] estadd scalar f_test_hours = e(first)[8,2] eststo: ivreg2 lwage exper (educ hours =age kidslt6 kidsge6), first estadd scalar f_test_educ = e(first)[8,1] estadd scalar f_test_hours = e(first)[8,2] esttab , b(3) se(3) stats(f_test_educ f_test_hours r2, fmt(3 3 3)) 

    Here's output of the esttab command:

     -------------------------------------------- (1) (2) lwage lwage -------------------------------------------- educ 0.102 0.107 (0.084) (0.084) hours 0.000 0.000 (0.000) (0.000) exper 0.034 0.010 (0.019) (0.007) expersq -0.001 (0.000) _cons -0.568 -0.560 (1.068) (1.086) -------------------------------------------- f_test_educ 6.491 6.687 f_test_hours 9.612 10.802 r2 0.115 0.082 -------------------------------------------- Standard errors in parentheses * p<0.05, ** p<0.01, *** p<0.001 
    0

    ncG1vNJzZmirpJawrLvVnqmfpJ%2Bse6S7zGiorp2jqbawutJobm5vZ2mFd4WOnq%2Bpp6Kptq%2BzjKynnpuZm7akedKtmK2ZXaTCtbzUrWSfqp%2BieqrC0Z6ea2WkpHqtrdOerw%3D%3D

     Share!