楼主: zdlspace
96750 120

[程序分享] Stata同时输出两阶段最小二乘法的两步回归结果   [推广有奖]

21
zdlspace 学生认证  发表于 2021-1-31 16:52:25 |只看作者 |坛友微信交流群
黃河泉 发表于 2021-1-31 16:23
你确定这个可以 run,我无法跑!
  1. . sysuse auto, clear
  2. (1978 Automobile Data)

  3. . eststo:ivreghdfe price (weight=length), a(foreign) first savefirst savefp(f)
  4. (MWFE estimator converged in 1 iterations)

  5. Stored estimation results
  6. -------------------------
  7. -----------------------------------------------------------------------------
  8.         name | command      depvar       npar  title
  9. -------------+---------------------------------------------------------------
  10.      fweight | ivreg2       weight          1  First-stage regression: weight
  11. -----------------------------------------------------------------------------

  12. First-stage regressions
  13. -----------------------


  14. First-stage regression of weight:

  15. Statistics consistent for homoskedasticity only
  16. Number of obs =                     74
  17. ------------------------------------------------------------------------------
  18.       weight |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
  19. -------------+----------------------------------------------------------------
  20.       length |     31.445      1.601    19.64   0.000       28.252      34.637
  21. ------------------------------------------------------------------------------
  22. F test of excluded instruments:
  23.   F(  1,    71) =   385.64
  24.   Prob > F      =   0.0000
  25. Sanderson-Windmeijer multivariate F test of excluded instruments:
  26.   F(  1,    71) =   385.64
  27.   Prob > F      =   0.0000



  28. Summary results for first-stage regressions
  29. -------------------------------------------

  30.                                            (Underid)            (Weak id)
  31. Variable     | F(  1,    71)  P-val | SW Chi-sq(  1) P-val | SW F(  1,    71)
  32. weight       |     385.64    0.0000 |      401.93   0.0000 |      385.64

  33. Stock-Yogo weak ID F test critical values for single endogenous regressor:
  34.                                    10% maximal IV size             16.38
  35.                                    15% maximal IV size              8.96
  36.                                    20% maximal IV size              6.66
  37.                                    25% maximal IV size              5.53
  38. Source: Stock-Yogo (2005).  Reproduced by permission.
  39. NB: Critical values are for Sanderson-Windmeijer F statistic.

  40. Underidentification test
  41. Ho: matrix of reduced form coefficients has rank=K1-1 (underidentified)
  42. Ha: matrix has rank=K1 (identified)
  43. Anderson canon. corr. LM statistic       Chi-sq(1)=62.49    P-val=0.0000

  44. Weak identification test
  45. Ho: equation is weakly identified
  46. Cragg-Donald Wald F statistic                                     385.64

  47. Stock-Yogo weak ID test critical values for K1=1 and L1=1:
  48.                                    10% maximal IV size             16.38
  49.                                    15% maximal IV size              8.96
  50.                                    20% maximal IV size              6.66
  51.                                    25% maximal IV size              5.53
  52. Source: Stock-Yogo (2005).  Reproduced by permission.

  53. Weak-instrument-robust inference
  54. Tests of joint significance of endogenous regressors B1 in main equation
  55. Ho: B1=0 and orthogonality conditions are valid
  56. Anderson-Rubin Wald test           F(1,71)=       32.46     P-val=0.0000
  57. Anderson-Rubin Wald test           Chi-sq(1)=     33.83     P-val=0.0000
  58. Stock-Wright LM S statistic        Chi-sq(1)=     23.22     P-val=0.0000

  59. Number of observations               N  =         74
  60. Number of regressors                 K  =          1
  61. Number of endogenous regressors      K1 =          1
  62. Number of instruments                L  =          1
  63. Number of excluded instruments       L1 =          1

  64. IV (2SLS) estimation
  65. --------------------

  66. Estimates efficient for homoskedasticity only
  67. Statistics consistent for homoskedasticity only

  68.                                                       Number of obs =       74
  69.                                                       F(  1,    71) =    43.55
  70.                                                       Prob > F      =   0.0000
  71. Total (centered) SS     =  633558013.5                Centered R2   =   0.4885
  72. Total (uncentered) SS   =  633558013.5                Uncentered R2 =   0.4885
  73. Residual SS             =  324043549.4                Root MSE      =     2136

  74. ------------------------------------------------------------------------------
  75.        price |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
  76. -------------+----------------------------------------------------------------
  77.       weight |      2.869      0.435     6.60   0.000        2.002       3.736
  78. ------------------------------------------------------------------------------
  79. Underidentification test (Anderson canon. corr. LM statistic):          62.494
  80.                                                    Chi-sq(1) P-val =    0.0000
  81. ------------------------------------------------------------------------------
  82. Weak identification test (Cragg-Donald Wald F statistic):              385.639
  83. Stock-Yogo weak ID test critical values: 10% maximal IV size             16.38
  84.                                          15% maximal IV size              8.96
  85.                                          20% maximal IV size              6.66
  86.                                          25% maximal IV size              5.53
  87. Source: Stock-Yogo (2005).  Reproduced by permission.
  88. ------------------------------------------------------------------------------
  89. Sargan statistic (overidentification test of all instruments):           0.000
  90.                                                  (equation exactly identified)
  91. ------------------------------------------------------------------------------
  92. Instrumented:         weight
  93. Excluded instruments: length
  94. Partialled-out:       _cons
  95.                       nb: total SS, model F and R2s are after partialling-out;
  96.                           any small-sample adjustments include partialled-out
  97.                           variables in regressor count K
  98. ------------------------------------------------------------------------------

  99. Absorbed degrees of freedom:
  100. -----------------------------------------------------+
  101. Absorbed FE | Categories  - Redundant  = Num. Coefs |
  102. -------------+---------------------------------------|
  103.      foreign |         2           0           2     |
  104. -----------------------------------------------------+
  105. (est2 stored)

  106. . est restore fweight
  107. (results fweight are active now)

  108. . outreg2 using xxx.doc,cttop(first) replace
  109. xxx.doc
  110. dir : seeout

  111. . est restore est1
  112. (results est1 are active now)

  113. . outreg2 using xxx.doc,cttop(second)
  114. xxx.doc
  115. dir : seeout

  116. .
  117. end of do-file

  118. . do "/var/folders/38/1b2z7ctd7yd90cdlc7ym_wxm0000gn/T//SD56421.000000"

  119. . sysuse auto, clear
  120. (1978 Automobile Data)

  121. . eststo clear

  122. . eststo: ivreghdfe price (weight=length), a(foreign) first savefirst savefprefix(f)
  123. (MWFE estimator converged in 1 iterations)

  124. Stored estimation results
  125. -------------------------
  126. -----------------------------------------------------------------------------
  127.         name | command      depvar       npar  title
  128. -------------+---------------------------------------------------------------
  129.      fweight | ivreg2       weight          1  First-stage regression: weight
  130. -----------------------------------------------------------------------------

  131. First-stage regressions
  132. -----------------------


  133. First-stage regression of weight:

  134. Statistics consistent for homoskedasticity only
  135. Number of obs =                     74
  136. ------------------------------------------------------------------------------
  137.       weight |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
  138. -------------+----------------------------------------------------------------
  139.       length |     31.445      1.601    19.64   0.000       28.252      34.637
  140. ------------------------------------------------------------------------------
  141. F test of excluded instruments:
  142.   F(  1,    71) =   385.64
  143.   Prob > F      =   0.0000
  144. Sanderson-Windmeijer multivariate F test of excluded instruments:
  145.   F(  1,    71) =   385.64
  146.   Prob > F      =   0.0000



  147. Summary results for first-stage regressions
  148. -------------------------------------------

  149.                                            (Underid)            (Weak id)
  150. Variable     | F(  1,    71)  P-val | SW Chi-sq(  1) P-val | SW F(  1,    71)
  151. weight       |     385.64    0.0000 |      401.93   0.0000 |      385.64

  152. Stock-Yogo weak ID F test critical values for single endogenous regressor:
  153.                                    10% maximal IV size             16.38
  154.                                    15% maximal IV size              8.96
  155.                                    20% maximal IV size              6.66
  156.                                    25% maximal IV size              5.53
  157. Source: Stock-Yogo (2005).  Reproduced by permission.
  158. NB: Critical values are for Sanderson-Windmeijer F statistic.

  159. Underidentification test
  160. Ho: matrix of reduced form coefficients has rank=K1-1 (underidentified)
  161. Ha: matrix has rank=K1 (identified)
  162. Anderson canon. corr. LM statistic       Chi-sq(1)=62.49    P-val=0.0000

  163. Weak identification test
  164. Ho: equation is weakly identified
  165. Cragg-Donald Wald F statistic                                     385.64

  166. Stock-Yogo weak ID test critical values for K1=1 and L1=1:
  167.                                    10% maximal IV size             16.38
  168.                                    15% maximal IV size              8.96
  169.                                    20% maximal IV size              6.66
  170.                                    25% maximal IV size              5.53
  171. Source: Stock-Yogo (2005).  Reproduced by permission.

  172. Weak-instrument-robust inference
  173. Tests of joint significance of endogenous regressors B1 in main equation
  174. Ho: B1=0 and orthogonality conditions are valid
  175. Anderson-Rubin Wald test           F(1,71)=       32.46     P-val=0.0000
  176. Anderson-Rubin Wald test           Chi-sq(1)=     33.83     P-val=0.0000
  177. Stock-Wright LM S statistic        Chi-sq(1)=     23.22     P-val=0.0000

  178. Number of observations               N  =         74
  179. Number of regressors                 K  =          1
  180. Number of endogenous regressors      K1 =          1
  181. Number of instruments                L  =          1
  182. Number of excluded instruments       L1 =          1

  183. IV (2SLS) estimation
  184. --------------------

  185. Estimates efficient for homoskedasticity only
  186. Statistics consistent for homoskedasticity only

  187.                                                       Number of obs =       74
  188.                                                       F(  1,    71) =    43.55
  189.                                                       Prob > F      =   0.0000
  190. Total (centered) SS     =  633558013.5                Centered R2   =   0.4885
  191. Total (uncentered) SS   =  633558013.5                Uncentered R2 =   0.4885
  192. Residual SS             =  324043549.4                Root MSE      =     2136

  193. ------------------------------------------------------------------------------
  194.        price |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
  195. -------------+----------------------------------------------------------------
  196.       weight |      2.869      0.435     6.60   0.000        2.002       3.736
  197. ------------------------------------------------------------------------------
  198. Underidentification test (Anderson canon. corr. LM statistic):          62.494
  199.                                                    Chi-sq(1) P-val =    0.0000
  200. ------------------------------------------------------------------------------
  201. Weak identification test (Cragg-Donald Wald F statistic):              385.639
  202. Stock-Yogo weak ID test critical values: 10% maximal IV size             16.38
  203.                                          15% maximal IV size              8.96
  204.                                          20% maximal IV size              6.66
  205.                                          25% maximal IV size              5.53
  206. Source: Stock-Yogo (2005).  Reproduced by permission.
  207. ------------------------------------------------------------------------------
  208. Sargan statistic (overidentification test of all instruments):           0.000
  209.                                                  (equation exactly identified)
  210. ------------------------------------------------------------------------------
  211. Instrumented:         weight
  212. Excluded instruments: length
  213. Partialled-out:       _cons
  214.                       nb: total SS, model F and R2s are after partialling-out;
  215.                           any small-sample adjustments include partialled-out
  216.                           variables in regressor count K
  217. ------------------------------------------------------------------------------

  218. Absorbed degrees of freedom:
  219. -----------------------------------------------------+
  220. Absorbed FE | Categories  - Redundant  = Num. Coefs |
  221. -------------+---------------------------------------|
  222.      foreign |         2           0           2     |
  223. -----------------------------------------------------+
  224. (est1 stored)

  225. . estadd scalar F = `e(widstat)' : fweight   //将第二阶段得到的弱工具变量检验统计量加到第一阶段模型
  226. > 中

  227. . esttab fweight est1 using xxx.doc, scalar(F) replace
  228. (output written to xxx.doc)
复制代码

使用道具

22
zdlspace 学生认证  发表于 2021-1-31 16:53:57 |只看作者 |坛友微信交流群
黃河泉 发表于 2021-1-31 16:23
你确定这个可以 run,我无法跑!
可能是你内存中储存了其他回归结果,加一条eststo clear试试。
  1. ***ivreghdfe----outreg2******
  2. sysuse auto, clear
  3. eststo clear
  4. eststo:ivreghdfe price (weight=length), a(foreign) first savefirst savefp(f)
  5. est restore fweight
  6. outreg2 using xxx.doc,cttop(first) replace
  7. est restore est1
  8. outreg2 using xxx.doc,cttop(second)

  9. ***ivreghdfe----esttab******
  10. sysuse auto, clear
  11. eststo clear
  12. eststo: ivreghdfe price (weight=length), a(foreign) first savefirst savefprefix(f)
  13. estadd scalar F = `e(widstat)' : fweight   //将第二阶段得到的弱工具变量检验统计量加到第一阶段模型中
  14. esttab fweight est1 using xxx.doc, scalar(F) replace
