---------------------------------------------------------------------------------- name: log: /disk/oldadmin/homes/web/html/stata/tsls_example1.log log type: text opened on: 21 May 2013, 16:47:38 . set rmsg on r; t=0.00 16:47:38 . set more off r; t=0.00 16:47:38 . set obs 1000000 obs was 0, now 1000000 r; t=0.02 16:47:38 . . gen idcode = int((_n-1)/10000) r; t=0.03 16:47:38 . gen x1 = uniform() r; t=0.07 16:47:38 . gen y2 = uniform() r; t=0.10 16:47:38 . gen z1 = y2+uniform() r; t=0.15 16:47:38 . gen y1 = y2 + x1 + uniform() r; t=0.12 16:47:38 . . * XTIVREG2 . . timer on 1 r; t=0.00 16:47:38 . xtset idcode panel variable: idcode (balanced) r; t=0.42 16:47:39 . xtivreg2 y1 (y2 = z1) x1, fe first cluster(idcode) FIXED EFFECTS ESTIMATION ------------------------ Number of groups = 100 Obs per group: min = 10000 avg = 10000.0 max = 10000 First-stage regressions ----------------------- First-stage regression of y2: FIXED EFFECTS ESTIMATION ------------------------ Number of groups = 100 Obs per group: min = 10000 avg = 10000.0 max = 10000 OLS estimation -------------- Estimates efficient for homoskedasticity only Statistics robust to heteroskedasticity and clustering on idcode Number of clusters (idcode) = 100 Number of obs = . F( 2, 99) = 1.4e+06 Prob > F = 0.0000 Total (centered) SS = 83255.80838 Centered R2 = 0.4993 Total (uncentered) SS = 83255.80838 Uncentered R2 = 0.4993 Residual SS = 41683.6815 Root MSE = .2042 ------------------------------------------------------------------------------ | Robust y2 | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- x1 | .0008032 .0006413 1.25 0.213 -.0004693 .0020757 z1 | .499785 .0003085 1620.24 0.000 .4991729 .500397 ------------------------------------------------------------------------------ Included instruments: x1 z1 ------------------------------------------------------------------------------ F test of excluded instruments: F( 1, 99) = 2.6e+06 Prob > F = 0.0000 Angrist-Pischke multivariate F test of excluded instruments: F( 1, 99) = 2.6e+06 Prob > F = 0.0000 Summary results for first-stage regressions ------------------------------------------- (Underid) (Weak id) Variable | F( 1, 99) P-val | AP Chi-sq( 1) P-val | AP F( 1, 99) y2 | 2.6e+06 0.0000 | 2.7e+06 0.0000 | 2.6e+06 NB: first-stage test statistics cluster-robust Stock-Yogo weak ID test critical values for single endogenous regressor: 10% maximal IV size 16.38 15% maximal IV size 8.96 20% maximal IV size 6.66 25% maximal IV size 5.53 Source: Stock-Yogo (2005). Reproduced by permission. NB: Critical values are for Cragg-Donald F statistic and i.i.d. errors. Underidentification test Ho: matrix of reduced form coefficients has rank=K1-1 (underidentified) Ha: matrix has rank=K1 (identified) Kleibergen-Paap rk LM statistic Chi-sq(1)=99.99 P-val=0.0000 Weak identification test Ho: equation is weakly identified Cragg-Donald Wald F statistic 1.0e+06 Kleibergen-Paap Wald rk F statistic 2.6e+06 Stock-Yogo weak ID test critical values for K1=1 and L1=1: 10% maximal IV size 16.38 15% maximal IV size 8.96 20% maximal IV size 6.66 25% maximal IV size 5.53 Source: Stock-Yogo (2005). Reproduced by permission. NB: Critical values are for Cragg-Donald F statistic and i.i.d. errors. Weak-instrument-robust inference Tests of joint significance of endogenous regressors B1 in main equation Ho: B1=0 and orthogonality conditions are valid Anderson-Rubin Wald test F(1,99)= 4.5e+05 P-val=0.0000 Anderson-Rubin Wald test Chi-sq(1)= . P-val= . Stock-Wright LM S statistic Chi-sq(1)= 99.97 P-val=0.0000 NB: Underidentification, weak identification and weak-identification-robust test statistics cluster-robust Number of clusters N_clust = 100 Number of observations N = . Number of regressors K = 2 Number of endogenous regressors K1 = 1 Number of instruments L = 2 Number of excluded instruments L1 = 1 IV (2SLS) estimation -------------------- Estimates efficient for homoskedasticity only Statistics robust to heteroskedasticity and clustering on idcode Number of clusters (idcode) = 100 Number of obs = . F( 2, 99) = 7.1e+05 Prob > F = 0.0000 Total (centered) SS = 249992.5486 Centered R2 = 0.6665 Total (uncentered) SS = 249992.5486 Uncentered R2 = 0.6665 Residual SS = 83377.41844 Root MSE = .2888 ------------------------------------------------------------------------------ | Robust y1 | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- y2 | .9979584 .0013694 728.73 0.000 .9952743 1.000642 x1 | .9996318 .000991 1008.75 0.000 .9976895 1.001574 ------------------------------------------------------------------------------ Underidentification test (Kleibergen-Paap rk LM statistic): 99.986 Chi-sq(1) P-val = 0.0000 ------------------------------------------------------------------------------ Weak identification test (Cragg-Donald Wald F statistic): 1.0e+06 (Kleibergen-Paap rk Wald F statistic): 2.6e+06 Stock-Yogo weak ID test critical values: 10% maximal IV size 16.38 15% maximal IV size 8.96 20% maximal IV size 6.66 25% maximal IV size 5.53 Source: Stock-Yogo (2005). Reproduced by permission. NB: Critical values are for Cragg-Donald F statistic and i.i.d. errors. ------------------------------------------------------------------------------ Hansen J statistic (overidentification test of all instruments): 0.000 (equation exactly identified) ------------------------------------------------------------------------------ Instrumented: y2 Included instruments: x1 Excluded instruments: z1 ------------------------------------------------------------------------------ r; t=31.33 16:48:10 . timer off 1 r; t=0.00 16:48:10 . . * tsls . . timer on 2 r; t=0.00 16:48:10 . tsls y1 (y2 = z1) x1, demean fe(idcode) first cluster(idcode) replace Linear regression Number of obs = 1000000 F( 2, 99) = . Prob > F = 0.0000 R-squared = 0.4993 Root MSE = .20417 (Std. Err. adjusted for 100 clusters in idcode) ------------------------------------------------------------------------------ | Robust y2 | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- z1 | .499785 .0003085 1620.24 0.000 .4991729 .500397 x1 | .0008032 .0006413 1.25 0.213 -.0004693 .0020757 _cons | 6.31e-10 2.11e-09 0.30 0.766 -3.56e-09 4.83e-09 ------------------------------------------------------------------------------ ( 1) z1 = 0 F( 1, 99) = 2.6e+06 Prob > F = 0.0000 tsls, Fixed-Effects Two-Stage Instrumental Variable Results Number of clusters () = 100 Number of obs = 1000000 Total (centered) SS = 249992.5486 Centered R2 = 0.6665 Total (uncentered) SS = 249992.5486 Uncentered R2 = 0.6665 Residual SS = 83377.41844 ------------------------------------------------------------------------------ y1 | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- y2 | .9979584 .0013694 728.73 0.000 .9952743 1.000642 x1 | .9996318 .000991 1008.75 0.000 .9976895 1.001574 _cons | 1.91e-09 3.95e-09 0.48 0.629 -5.84e-09 9.65e-09 ------------------------------------------------------------------------------ r; t=5.46 16:48:16 . timer off 2 r; t=0.00 16:48:16 . timer on 3 r; t=0.00 16:48:16 . tsls y1 (y2 = z1) x1, fe(idcode) first cluster(idcode) Linear regression Number of obs = 1000000 F( 2, 99) = . Prob > F = 0.0000 R-squared = 0.4993 Root MSE = .20417 (Std. Err. adjusted for 100 clusters in idcode) ------------------------------------------------------------------------------ | Robust y2 | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- z1 | .499785 .0003085 1620.24 0.000 .4991729 .500397 x1 | .0008032 .0006413 1.25 0.213 -.0004693 .0020757 _cons | 6.31e-10 2.11e-09 0.30 0.766 -3.56e-09 4.83e-09 ------------------------------------------------------------------------------ ( 1) z1 = 0 F( 1, 99) = 2.6e+06 Prob > F = 0.0000 tsls, Fixed-Effects Two-Stage Instrumental Variable Results Number of clusters () = 100 Number of obs = 1000000 Total (centered) SS = 249992.5486 Centered R2 = 0.6665 Total (uncentered) SS = 249992.5486 Uncentered R2 = 0.6665 Residual SS = 83377.41844 ------------------------------------------------------------------------------ y1 | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- y2 | .9979584 .0013694 728.73 0.000 .9952743 1.000642 x1 | .9996318 .000991 1008.75 0.000 .9976895 1.001574 _cons | 1.91e-09 3.95e-09 0.48 0.629 -5.84e-09 9.65e-09 ------------------------------------------------------------------------------ r; t=1.12 16:48:17 . timer off 3 r; t=0.00 16:48:17 . . ******************************************** . * timer 1 time for xtivreg2 * . * timer 2 time for tsls * . * timer 3 timer for tsls with demeaned data* . ******************************************** . . timer list 1: 31.75 / 1 = 31.7510 2: 5.45 / 1 = 5.4530 3: 1.13 / 1 = 1.1270 r; t=0.00 16:48:17 . . . end of do-file r; t=0.00 16:48:17 . exit,clear