复制代码

使用道具

23
zdlspace 学生认证  发表于 2021-1-31 16:55:24 |只看作者 |坛友微信交流群
黃河泉 发表于 2021-1-31 16:23
你确定这个可以 run,我无法跑!
我这边确实可以跑的,您那边报什么错了?
  1. . sysuse auto, clear
  2. (1978 Automobile Data)

  3. . eststo:ivreghdfe price (weight=length), a(foreign) first savefirst savefp(f)
  4. (MWFE estimator converged in 1 iterations)

  5. Stored estimation results
  6. -------------------------
  7. -----------------------------------------------------------------------------
  8.         name | command      depvar       npar  title
  9. -------------+---------------------------------------------------------------
  10.      fweight | ivreg2       weight          1  First-stage regression: weight
  11. -----------------------------------------------------------------------------

  12. First-stage regressions
  13. -----------------------


  14. First-stage regression of weight:

  15. Statistics consistent for homoskedasticity only
  16. Number of obs =                     74
  17. ------------------------------------------------------------------------------
  18.       weight |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
  19. -------------+----------------------------------------------------------------
  20.       length |     31.445      1.601    19.64   0.000       28.252      34.637
  21. ------------------------------------------------------------------------------
  22. F test of excluded instruments:
  23.   F(  1,    71) =   385.64
  24.   Prob > F      =   0.0000
  25. Sanderson-Windmeijer multivariate F test of excluded instruments:
  26.   F(  1,    71) =   385.64
  27.   Prob > F      =   0.0000



  28. Summary results for first-stage regressions
  29. -------------------------------------------

  30.                                            (Underid)            (Weak id)
  31. Variable     | F(  1,    71)  P-val | SW Chi-sq(  1) P-val | SW F(  1,    71)
  32. weight       |     385.64    0.0000 |      401.93   0.0000 |      385.64

  33. Stock-Yogo weak ID F test critical values for single endogenous regressor:
  34.                                    10% maximal IV size             16.38
  35.                                    15% maximal IV size              8.96
  36.                                    20% maximal IV size              6.66
  37.                                    25% maximal IV size              5.53
  38. Source: Stock-Yogo (2005).  Reproduced by permission.
  39. NB: Critical values are for Sanderson-Windmeijer F statistic.

  40. Underidentification test
  41. Ho: matrix of reduced form coefficients has rank=K1-1 (underidentified)
  42. Ha: matrix has rank=K1 (identified)
  43. Anderson canon. corr. LM statistic       Chi-sq(1)=62.49    P-val=0.0000

  44. Weak identification test
  45. Ho: equation is weakly identified
  46. Cragg-Donald Wald F statistic                                     385.64

  47. Stock-Yogo weak ID test critical values for K1=1 and L1=1:
  48.                                    10% maximal IV size             16.38
  49.                                    15% maximal IV size              8.96
  50.                                    20% maximal IV size              6.66
  51.                                    25% maximal IV size              5.53
  52. Source: Stock-Yogo (2005).  Reproduced by permission.

  53. Weak-instrument-robust inference
  54. Tests of joint significance of endogenous regressors B1 in main equation
  55. Ho: B1=0 and orthogonality conditions are valid
  56. Anderson-Rubin Wald test           F(1,71)=       32.46     P-val=0.0000
  57. Anderson-Rubin Wald test           Chi-sq(1)=     33.83     P-val=0.0000
  58. Stock-Wright LM S statistic        Chi-sq(1)=     23.22     P-val=0.0000

  59. Number of observations               N  =         74
  60. Number of regressors                 K  =          1
  61. Number of endogenous regressors      K1 =          1
  62. Number of instruments                L  =          1
  63. Number of excluded instruments       L1 =          1

  64. IV (2SLS) estimation
  65. --------------------

  66. Estimates efficient for homoskedasticity only
  67. Statistics consistent for homoskedasticity only

  68.                                                       Number of obs =       74
  69.                                                       F(  1,    71) =    43.55
  70.                                                       Prob > F      =   0.0000
  71. Total (centered) SS     =  633558013.5                Centered R2   =   0.4885
  72. Total (uncentered) SS   =  633558013.5                Uncentered R2 =   0.4885
  73. Residual SS             =  324043549.4                Root MSE      =     2136

  74. ------------------------------------------------------------------------------
  75.        price |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
  76. -------------+----------------------------------------------------------------
  77.       weight |      2.869      0.435     6.60   0.000        2.002       3.736
  78. ------------------------------------------------------------------------------
  79. Underidentification test (Anderson canon. corr. LM statistic):          62.494
  80.                                                    Chi-sq(1) P-val =    0.0000
  81. ------------------------------------------------------------------------------
  82. Weak identification test (Cragg-Donald Wald F statistic):              385.639
  83. Stock-Yogo weak ID test critical values: 10% maximal IV size             16.38
  84.                                          15% maximal IV size              8.96
  85.                                          20% maximal IV size              6.66
  86.                                          25% maximal IV size              5.53
  87. Source: Stock-Yogo (2005).  Reproduced by permission.
  88. ------------------------------------------------------------------------------
  89. Sargan statistic (overidentification test of all instruments):           0.000
  90.                                                  (equation exactly identified)
  91. ------------------------------------------------------------------------------
  92. Instrumented:         weight
  93. Excluded instruments: length
  94. Partialled-out:       _cons
  95.                       nb: total SS, model F and R2s are after partialling-out;
  96.                           any small-sample adjustments include partialled-out
  97.                           variables in regressor count K
  98. ------------------------------------------------------------------------------

  99. Absorbed degrees of freedom:
  100. -----------------------------------------------------+
  101. Absorbed FE | Categories  - Redundant  = Num. Coefs |
  102. -------------+---------------------------------------|
  103.      foreign |         2           0           2     |
  104. -----------------------------------------------------+
  105. (est2 stored)

  106. . est restore fweight
  107. (results fweight are active now)

  108. . outreg2 using xxx.doc,cttop(first) replace
  109. xxx.doc
  110. dir : seeout

  111. . est restore est1
  112. (results est1 are active now)

  113. . outreg2 using xxx.doc,cttop(second)
  114. xxx.doc
  115. dir : seeout

  116. .
  117. end of do-file

  118. . do "/var/folders/38/1b2z7ctd7yd90cdlc7ym_wxm0000gn/T//SD56421.000000"

  119. . sysuse auto, clear
  120. (1978 Automobile Data)

  121. . eststo clear

  122. . eststo: ivreghdfe price (weight=length), a(foreign) first savefirst savefprefix(f)
  123. (MWFE estimator converged in 1 iterations)

  124. Stored estimation results
  125. -------------------------
  126. -----------------------------------------------------------------------------
  127.         name | command      depvar       npar  title
  128. -------------+---------------------------------------------------------------
  129.      fweight | ivreg2       weight          1  First-stage regression: weight
  130. -----------------------------------------------------------------------------

  131. First-stage regressions
  132. -----------------------


  133. First-stage regression of weight:

  134. Statistics consistent for homoskedasticity only
  135. Number of obs =                     74
  136. ------------------------------------------------------------------------------
  137.       weight |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
  138. -------------+----------------------------------------------------------------
  139.       length |     31.445      1.601    19.64   0.000       28.252      34.637
  140. ------------------------------------------------------------------------------
  141. F test of excluded instruments:
  142.   F(  1,    71) =   385.64
  143.   Prob > F      =   0.0000
  144. Sanderson-Windmeijer multivariate F test of excluded instruments:
  145.   F(  1,    71) =   385.64
  146.   Prob > F      =   0.0000



  147. Summary results for first-stage regressions
  148. -------------------------------------------

  149.                                            (Underid)            (Weak id)
  150. Variable     | F(  1,    71)  P-val | SW Chi-sq(  1) P-val | SW F(  1,    71)
  151. weight       |     385.64    0.0000 |      401.93   0.0000 |      385.64

  152. Stock-Yogo weak ID F test critical values for single endogenous regressor:
  153.                                    10% maximal IV size             16.38
  154.                                    15% maximal IV size              8.96
  155.                                    20% maximal IV size              6.66
  156.                                    25% maximal IV size              5.53
  157. Source: Stock-Yogo (2005).  Reproduced by permission.
  158. NB: Critical values are for Sanderson-Windmeijer F statistic.

  159. Underidentification test
  160. Ho: matrix of reduced form coefficients has rank=K1-1 (underidentified)
  161. Ha: matrix has rank=K1 (identified)
  162. Anderson canon. corr. LM statistic       Chi-sq(1)=62.49    P-val=0.0000

  163. Weak identification test
  164. Ho: equation is weakly identified
  165. Cragg-Donald Wald F statistic                                     385.64

  166. Stock-Yogo weak ID test critical values for K1=1 and L1=1:
  167.                                    10% maximal IV size             16.38
  168.                                    15% maximal IV size              8.96
  169.                                    20% maximal IV size              6.66
  170.                                    25% maximal IV size              5.53
  171. Source: Stock-Yogo (2005).  Reproduced by permission.

  172. Weak-instrument-robust inference
  173. Tests of joint significance of endogenous regressors B1 in main equation
  174. Ho: B1=0 and orthogonality conditions are valid
  175. Anderson-Rubin Wald test           F(1,71)=       32.46     P-val=0.0000
  176. Anderson-Rubin Wald test           Chi-sq(1)=     33.83     P-val=0.0000
  177. Stock-Wright LM S statistic        Chi-sq(1)=     23.22     P-val=0.0000

  178. Number of observations               N  =         74
  179. Number of regressors                 K  =          1
  180. Number of endogenous regressors      K1 =          1
  181. Number of instruments                L  =          1
  182. Number of excluded instruments       L1 =          1

  183. IV (2SLS) estimation
  184. --------------------

  185. Estimates efficient for homoskedasticity only
  186. Statistics consistent for homoskedasticity only

  187.                                                       Number of obs =       74
  188.                                                       F(  1,    71) =    43.55
  189.                                                       Prob > F      =   0.0000
  190. Total (centered) SS     =  633558013.5                Centered R2   =   0.4885
  191. Total (uncentered) SS   =  633558013.5                Uncentered R2 =   0.4885
  192. Residual SS             =  324043549.4                Root MSE      =     2136

  193. ------------------------------------------------------------------------------
  194.        price |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
  195. -------------+----------------------------------------------------------------
  196.       weight |      2.869      0.435     6.60   0.000        2.002       3.736
  197. ------------------------------------------------------------------------------
  198. Underidentification test (Anderson canon. corr. LM statistic):          62.494
  199.                                                    Chi-sq(1) P-val =    0.0000
  200. ------------------------------------------------------------------------------
  201. Weak identification test (Cragg-Donald Wald F statistic):              385.639
  202. Stock-Yogo weak ID test critical values: 10% maximal IV size             16.38
  203.                                          15% maximal IV size              8.96
  204.                                          20% maximal IV size              6.66
  205.                                          25% maximal IV size              5.53
  206. Source: Stock-Yogo (2005).  Reproduced by permission.
  207. ------------------------------------------------------------------------------
  208. Sargan statistic (overidentification test of all instruments):           0.000
  209.                                                  (equation exactly identified)
  210. ------------------------------------------------------------------------------
  211. Instrumented:         weight
  212. Excluded instruments: length
  213. Partialled-out:       _cons
  214.                       nb: total SS, model F and R2s are after partialling-out;
  215.                           any small-sample adjustments include partialled-out
  216.                           variables in regressor count K
  217. ------------------------------------------------------------------------------

  218. Absorbed degrees of freedom:
  219. -----------------------------------------------------+
  220. Absorbed FE | Categories  - Redundant  = Num. Coefs |
  221. -------------+---------------------------------------|
  222.      foreign |         2           0           2     |
  223. -----------------------------------------------------+
  224. (est1 stored)

  225. . estadd scalar F = `e(widstat)' : fweight   //将第二阶段得到的弱工具变量检验统计量加到第一阶段模型
  226. > 中

  227. . esttab fweight est1 using xxx.doc, scalar(F) replace
  228. (output written to xxx.doc)
复制代码

使用道具

24
黃河泉 在职认证  发表于 2021-2-1 08:35:40 |只看作者 |坛友微信交流群
zdlspace 发表于 2021-1-31 16:53
可能是你内存中储存了其他回归结果,加一条eststo clear试试。
还是不行:
  1. . ***ivreghdfe----outreg2******
  2. . sysuse auto, clear
  3. (1978 Automobile Data)

  4. . eststo clear

  5. . eststo:ivreghdfe price (weight=length), a(foreign) first savefirst savefp(f)
  6. (MWFE estimator converged in 1 iterations)

  7. Stored estimation results
  8. -------------------------
  9. -----------------------------------------------------------------------------
  10.         name | command      depvar       npar  title
  11. -------------+---------------------------------------------------------------
  12.      fweight | ivreg2       weight          1  First-stage regression: weight
  13. -----------------------------------------------------------------------------

  14. First-stage regressions
  15. -----------------------


  16. Statistics consistent for homoskedasticity only

  17.                                                       Number of obs =       74
  18.                                                       F(  .,     .) =        .
  19.                                                       Prob > F      =        .
  20. Total (centered) SS     =            .                Centered R2   =        .
  21. Total (uncentered) SS   =            .                Uncentered R2 =        .
  22. Residual SS             =            .                Root MSE      =    250.3

  23. ------------------------------------------------------------------------------
  24.       weight |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
  25. -------------+----------------------------------------------------------------
  26.       length |   31.44455   1.601234    19.64   0.000     28.25178    34.63732
  27. ------------------------------------------------------------------------------
  28. Sargan statistic (Lagrange multiplier test of excluded instruments):         .
  29.                                                  (equation exactly identified)
  30. ------------------------------------------------------------------------------
  31. invalid syntax
  32. r(198);

  33. end of do-file

  34. r(198);
复制代码

使用道具

25
黃河泉 在职认证  发表于 2021-2-1 08:42:10 |只看作者 |坛友微信交流群
zdlspace 发表于 2021-1-31 16:53
可能是你内存中储存了其他回归结果,加一条eststo clear试试。
不好意思,更新所有相关 pacjages 后就可以了:
  1. * Install ftools (remove program if it existed previously)
  2. cap ado uninstall ftools
  3. net install ftools, from("https://raw.githubusercontent.com/sergiocorreia/ftools/master/src/") replace

  4. * Install reghdfe
  5. cap ado uninstall reghdfe
  6. net install reghdfe, from("https://raw.githubusercontent.com/sergiocorreia/reghdfe/master/src/") replace

  7. * Install boottest (Stata 11 and 12)
  8. if (c(version)<13) cap ado uninstall boottest
  9. if (c(version)<13) ssc install boottest, replace

  10. * Install moremata (sometimes used by ftools but not needed for reghdfe)
  11. cap ssc install moremata, replace

  12. * Install ivreg2, the core package
  13. cap ado uninstall ivreg2
  14. ssc install ivreg2, replace

  15. * Finally, install this package
  16. cap ado uninstall ivreghdfe
  17. net install ivreghdfe, from(https://raw.githubusercontent.com/sergiocorreia/ivreghdfe/master/src/) replace
复制代码
已有 1 人评分学术水平 热心指数 信用等级 收起 理由
Sunknownay + 3 + 3 + 3 好的意见建议

总评分: 学术水平 + 3  热心指数 + 3  信用等级 + 3   查看全部评分

使用道具

26
zdlspace 学生认证  发表于 2021-2-1 13:15:39 |只看作者 |坛友微信交流群
黃河泉 发表于 2021-2-1 08:42
不好意思,更新所有相关 pacjages 后就可以了:
嗯,是这样的,基本上我常用的命令,我都会给它更新到最新版,因为作者有可能修复了命令中的一些bug。

使用道具

27
田子啊 发表于 2021-3-31 14:14:27 |只看作者 |坛友微信交流群
楼主你好,我在用xtivreg2 输出结果时,显示command outreg2 using is unrecognized ,但是我之前也一直在用outreg2啊,不会存在没有安装的意思,想问楼主这个是什么原因呢

使用道具

28
zdlspace 学生认证  发表于 2021-3-31 14:50:36 |只看作者 |坛友微信交流群
田子啊 发表于 2021-3-31 14:14
楼主你好,我在用xtivreg2 输出结果时,显示command outreg2 using is unrecognized ,但是我之前也一 ...
先确认是否确实安装了,help outreg2,看看有没有。如果有的话,试着重新安装一次,ssc install outreg2,replace

使用道具

29
田子啊 发表于 2021-3-31 15:17:03 |只看作者 |坛友微信交流群
楼主你好,我又试了一下,发现还是不行。另外,我在运行estadd scalar F = `e(widstat)' : fweight  这个的时候,请问我应该更改这个命令里面什么的变量呢,因为结果显示estimation result fweight not found,感谢你的帮助

使用道具

30
玫睁涨捧 发表于 2021-4-16 13:41:36 |只看作者 |坛友微信交流群
楼主你好,我按照你的命令跑不了,xtivreg2也是更新到最新的版本了,能不能麻烦你帮忙解答一下,谢谢!
. which xtivreg2
/Users/zhouzhou/Library/Application Support/Stata/ado/plus/x/xtivreg2.ado
*! xtivreg2 1.0.17 19Feb2015
*! author mes



. use http://fmwww.bc.edu/ec-p/data/macro/abdata.dta,clear
(Layard & Nickell, Unemployment in Britain, Economica 53, 1986 from Ox dist)

. xtset id year
       panel variable:  id (unbalanced)
        time variable:  year, 1976 to 1984
                delta:  1 unit

. xtivreg2 ys k (n=l2.n l3.n), fe first savefp(first)   
option   not allowed
r(198);

end of do-file

r(198);

.

使用道具

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注jltj
拉您入交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-4-27 18:26