-----------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  /Users/yangyanjun/Desktop/exchangerate/提交版本/logs/tables_log.txt
  log type:  text
 opened on:  26 Jul 2025, 15:49:58

.   do "$dofiles/tables.do"

. 
. * ================================================
. *-  tables
. * ================================================
. 
. 
. display "开始生成描述性统计表..."
开始生成描述性统计表...

. 
.   *----------------- 指标含义 -----------------*
. 
. * 基础变量：
.  * - year: 年份
.  * - party_id: 企业代码
.  * - firm: 企业代码（重新编码）
.  * - company: 企业名称
.  * - hs_id: 8位产品代码
.  * - hs6: 6位产品hs代码
.  * - hs4: 4位产品hs代码
.  * - hs2: 2位产品hs代码
.  * - origin_id: 原产地代码
.  * - 国家: 中文国家名称
. 
.  * 价格与数量变量：
.  * - ppi: ppi数据
.  * - e: 1单位外币兑换的人民币汇率
.  * - value: 4位hs编码人民币计价进口额
.  * - quantity: 根据4位hs码加总的货物数量
.  * - price: 以人民币计价的商品单价
. 
. * 差分变量：
.  * - d_lnprice: 对数价格的差分值
.  * - d_lnppi: PPI对数差分 
.  * - d_lne: 对数汇率的差分值
. 
. * 竞争度指标：
.  * - hhi_hs4: 基于hs4进口额计算的HHI指数（除以10000标准化）
.  * - hhi_hs6: 基于hs6进口额计算的HHI指数（除以10000标准化）
.  * - hhi_hs8: 基于hs8进口额计算的HHI指数
.  * - hhi_hs4_avg: 行业平均的hhi指数
.  * - hhi_hs4_c: 行业-出口来源国层面构建的进口竞争度指标
.  * - HHI_kt: 全球进口商竞争度指标 
.  
. * 机制检验变量：
.  * - share: 企业的进口份额
.  
. * 产品分类变量：
.  * - bec: BEC产品分类代码
.  * - 中间品: 中间品虚拟变量（1=中间品，0=最终品）
. 
. * 企业类型变量：
.  * - types: 企业类型（"0"=进出口企业，"1"=内销型企业）
.  * - type: 企业类型数值变量
. 
. * 分组标识变量：
.  * - firm_origin_id_hs4: group(firm origin_id hs4)分组变量
. 
. * 固定效应组合：
.  * - 企业固定效应: firm
.  * - 产品固定效应: hs4/hs6/hs8
.  * - 原产地固定效应: origin_id
.  * - 年份固定效应: year
.  * - 交叉固定效应: firm#hs4#origin_id, hs4#origin_id等
.  
.   *----------------- 指标含义（以上部分） -----------------*
. 
. 
. **#A.表1.描述性统计
. /*------------------------------------------------------------------------------
>  * 表1.描述性统计
>  *------------------------------------------------------------------------------*/
. 
.   //主要回归变量
.   use "$W/final_data.dta", clear        

.   xtset firm_origin_id_hs4 year 

Panel variable: firm_origin_id_hs4 (unbalanced)
 Time variable: year, 2001 to 2013, but with gaps
         Delta: 1 unit

.   global y    "d_lnprice"                               // 被解释变量

.   global x1   "d_lne"                                   // 基本解释变量

.   global c    "d_lnppi"                                 // 基本控制变量  

.   local  v    "$y $x1 $c"                               // 主要回归变量

.   local  s    "$T/Table1_主要变量描述性统计"                // 存储的文件名

.   *ssc install sum2docx, replace
.   sum2docx `v' using "`s'.docx", replace ///
>     stats(N mean(%9.3f) sd min(%9.3f) p5(%9.3f) p25(%9.3f) median(%9.3f) p75(%9.3f) p95(%9.3f) max(
> %9.3f)) ///
>     title("主要回归变量描述性统计")
Summary statistics table has been written to file /Users/yangyanjun/Desktop/exchangerate/提交版本/tab
> les/Table1_主要变量描述性统计.docx.

. 
.   //基于HS4计算集中度指标的描述性统计
.   use "$W/赫芬达尔指数_hs4.dta", clear 

.   replace hhi_hs4 = hhi_hs4/10000                   
(15,798 real changes made)

.   local s_hs4 "$T/Table1_HHI_HS4描述性统计"  

.   sum2docx hhi_hs4 using "`s_hs4'.docx", replace ///
>     stats(N mean(%9.4f) sd min(%9.4f) p5(%9.4f) p25(%9.4f) median(%9.4f) p75(%9.4f) p95(%9.4f) max(
> %9.4f)) ///
>     title("HHI指数描述性统计(基于HS4)")
Summary statistics table has been written to file /Users/yangyanjun/Desktop/exchangerate/提交版本/tab
> les/Table1_HHI_HS4描述性统计.docx.

. 
.   //基于HS6计算集中度指标的描述性统计
.   use "$W/赫芬达尔指数_hs6.dta", clear

.   replace hhi_hs6 = hhi_hs6/10000                   
(61,651 real changes made)

.   local s_hs6 "$T/Table1_HHI_HS6描述性统计"  

.   sum2docx hhi_hs6 using "`s_hs6'.docx", replace ///
>     stats(N mean(%9.4f) sd min(%9.4f) p5(%9.4f) p25(%9.4f) median(%9.4f) p75(%9.4f) p95(%9.4f) max(
> %9.4f)) ///
>     title("HHI指数描述性统计(基于HS6)")
Summary statistics table has been written to file /Users/yangyanjun/Desktop/exchangerate/提交版本/tab
> les/Table1_HHI_HS6描述性统计.docx.

. 
. **#B.表2.基准回归
. /*------------------------------------------------------------------------------
>  * 表2.基准回归
>  *------------------------------------------------------------------------------*/
. 
.   use "$W/final_data.dta", clear

.   xtset firm_origin_id_hs4 year

Panel variable: firm_origin_id_hs4 (unbalanced)
 Time variable: year, 2001 to 2013, but with gaps
         Delta: 1 unit

.   global y    "d_lnprice"                                  //被解释变量

.   global x1   "d_lne"                                      //基本解释变量

.   global x2   "hhi_hs4"                                    //基本解释变量

.   global x3   "c.d_lne#c.hhi_hs4"                          //基本解释变量(主要观测)   

.   global c    "d_lnppi"                                    //基本控制变量  

.   global f    ", absorb(hs4#origin_id#firm year)"          //固定效应  

.   global opt  "vce(cluster i.origin_id#i.hs4)"

. 
.   reghdfe $y $x1          $c ,noabsorb  $opt 
(MWFE estimator converged in 1 iterations)

HDFE Linear regression                            Number of obs   = 10,796,716
Absorbing 1 HDFE group                            F(   2,  36169) =     223.07
Statistics robust to heteroskedasticity           Prob > F        =     0.0000
                                                  R-squared       =     0.0003
                                                  Adj R-squared   =     0.0003
                                                  Within R-sq.    =     0.0003
Number of clusters (origin_id#hs4) =     36,170   Root MSE        =     1.2325

                     (Std. err. adjusted for 36,170 clusters in origin_id#hs4)
------------------------------------------------------------------------------
             |               Robust
   d_lnprice | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
       d_lne |   .2428121   .0120717    20.11   0.000     .2191513     .266473
     d_lnppi |   .0909146   .0168986     5.38   0.000     .0577927    .1240364
       _cons |   .0235374   .0015069    15.62   0.000     .0205838     .026491
------------------------------------------------------------------------------

.   est store m1  

.   reghdfe $y $x1          $c $f  $opt
(dropped 1698839 singleton observations)
(MWFE estimator converged in 10 iterations)

HDFE Linear regression                            Number of obs   =  9,097,877
Absorbing 2 HDFE groups                           F(   2,  28829) =     153.34
Statistics robust to heteroskedasticity           Prob > F        =     0.0000
                                                  R-squared       =     0.1512
                                                  Adj R-squared   =    -0.1185
                                                  Within R-sq.    =     0.0002
Number of clusters (origin_id#hs4) =     28,830   Root MSE        =     1.2544

                     (Std. err. adjusted for 28,830 clusters in origin_id#hs4)
------------------------------------------------------------------------------
             |               Robust
   d_lnprice | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
       d_lne |   .2265098   .0134814    16.80   0.000     .2000856     .252934
     d_lnppi |  -.0366859   .0285137    -1.29   0.198    -.0925741    .0192024
       _cons |   .0313114   .0005697    54.96   0.000     .0301946    .0324281
------------------------------------------------------------------------------

Absorbed degrees of freedom:
----------------------------------------------------------------+
            Absorbed FE | Categories  - Redundant  = Num. Coefs |
------------------------+---------------------------------------|
     hs4#origin_id#firm |   2193666     2193666           0    *|
                   year |        13           1          12     |
----------------------------------------------------------------+
* = FE nested within cluster; treated as redundant for DoF computation

.   est store m2  

.   reghdfe $y $x1 $x2 $x3  $c ,noabsorb  $opt
(MWFE estimator converged in 1 iterations)

HDFE Linear regression                            Number of obs   = 10,796,716
Absorbing 1 HDFE group                            F(   4,  36169) =     120.28
Statistics robust to heteroskedasticity           Prob > F        =     0.0000
                                                  R-squared       =     0.0003
                                                  Adj R-squared   =     0.0003
                                                  Within R-sq.    =     0.0003
Number of clusters (origin_id#hs4) =     36,170   Root MSE        =     1.2325

                          (Std. err. adjusted for 36,170 clusters in origin_id#hs4)
-----------------------------------------------------------------------------------
                  |               Robust
        d_lnprice | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
------------------+----------------------------------------------------------------
            d_lne |   .2555269   .0129023    19.80   0.000      .230238    .2808158
          hhi_hs4 |   -.041553   .0129322    -3.21   0.001    -.0669005   -.0162054
                  |
c.d_lne#c.hhi_hs4 |  -.3935259   .1498935    -2.63   0.009    -.6873216   -.0997303
                  |
          d_lnppi |   .0915477   .0167889     5.45   0.000      .058641    .1244543
            _cons |   .0247173   .0017586    14.06   0.000     .0212705    .0281641
-----------------------------------------------------------------------------------

.   est store m3 

.   reghdfe $y $x1 $x2 $x3  $c $f  $opt
(dropped 1698839 singleton observations)
(MWFE estimator converged in 10 iterations)

HDFE Linear regression                            Number of obs   =  9,097,877
Absorbing 2 HDFE groups                           F(   4,  28829) =      78.05
Statistics robust to heteroskedasticity           Prob > F        =     0.0000
                                                  R-squared       =     0.1512
                                                  Adj R-squared   =    -0.1185
                                                  Within R-sq.    =     0.0002
Number of clusters (origin_id#hs4) =     28,830   Root MSE        =     1.2544

                          (Std. err. adjusted for 28,830 clusters in origin_id#hs4)
-----------------------------------------------------------------------------------
                  |               Robust
        d_lnprice | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
------------------+----------------------------------------------------------------
            d_lne |    .238408   .0147261    16.19   0.000     .2095441    .2672718
          hhi_hs4 |    -.00225   .0185565    -0.12   0.903    -.0386215    .0341215
                  |
c.d_lne#c.hhi_hs4 |  -.4136731   .1176146    -3.52   0.000    -.6442031   -.1831431
                  |
          d_lnppi |  -.0371079   .0285003    -1.30   0.193    -.0929698     .018754
            _cons |   .0314054   .0007784    40.35   0.000     .0298797    .0329311
-----------------------------------------------------------------------------------

Absorbed degrees of freedom:
----------------------------------------------------------------+
            Absorbed FE | Categories  - Redundant  = Num. Coefs |
------------------------+---------------------------------------|
     hs4#origin_id#firm |   2193666     2193666           0    *|
                   year |        13           1          12     |
----------------------------------------------------------------+
* = FE nested within cluster; treated as redundant for DoF computation

.   est store m4

. 
.   // 为模型1添加固定效应标量（无固定效应）
.   estimates restore m1
(results m1 are active now)

.   estadd local fe_imp "NO"        // 使用字符串"NO"

added macro:
             e(fe_imp) : "NO"

.   estadd local fe_year "NO"       // 使用字符串"NO"

added macro:
            e(fe_year) : "NO"

.   estimates store m1

.   // 为模型2添加固定效应标量（有固定效应）
.   estimates restore m2  
(results m2 are active now)

.   estadd local fe_imp "YES"       // 使用字符串"YES"

added macro:
             e(fe_imp) : "YES"

.   estadd local fe_year "YES"      // 使用字符串"YES"

added macro:
            e(fe_year) : "YES"

.   estimates store m2

.   // 为模型3添加固定效应标量（无固定效应）
.   estimates restore m3
(results m3 are active now)

.   estadd local fe_imp "NO"        // 使用字符串"NO"

added macro:
             e(fe_imp) : "NO"

.   estadd local fe_year "NO"       // 使用字符串"NO"

added macro:
            e(fe_year) : "NO"

.   estimates store m3

.   // 为模型4添加固定效应标量（有固定效应）
.   estimates restore m4
(results m4 are active now)

.   estadd local fe_imp "YES"       // 使用字符串"YES"

added macro:
             e(fe_imp) : "YES"

.   estadd local fe_year "YES"      // 使用字符串"YES"

added macro:
            e(fe_year) : "YES"

.   estimates store m4

. 
.   local s "using $T/Table2_基准回归.csv"      //执行时包括这一行会输出Excel表格

.   local m "m1 m2 m3 m4"

.   esttab `m' `s', replace   ///
>          se(%6.3f) b(%6.3f)               ///
>          star(* 0.1 ** 0.05 *** 0.01)     ///
>          scalars("r2 R²" "N N") ///
>          stats(fe_imp fe_year r2 N, fmt(%s %s %6.3f %12.0f) ///
>          labels("Imp-Ind-Cty FE" "Year FE" "R²" "N")) ///
>          title(table2 baseline result)   ///
>          nogap compress 
(output written to /Users/yangyanjun/Desktop/exchangerate/提交版本/tables/Table2_基准回归.csv)

. 
. **#C.表3.机制检验  
. /*------------------------------------------------------------------------------
>  * 表3.机制检验
>  *------------------------------------------------------------------------------*/
. 
.   use "$W/final_data.dta", clear

.   xtset firm_origin_id_hs4 year

Panel variable: firm_origin_id_hs4 (unbalanced)
 Time variable: year, 2001 to 2013, but with gaps
         Delta: 1 unit

.   bys hs4 year :egen share=pc(value)

.   global y    "d_lnprice"                               //被解释变量

.   global x1   "d_lne"                                   //基本解释变量

.   global x2   "share"                                   //机制变量：企业进口份额

.   global x3   "c.d_lne#c.share"                         //交互项：汇率×进口份额

.   global c    "d_lnppi"                                 //基本控制变量  

.   global f    ", absorb(firm hs4 origin_id year)"       //固定效应：企业+产品+原产地+年份

.   global f1   ", absorb(firm#hs4#origin_id year)"       //固定效应：企业-产品-原产地+年份

.   global f2   ", absorb(hs4#origin_id firm#year)"       //固定效应产品-原产地+企业-年份

.   global opt "vce(cluster i.origin_id#i.hs4)"

. 
.   reghdfe $y $x1  $x2 $x3  $c, noabsorb $opt
(MWFE estimator converged in 1 iterations)

HDFE Linear regression                            Number of obs   = 10,796,716
Absorbing 1 HDFE group                            F(   4,  36169) =     179.79
Statistics robust to heteroskedasticity           Prob > F        =     0.0000
                                                  R-squared       =     0.0004
                                                  Adj R-squared   =     0.0004
                                                  Within R-sq.    =     0.0004
Number of clusters (origin_id#hs4) =     36,170   Root MSE        =     1.2324

                        (Std. err. adjusted for 36,170 clusters in origin_id#hs4)
---------------------------------------------------------------------------------
                |               Robust
      d_lnprice | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
----------------+----------------------------------------------------------------
          d_lne |     .24288   .0121333    20.02   0.000     .2190984    .2666616
          share |   .0039069    .000232    16.84   0.000     .0034522    .0043616
                |
c.d_lne#c.share |  -.0022899   .0019212    -1.19   0.233    -.0060555    .0014757
                |
        d_lnppi |   .0893421   .0169087     5.28   0.000     .0562006    .1224836
          _cons |   .0230568   .0015207    15.16   0.000     .0200761    .0260374
---------------------------------------------------------------------------------

.   est store m1

.   reghdfe $y $x1  $x2 $x3  $c  $f   $opt
(dropped 39743 singleton observations)
(MWFE estimator converged in 20 iterations)

HDFE Linear regression                            Number of obs   = 10,756,973
Absorbing 4 HDFE groups                           F(   4,  36005) =     173.21
Statistics robust to heteroskedasticity           Prob > F        =     0.0000
                                                  R-squared       =     0.0185
                                                  Adj R-squared   =     0.0009
                                                  Within R-sq.    =     0.0002
Number of clusters (origin_id#hs4) =     36,006   Root MSE        =     1.2317

                        (Std. err. adjusted for 36,006 clusters in origin_id#hs4)
---------------------------------------------------------------------------------
                |               Robust
      d_lnprice | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
----------------+----------------------------------------------------------------
          d_lne |   .2018629   .0121798    16.57   0.000     .1779902    .2257356
          share |   .0059868   .0003058    19.58   0.000     .0053875    .0065861
                |
c.d_lne#c.share |  -.0038132   .0017896    -2.13   0.033    -.0073209   -.0003055
                |
        d_lnppi |  -.0579375   .0249136    -2.33   0.020    -.1067688   -.0091061
          _cons |   .0254211   .0006804    37.36   0.000     .0240875    .0267547
---------------------------------------------------------------------------------

Absorbed degrees of freedom:
-----------------------------------------------------+
 Absorbed FE | Categories  - Redundant  = Num. Coefs |
-------------+---------------------------------------|
        firm |    188862           0      188862     |
         hs4 |      1136           2        1134     |
   origin_id |        98           1          97    ?|
        year |        13           1          12    ?|
-----------------------------------------------------+
? = number of redundant parameters may be higher

.   est store m2  

.   reghdfe $y $x1  $x2 $x3  $c  $f1  $opt
(dropped 1698839 singleton observations)
(MWFE estimator converged in 10 iterations)

HDFE Linear regression                            Number of obs   =  9,097,877
Absorbing 2 HDFE groups                           F(   4,  28829) =     153.54
Statistics robust to heteroskedasticity           Prob > F        =     0.0000
                                                  R-squared       =     0.1513
                                                  Adj R-squared   =    -0.1184
                                                  Within R-sq.    =     0.0003
Number of clusters (origin_id#hs4) =     28,830   Root MSE        =     1.2544

                        (Std. err. adjusted for 28,830 clusters in origin_id#hs4)
---------------------------------------------------------------------------------
                |               Robust
      d_lnprice | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
----------------+----------------------------------------------------------------
          d_lne |   .2272949   .0135639    16.76   0.000      .200709    .2538809
          share |   .0140184    .000774    18.11   0.000     .0125013    .0155355
                |
c.d_lne#c.share |   -.007228   .0024044    -3.01   0.003    -.0119407   -.0025153
                |
        d_lnppi |   -.037185   .0285169    -1.30   0.192    -.0930795    .0187096
          _cons |   .0293903   .0005761    51.02   0.000     .0282611    .0305194
---------------------------------------------------------------------------------

Absorbed degrees of freedom:
----------------------------------------------------------------+
            Absorbed FE | Categories  - Redundant  = Num. Coefs |
------------------------+---------------------------------------|
     firm#hs4#origin_id |   2193666     2193666           0    *|
                   year |        13           1          12     |
----------------------------------------------------------------+
* = FE nested within cluster; treated as redundant for DoF computation

.   est store m3 

.   reghdfe $y $x1  $x2 $x3  $c  $f2  $opt
(dropped 253555 singleton observations)
(MWFE estimator converged in 35 iterations)

HDFE Linear regression                            Number of obs   = 10,543,161
Absorbing 2 HDFE groups                           F(   4,  31137) =     148.56
Statistics robust to heteroskedasticity           Prob > F        =     0.0000
                                                  R-squared       =     0.0792
                                                  Adj R-squared   =     0.0122
                                                  Within R-sq.    =     0.0001
Number of clusters (origin_id#hs4) =     31,138   Root MSE        =     1.2274

                        (Std. err. adjusted for 31,138 clusters in origin_id#hs4)
---------------------------------------------------------------------------------
                |               Robust
      d_lnprice | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
----------------+----------------------------------------------------------------
          d_lne |   .1120686   .0087214    12.85   0.000     .0949743    .1291629
          share |   .0069935    .000353    19.81   0.000     .0063017    .0076854
                |
c.d_lne#c.share |  -.0064812   .0019609    -3.31   0.001    -.0103246   -.0026378
                |
        d_lnppi |  -.0766314   .0223259    -3.43   0.001    -.1203911   -.0328717
          _cons |   .0248605   .0004386    56.69   0.000     .0240009    .0257201
---------------------------------------------------------------------------------

Absorbed degrees of freedom:
---------------------------------------------------------+
     Absorbed FE | Categories  - Redundant  = Num. Coefs |
-----------------+---------------------------------------|
   hs4#origin_id |     31138       31138           0    *|
       firm#year |    684433           1      684432     |
---------------------------------------------------------+
* = FE nested within cluster; treated as redundant for DoF computation

.   est store m4

. 
.   // 为模型2添加固定效应标识
.   estimates restore m1
(results m1 are active now)

.   estadd local fe_info "NO"

added macro:
            e(fe_info) : "NO"

.   estimates store m1

.   // 为模型2添加固定效应标识
.   estimates restore m2  
(results m2 are active now)

.   estadd local fe_info "YES"

added macro:
            e(fe_info) : "YES"

.   estimates store m2

.   // 为模型3添加固定效应标识
.   estimates restore m3
(results m3 are active now)

.   estadd local fe_info "YES"

added macro:
            e(fe_info) : "YES"

.   estimates store m3

.   // 为模型4添加固定效应标识
.   estimates restore m4
(results m4 are active now)

.   estadd local fe_info "YES"

added macro:
            e(fe_info) : "YES"

.   estimates store m4

. 
.   local s "using $T/Table3_机制检验.csv"      //执行时包括这一行会输出Excel表格

.   local m "m1 m2 m3 m4"

.   esttab `m' `s', replace   ///
>          se(%6.3f) b(%6.3f)               ///
>          star(* 0.1 ** 0.05 *** 0.01)     ///
>          scalars("r2 R²" "N N")    ///
>          title(table3 Mechanism Testing)  ///
>          nogap compress
(output written to /Users/yangyanjun/Desktop/exchangerate/提交版本/tables/Table3_机制检验.csv)

. 
. **#D.表4.异质性分析
. /*------------------------------------------------------------------------------
>  * 表4(1)(2)列：区分中间品和最终品
>  *------------------------------------------------------------------------------*/
. 
.   use "$W/final_data.dta", clear

.   xtset firm_origin_id_hs4 year 

Panel variable: firm_origin_id_hs4 (unbalanced)
 Time variable: year, 2001 to 2013, but with gaps
         Delta: 1 unit

.   tostring hs6,replace  
hs6 was long now str6

.   merge m:1 hs6 using "$R/hs6 to bec.dta"  

    Result                      Number of obs
    -----------------------------------------
    Not matched                       630,923
        from master                   629,837  (_merge==1)
        from using                      1,086  (_merge==2)

    Matched                        10,166,879  (_merge==3)
    -----------------------------------------

.   drop if _merge==2
(1,086 observations deleted)

.   drop hs61 bec1 _merge

.   inlist2 bec, values(111, 121, 21, 22, 31, 322, 42 , 53) name(中间品)
(4,093 real changes made)
(16,187 real changes made)
(197,871 real changes made)
(4,887,551 real changes made)
(3,608 real changes made)
(59,342 real changes made)
(0 real changes made)
(138,961 real changes made)

.   destring  hs6 ,replace 
hs6: all characters numeric; replaced as long

.   global y    "d_lnprice"                             //被解释变量

.   global x1   "d_lne"                                 //基本解释变量

.   global x2   "hhi_hs4"                               //基本解释变量

.   global x3   "c.d_lne#c.hhi_hs4"                     //基本解释变量(主要观测)）

.   global c    "d_lnppi"                               //基本控制变量  

.   global f    ", absorb(firm#hs4#origin_id year)"     //固定效应:个体(企业-产品-原产地层面)与年份固
> 定

.   global opt "vce(cluster i.origin_id#i.hs4)"

.   replace 中间品 = 0 if 中间品==.
(5,489,103 real changes made)

. 
.   
.   reghdfe $y $x1  $x2 $x3  $c if 中间品==1 $f  $opt
(dropped 785091 singleton observations)
(MWFE estimator converged in 10 iterations)

HDFE Linear regression                            Number of obs   =  4,522,522
Absorbing 2 HDFE groups                           F(   4,  15412) =      54.48
Statistics robust to heteroskedasticity           Prob > F        =     0.0000
                                                  R-squared       =     0.1593
                                                  Adj R-squared   =    -0.1033
                                                  Within R-sq.    =     0.0005
Number of clusters (origin_id#hs4) =     15,413   Root MSE        =     0.8661

                          (Std. err. adjusted for 15,413 clusters in origin_id#hs4)
-----------------------------------------------------------------------------------
                  |               Robust
        d_lnprice | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
------------------+----------------------------------------------------------------
            d_lne |    .284777   .0199858    14.25   0.000     .2456026    .3239514
          hhi_hs4 |   .0052915   .0218307     0.24   0.808    -.0374992    .0480821
                  |
c.d_lne#c.hhi_hs4 |  -.4944091   .2017537    -2.45   0.014    -.8898701   -.0989481
                  |
          d_lnppi |    .110747   .0370743     2.99   0.003      .038077    .1834171
            _cons |   .0377885   .0010537    35.86   0.000     .0357232    .0398539
-----------------------------------------------------------------------------------

Absorbed degrees of freedom:
----------------------------------------------------------------+
            Absorbed FE | Categories  - Redundant  = Num. Coefs |
------------------------+---------------------------------------|
     firm#hs4#origin_id |   1076413     1076413           0    *|
                   year |        13           1          12     |
----------------------------------------------------------------+
* = FE nested within cluster; treated as redundant for DoF computation

.   estadd local FE "YES", replace

added macro:
                 e(FE) : "YES"

.   est store m1    

.   reghdfe $y $x1  $x2 $x3  $c if 中间品==0 $f  $opt
(dropped 947854 singleton observations)
(MWFE estimator converged in 10 iterations)

HDFE Linear regression                            Number of obs   =  4,541,249
Absorbing 2 HDFE groups                           F(   4,  14787) =      33.63
Statistics robust to heteroskedasticity           Prob > F        =     0.0000
                                                  R-squared       =     0.1508
                                                  Adj R-squared   =    -0.1280
                                                  Within R-sq.    =     0.0001
Number of clusters (origin_id#hs4) =     14,788   Root MSE        =     1.5487

                          (Std. err. adjusted for 14,788 clusters in origin_id#hs4)
-----------------------------------------------------------------------------------
                  |               Robust
        d_lnprice | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
------------------+----------------------------------------------------------------
            d_lne |    .206987   .0196947    10.51   0.000     .1683829    .2455911
          hhi_hs4 |  -.0814186   .0349911    -2.33   0.020    -.1500056   -.0128317
                  |
c.d_lne#c.hhi_hs4 |  -.4235291   .1243269    -3.41   0.001    -.6672253    -.179833
                  |
          d_lnppi |  -.1350301   .0421696    -3.20   0.001    -.2176878   -.0523724
            _cons |   .0254792   .0011408    22.34   0.000     .0232431    .0277152
-----------------------------------------------------------------------------------

Absorbed degrees of freedom:
----------------------------------------------------------------+
            Absorbed FE | Categories  - Redundant  = Num. Coefs |
------------------------+---------------------------------------|
     firm#hs4#origin_id |   1122299     1122299           0    *|
                   year |        13           1          12     |
----------------------------------------------------------------+
* = FE nested within cluster; treated as redundant for DoF computation

.   estadd local FE "YES", replace

added macro:
                 e(FE) : "YES"

.   est store m2

.   
.   //chowtest
.   qui reghdfe $y $x1 $x2 $x3 $c i.中间品#$x3  $f vce(r)

.   test 1.中间品#c.d_lne#c.hhi_hs4 = 0

 ( 1)  1.中间品#c.d_lne#c.hhi_hs4 = 0

       F(  1,6904194) =    4.23
            Prob > F =    0.0398

. 
. /*------------------------------------------------------------------------------
>  * 表4(3)(4)列：区分企业
>  *------------------------------------------------------------------------------*/
.   use "$W/final_data.dta", clear

.   xtset firm_origin_id_hs4 year

Panel variable: firm_origin_id_hs4 (unbalanced)
 Time variable: year, 2001 to 2013, but with gaps
         Delta: 1 unit

.   merge m:1 party_id using "$D/企业代码及类型.dta"
(variable party_id was str11, now str20 to accommodate using data's values)

    Result                      Number of obs
    -----------------------------------------
    Not matched                       436,395
        from master                     4,531  (_merge==1)
        from using                    431,864  (_merge==2)

    Matched                        10,792,185  (_merge==3)
    -----------------------------------------

.   drop if _merge ==1 | _merge ==2
(436,395 observations deleted)

.   drop _merge

.   xtset firm_origin_id_hs4 year 

Panel variable: firm_origin_id_hs4 (unbalanced)
 Time variable: year, 2001 to 2013, but with gaps
         Delta: 1 unit

.   global y    "d_lnprice"                                //被解释变量

.   global x1   "d_lne"                                    //基本解释变量

.   global x2   "hhi_hs4"                                  //基本解释变量

.   global x3   "c.d_lne#c.hhi_hs4"                        //基本解释变量(主要观测)     

.   global c    "d_lnppi"                                  //基本控制变量  

.   global i    "if types =="0""                           //即进口又出口企业

.   global i1   "if types =="1""                           //内销型企业

.   global f   ", absorb(hs4#origin_id year)"         //固定效应:个体(企业-产品-原产地层面)与年份固定

.   global opt "vce(cluster i.origin_id#i.hs4)"

. 
.   reghdfe $y $x1 $x2 $x3  $c $i1  $f  $opt
(dropped 3830 singleton observations)
(MWFE estimator converged in 6 iterations)

HDFE Linear regression                            Number of obs   =    651,354
Absorbing 2 HDFE groups                           F(   4,  15211) =      24.90
Statistics robust to heteroskedasticity           Prob > F        =     0.0000
                                                  R-squared       =     0.0192
                                                  Adj R-squared   =    -0.0042
                                                  Within R-sq.    =     0.0002
Number of clusters (origin_id#hs4) =     15,212   Root MSE        =     1.1724

                          (Std. err. adjusted for 15,212 clusters in origin_id#hs4)
-----------------------------------------------------------------------------------
                  |               Robust
        d_lnprice | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
------------------+----------------------------------------------------------------
            d_lne |   .2323452   .0255626     9.09   0.000     .1822395    .2824509
          hhi_hs4 |  -.0012571   .0317063    -0.04   0.968    -.0634053    .0608912
                  |
c.d_lne#c.hhi_hs4 |  -.6584868   .2671312    -2.47   0.014    -1.182096   -.1348775
                  |
          d_lnppi |  -.0009141   .0613955    -0.01   0.988    -.1212565    .1194284
            _cons |   .0170343   .0016668    10.22   0.000     .0137671    .0203014
-----------------------------------------------------------------------------------

Absorbed degrees of freedom:
---------------------------------------------------------+
     Absorbed FE | Categories  - Redundant  = Num. Coefs |
-----------------+---------------------------------------|
   hs4#origin_id |     15212       15212           0    *|
            year |        13           1          12     |
---------------------------------------------------------+
* = FE nested within cluster; treated as redundant for DoF computation

.   estadd local FE "YES", replace

added macro:
                 e(FE) : "YES"

.   est store m3

.   reghdfe $y $x1 $x2 $x3  $c $i $f  $opt
(dropped 4584 singleton observations)
(MWFE estimator converged in 5 iterations)

HDFE Linear regression                            Number of obs   = 10,132,417
Absorbing 2 HDFE groups                           F(   4,  30773) =      83.32
Statistics robust to heteroskedasticity           Prob > F        =     0.0000
                                                  R-squared       =     0.0043
                                                  Adj R-squared   =     0.0013
                                                  Within R-sq.    =     0.0002
Number of clusters (origin_id#hs4) =     30,774   Root MSE        =     1.2360

                          (Std. err. adjusted for 30,774 clusters in origin_id#hs4)
-----------------------------------------------------------------------------------
                  |               Robust
        d_lnprice | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
------------------+----------------------------------------------------------------
            d_lne |   .2278091   .0133652    17.04   0.000     .2016127    .2540055
          hhi_hs4 |   .0037521   .0157905     0.24   0.812    -.0271978    .0347021
                  |
c.d_lne#c.hhi_hs4 |  -.4600487   .1354445    -3.40   0.001    -.7255255   -.1945719
                  |
          d_lnppi |  -.0352599   .0261759    -1.35   0.178    -.0865658     .016046
            _cons |   .0260774   .0006812    38.28   0.000     .0247423    .0274125
-----------------------------------------------------------------------------------

Absorbed degrees of freedom:
---------------------------------------------------------+
     Absorbed FE | Categories  - Redundant  = Num. Coefs |
-----------------+---------------------------------------|
   hs4#origin_id |     30774       30774           0    *|
            year |        13           1          12     |
---------------------------------------------------------+
* = FE nested within cluster; treated as redundant for DoF computation

.   estadd local FE "YES", replace

added macro:
                 e(FE) : "YES"

.   est store m4

.   local s "using $T/Table4_异质性分析.csv"   

.   local m "m1 m2 m3 m4"

.   esttab `m' `s', replace ///
>          se(%6.3f) b(%6.3f)               ///
>          star(* 0.1 ** 0.05 *** 0.01)     ///
>          stats(FE r2 N,   ///
>          fmt(%3s %3s %9.3f %12.0f) ///
>              labels("FE" "R²" "N"))  ///
>          title("table4 Product and Company Differentiation")    ///
>          mtitle("中间品" "最终品" "内销型企业" "进出口企业")  ///
>          nogap compress
(output written to /Users/yangyanjun/Desktop/exchangerate/提交版本/tables/Table4_异质性分析.csv)

.   
.   //chowtest
.   destring types,gen(type)
types: all characters numeric; type generated as byte

.   qui reghdfe $y $x1 $x2 $x3 $c i.type#$x3 $f vce(r)

.   test 1.type#c.d_lne#c.hhi_hs4 = 0 

 ( 1)  1.type#c.d_lne#c.hhi_hs4 = 0

       F(  1,10756001) =    7.82
            Prob > F =    0.0052

. 
. **#E.附录III 表
. /*------------------------------------------------------------------------------
>  * 附录III 表1 
>  *------------------------------------------------------------------------------*/
. 
.   use "$W/final_data.dta", clear

.   xtset firm_origin_id_hs4 year

Panel variable: firm_origin_id_hs4 (unbalanced)
 Time variable: year, 2001 to 2013, but with gaps
         Delta: 1 unit

.   merge m:1 year hs4 using "$D/国际竞争hhi指标_hs4.dta"   
(variable hs4 was int, now float to accommodate using data's values)

    Result                      Number of obs
    -----------------------------------------
    Not matched                         3,669
        from master                       377  (_merge==1)
        from using                      3,292  (_merge==2)

    Matched                        10,796,339  (_merge==3)
    -----------------------------------------

.   keep if _merge == 3
(3,669 observations deleted)

.   drop _merge

.   global y    "d_lnprice"                                  

.   global x1   "d_lne"                                      

.   global x2   "hhi_hs4"                                  

.   global x3   "c.d_lne#c.hhi_hs4"                               

.   global x4   "HHI_kt"                                     // 全球进口商竞争度指标

.   global x5   "c.d_lne#c.HHI_kt"                           // 全球HHI与汇率的交互项

.   global c    "d_lnppi"                                      

.   global f    ", absorb(hs4#origin_id#firm year)"            

.   global opt  "vce(cluster i.origin_id#i.hs4)"

. 
.   reghdfe $y $x1         $x4 $x5 $c $f $opt
(dropped 1698731 singleton observations)
(MWFE estimator converged in 10 iterations)

HDFE Linear regression                            Number of obs   =  9,097,608
Absorbing 2 HDFE groups                           F(   4,  28813) =      78.16
Statistics robust to heteroskedasticity           Prob > F        =     0.0000
                                                  R-squared       =     0.1512
                                                  Adj R-squared   =    -0.1185
                                                  Within R-sq.    =     0.0002
Number of clusters (origin_id#hs4) =     28,814   Root MSE        =     1.2544

                         (Std. err. adjusted for 28,814 clusters in origin_id#hs4)
----------------------------------------------------------------------------------
                 |               Robust
       d_lnprice | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-----------------+----------------------------------------------------------------
           d_lne |    .221173   .0204775    10.80   0.000     .1810362    .2613099
          HHI_kt |  -.1784961   .0818087    -2.18   0.029    -.3388451   -.0181472
                 |
c.d_lne#c.HHI_kt |   .0908155   .2886481     0.31   0.753    -.4749482    .6565792
                 |
         d_lnppi |  -.0378483   .0284402    -1.33   0.183    -.0935925    .0178958
           _cons |   .0413725   .0046011     8.99   0.000     .0323542    .0503908
----------------------------------------------------------------------------------

Absorbed degrees of freedom:
----------------------------------------------------------------+
            Absorbed FE | Categories  - Redundant  = Num. Coefs |
------------------------+---------------------------------------|
     hs4#origin_id#firm |   2193532     2193532           0    *|
                   year |        13           1          12     |
----------------------------------------------------------------+
* = FE nested within cluster; treated as redundant for DoF computation

.   estadd local Year_FE "YES", replace

added macro:
            e(Year_FE) : "YES"

.   estadd local Ind_Cty_FE "YES", replace

added macro:
         e(Ind_Cty_FE) : "YES"

.   est store m1 

.   reghdfe $y $x1 $x2 $x3 $x4 $x5 $c ,noabsorb  $opt
(MWFE estimator converged in 1 iterations)

HDFE Linear regression                            Number of obs   = 10,796,339
Absorbing 1 HDFE group                            F(   6,  36149) =      85.05
Statistics robust to heteroskedasticity           Prob > F        =     0.0000
                                                  R-squared       =     0.0003
                                                  Adj R-squared   =     0.0003
                                                  Within R-sq.    =     0.0003
Number of clusters (origin_id#hs4) =     36,150   Root MSE        =     1.2325

                          (Std. err. adjusted for 36,150 clusters in origin_id#hs4)
-----------------------------------------------------------------------------------
                  |               Robust
        d_lnprice | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
------------------+----------------------------------------------------------------
            d_lne |    .262702   .0183044    14.35   0.000     .2268248    .2985793
          hhi_hs4 |   -.039724   .0131433    -3.02   0.003    -.0654853   -.0139627
                  |
c.d_lne#c.hhi_hs4 |  -.3772459   .1423301    -2.65   0.008    -.6562171   -.0982746
                  |
           HHI_kt |  -.0196101   .0228862    -0.86   0.392    -.0644677    .0252476
                  |
 c.d_lne#c.HHI_kt |  -.1292213   .2456232    -0.53   0.599      -.61065    .3522074
                  |
          d_lnppi |   .0920786   .0167398     5.50   0.000     .0592681    .1248892
            _cons |   .0257634    .002207    11.67   0.000     .0214376    .0300892
-----------------------------------------------------------------------------------

.   estadd local Year_FE "NO", replace

added macro:
            e(Year_FE) : "NO"

.   estadd local Ind_Cty_FE "NO", replace

added macro:
         e(Ind_Cty_FE) : "NO"

.   est store m2 

.   reghdfe $y $x1 $x2 $x3 $x4 $x5 $c $f $opt
(dropped 1698731 singleton observations)
(MWFE estimator converged in 10 iterations)

HDFE Linear regression                            Number of obs   =  9,097,608
Absorbing 2 HDFE groups                           F(   6,  28813) =      52.55
Statistics robust to heteroskedasticity           Prob > F        =     0.0000
                                                  R-squared       =     0.1512
                                                  Adj R-squared   =    -0.1185
                                                  Within R-sq.    =     0.0002
Number of clusters (origin_id#hs4) =     28,814   Root MSE        =     1.2544

                          (Std. err. adjusted for 28,814 clusters in origin_id#hs4)
-----------------------------------------------------------------------------------
                  |               Robust
        d_lnprice | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
------------------+----------------------------------------------------------------
            d_lne |   .2258466   .0209199    10.80   0.000     .1848426    .2668505
          hhi_hs4 |  -.0072431   .0186479    -0.39   0.698    -.0437939    .0293077
                  |
c.d_lne#c.hhi_hs4 |  -.4335261   .1201337    -3.61   0.000    -.6689938   -.1980584
                  |
           HHI_kt |  -.1725431   .0819309    -2.11   0.035    -.3331315   -.0119548
                  |
 c.d_lne#c.HHI_kt |   .2265511   .2936825     0.77   0.440    -.3490801    .8021824
                  |
          d_lnppi |  -.0385412   .0284438    -1.35   0.175    -.0942923    .0172099
            _cons |     .04127   .0046789     8.82   0.000     .0320992    .0504408
-----------------------------------------------------------------------------------

Absorbed degrees of freedom:
----------------------------------------------------------------+
            Absorbed FE | Categories  - Redundant  = Num. Coefs |
------------------------+---------------------------------------|
     hs4#origin_id#firm |   2193532     2193532           0    *|
                   year |        13           1          12     |
----------------------------------------------------------------+
* = FE nested within cluster; treated as redundant for DoF computation

.   estadd local Year_FE "YES", replace

added macro:
            e(Year_FE) : "YES"

.   estadd local Ind_Cty_FE "YES", replace

added macro:
         e(Ind_Cty_FE) : "YES"

.   est store m3 

.   //增加替代指标检验
.   use "$W/final_data_hs6.dta", clear

.   merge m:1 year hs6 using "$D/国际竞争hhi指标.dta"       
(variable hs6 was long, now double to accommodate using data's values)

    Result                      Number of obs
    -----------------------------------------
    Not matched                        17,941
        from master                       377  (_merge==1)
        from using                     17,564  (_merge==2)

    Matched                        12,721,985  (_merge==3)
    -----------------------------------------

.   keep if _merge == 3
(17,941 observations deleted)

.   drop _merge

.   global y    "d_lnprice"                               

.   global x1   "d_lne"                                 

.   global x2   "hhi_hs6"

.   global x3   "c.d_lne#c.hhi_hs6"                     

.   global x4   "HHI_kt"                          // 全球进口商竞争度指标

.   global x5   "c.d_lne#c.HHI_kt"                // 全球HHI与汇率的交互项

.   global c    "d_lnppi"                                

.   global f1    ", absorb(hs6#origin_id)"            

.   global f   ", absorb(hs6#origin_id#firm year)"   

.   global opt  "vce(cluster i.origin_id#i.hs6 )"

. 
.   reghdfe $y $x1         $x4 $x5 $c $f $opt
(dropped 2298947 singleton observations)
(MWFE estimator converged in 10 iterations)

HDFE Linear regression                            Number of obs   = 10,423,038
Absorbing 2 HDFE groups                           F(   4,  75505) =     155.21
Statistics robust to heteroskedasticity           Prob > F        =     0.0000
                                                  R-squared       =     0.1624
                                                  Adj R-squared   =    -0.1226
                                                  Within R-sq.    =     0.0003
Number of clusters (origin_id#hs6) =     75,506   Root MSE        =     1.0578

                         (Std. err. adjusted for 75,506 clusters in origin_id#hs6)
----------------------------------------------------------------------------------
                 |               Robust
       d_lnprice | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-----------------+----------------------------------------------------------------
           d_lne |   .2122342   .0151367    14.02   0.000     .1825663     .241902
          HHI_kt |  -.0738207   .0312893    -2.36   0.018    -.1351475   -.0124939
                 |
c.d_lne#c.HHI_kt |   .2726809   .1724395     1.58   0.114    -.0652997    .6106614
                 |
         d_lnppi |  -.0270109   .0212076    -1.27   0.203    -.0685777    .0145559
           _cons |   .0409738   .0021317    19.22   0.000     .0367957    .0451518
----------------------------------------------------------------------------------

Absorbed degrees of freedom:
----------------------------------------------------------------+
            Absorbed FE | Categories  - Redundant  = Num. Coefs |
------------------------+---------------------------------------|
     hs6#origin_id#firm |   2646534     2646534           0    *|
                   year |        13           1          12     |
----------------------------------------------------------------+
* = FE nested within cluster; treated as redundant for DoF computation

.   estadd local Year_FE "YES", replace

added macro:
            e(Year_FE) : "YES"

.   estadd local Ind_Cty_FE "YES", replace

added macro:
         e(Ind_Cty_FE) : "YES"

.   est store m4

.   reghdfe $y $x1 $x2 $x3 $x4 $x5 $c ,noabsorb  $opt
(MWFE estimator converged in 1 iterations)

HDFE Linear regression                            Number of obs   = 12,721,985
Absorbing 1 HDFE group                            F(   6, 100442) =     184.72
Statistics robust to heteroskedasticity           Prob > F        =     0.0000
                                                  R-squared       =     0.0005
                                                  Adj R-squared   =     0.0005
                                                  Within R-sq.    =     0.0005
Number of clusters (origin_id#hs6) =    100,443   Root MSE        =     1.0411

                         (Std. err. adjusted for 100,443 clusters in origin_id#hs6)
-----------------------------------------------------------------------------------
                  |               Robust
        d_lnprice | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
------------------+----------------------------------------------------------------
            d_lne |   .2534542   .0139261    18.20   0.000     .2261591    .2807492
          hhi_hs6 |  -.0627653   .0050555   -12.42   0.000     -.072674   -.0528567
                  |
c.d_lne#c.hhi_hs6 |   -.122694    .059494    -2.06   0.039    -.2393014   -.0060865
                  |
           HHI_kt |  -.0429378   .0109778    -3.91   0.000    -.0644541   -.0214214
                  |
 c.d_lne#c.HHI_kt |   .0018401   .1569522     0.01   0.991    -.3057842    .3094644
                  |
          d_lnppi |   .0761958   .0113872     6.69   0.000     .0538771    .0985145
            _cons |   .0370453     .00125    29.64   0.000     .0345954    .0394952
-----------------------------------------------------------------------------------

.   estadd local Year_FE "NO", replace

added macro:
            e(Year_FE) : "NO"

.   estadd local Ind_Cty_FE "NO", replace

added macro:
         e(Ind_Cty_FE) : "NO"

.   est store m5 

.   reghdfe $y $x1 $x2 $x3 $x4 $x5 $c $f $opt
(dropped 2298947 singleton observations)
(MWFE estimator converged in 10 iterations)

HDFE Linear regression                            Number of obs   = 10,423,038
Absorbing 2 HDFE groups                           F(   6,  75505) =     105.80
Statistics robust to heteroskedasticity           Prob > F        =     0.0000
                                                  R-squared       =     0.1624
                                                  Adj R-squared   =    -0.1226
                                                  Within R-sq.    =     0.0003
Number of clusters (origin_id#hs6) =     75,506   Root MSE        =     1.0578

                          (Std. err. adjusted for 75,506 clusters in origin_id#hs6)
-----------------------------------------------------------------------------------
                  |               Robust
        d_lnprice | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
------------------+----------------------------------------------------------------
            d_lne |   .2203407   .0155971    14.13   0.000     .1897705    .2509109
          hhi_hs6 |  -.0227372   .0089388    -2.54   0.011    -.0402572   -.0052173
                  |
c.d_lne#c.hhi_hs6 |  -.2604437   .0610915    -4.26   0.000    -.3801828   -.1407047
                  |
           HHI_kt |  -.0722909   .0312921    -2.31   0.021    -.1336233   -.0109586
                  |
 c.d_lne#c.HHI_kt |   .3486736   .1706984     2.04   0.041     .0141056    .6832417
                  |
          d_lnppi |  -.0272666   .0211901    -1.29   0.198    -.0687992     .014266
            _cons |   .0421046   .0021989    19.15   0.000     .0377948    .0464143
-----------------------------------------------------------------------------------

Absorbed degrees of freedom:
----------------------------------------------------------------+
            Absorbed FE | Categories  - Redundant  = Num. Coefs |
------------------------+---------------------------------------|
     hs6#origin_id#firm |   2646534     2646534           0    *|
                   year |        13           1          12     |
----------------------------------------------------------------+
* = FE nested within cluster; treated as redundant for DoF computation

.   estadd local Year_FE "YES", replace

added macro:
            e(Year_FE) : "YES"

.   estadd local Ind_Cty_FE "YES", replace

added macro:
         e(Ind_Cty_FE) : "YES"

.   est store m6 

. 
.   local s "using $T/TableII_1.csv"      

.   local m "m1 m2 m3 m4 m5 m6"

.   esttab `m' `s', nogap compress replace ///
>     se(%6.3f) b(%6.3f) ///
>     star(* 0.1 ** 0.05 *** 0.01) ///
>     stats(Year_FE Ind_Cty_FE r2 N, ///
>         fmt(%3s %3s %9.3f %12.0f) ///
>         labels("Year FE" "Ind-Cty FE" "R²" "N")) ///
>     title(table TableII_1)
(output written to /Users/yangyanjun/Desktop/exchangerate/提交版本/tables/TableII_1.csv)

. 
. **#F.附录V 
. /*------------------------------------------------------------------------------
>  * 附录V 表A 1 第(1)列:行业平均的hhi指数
>  *------------------------------------------------------------------------------*/
. 
.   use "$W/final_data.dta", clear

.   merge m:1 hs4 using "$W/赫芬达尔指数_hs4_平均.dta"    

    Result                      Number of obs
    -----------------------------------------
    Not matched                           199
        from master                         0  (_merge==1)
        from using                        199  (_merge==2)

    Matched                        10,796,716  (_merge==3)
    -----------------------------------------

.   drop if _merge==2
(199 observations deleted)

.   drop _merge

.   xtset firm_origin_id_hs4 year    

Panel variable: firm_origin_id_hs4 (unbalanced)
 Time variable: year, 2001 to 2013, but with gaps
         Delta: 1 unit

.   global y    "d_lnprice"                              //被解释变量

.   global x1   "d_lne"                                  //基本解释变量               

.   global x2   "hhi_hs4_avg"                            //基本解释变量(主要观测)

.   global x3   "c.d_lne#c.hhi_hs4_avg"                  

.   global c    "d_lnppi"                                                    

.   global f   ", absorb(firm#origin_id year)"                    

.   global opt "vce(cluster i.origin_id#i.hs4)"

.   reghdfe $y $x1 $x2 $x3  $c $f $opt
(dropped 259020 singleton observations)
(MWFE estimator converged in 9 iterations)

HDFE Linear regression                            Number of obs   = 10,537,696
Absorbing 2 HDFE groups                           F(   4,  34154) =      94.37
Statistics robust to heteroskedasticity           Prob > F        =     0.0000
                                                  R-squared       =     0.0405
                                                  Adj R-squared   =    -0.0181
                                                  Within R-sq.    =     0.0002
Number of clusters (origin_id#hs4) =     34,155   Root MSE        =     1.2454

                              (Std. err. adjusted for 34,155 clusters in origin_id#hs4)
---------------------------------------------------------------------------------------
                      |               Robust
            d_lnprice | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
----------------------+----------------------------------------------------------------
                d_lne |   .2343475   .0150388    15.58   0.000      .204871     .263824
          hhi_hs4_avg |  -.0567274   .0144638    -3.92   0.000    -.0850769    -.028378
                      |
c.d_lne#c.hhi_hs4_avg |  -.2560892   .1361203    -1.88   0.060    -.5228895    .0107112
                      |
              d_lnppi |  -.0521244   .0271615    -1.92   0.055    -.1053619    .0011131
                _cons |   .0291102   .0016109    18.07   0.000     .0259527    .0322677
---------------------------------------------------------------------------------------

Absorbed degrees of freedom:
----------------------------------------------------------+
      Absorbed FE | Categories  - Redundant  = Num. Coefs |
------------------+---------------------------------------|
   firm#origin_id |    606306           0      606306     |
             year |        13           1          12     |
----------------------------------------------------------+

.   est store m1  

.   
.   outreg2 m1 using "$T/TableIII_1_第(1)列.doc", replace ///
>     keep($x1 $x2 $x3) ///
>     bdec(3) sdec(3) ///
>     bracket ///
>     nocons ///
>     addtext(Imp-Cty FE, YES, Year FE, YES)    ///
>     title("tableIII_1_(1)")
/Users/yangyanjun/Desktop/exchangerate/提交版本/tables/TableIII_1_第(1)列.doc
dir : seeout

. 
. /*------------------------------------------------------------------------------
>  * 附录V 表A 1 第(2)列:使用6位HS编码计算
>  *------------------------------------------------------------------------------*/
. 
.   use "$W/final_data_hs6.dta", clear 

.   global y    "d_lnprice"                              //被解释变量

.   global x1   "d_lne"                                  //基本解释变量               

.   global x2   "hhi_hs6"                            //基本解释变量(主要观测)

.   global x3   "c.d_lne#c.hhi_hs6"                       

.   global c    "d_lnppi"                                                    

.   global f   ", absorb(hs6#origin_id#firm year)"               

.   global opt "vce(cluster i.origin_id#i.hs6)"

. 
.   reghdfe $y $x1 $x2 $x3  $c $f $opt
(dropped 2299055 singleton observations)
(MWFE estimator converged in 10 iterations)

HDFE Linear regression                            Number of obs   = 10,423,307
Absorbing 2 HDFE groups                           F(   4,  75521) =     160.12
Statistics robust to heteroskedasticity           Prob > F        =     0.0000
                                                  R-squared       =     0.1624
                                                  Adj R-squared   =    -0.1226
                                                  Within R-sq.    =     0.0003
Number of clusters (origin_id#hs6) =     75,522   Root MSE        =     1.0578

                          (Std. err. adjusted for 75,522 clusters in origin_id#hs6)
-----------------------------------------------------------------------------------
                  |               Robust
        d_lnprice | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
------------------+----------------------------------------------------------------
            d_lne |   .2426588   .0109251    22.21   0.000     .2212456     .264072
          hhi_hs6 |  -.0211402   .0089414    -2.36   0.018    -.0386653    -.003615
                  |
c.d_lne#c.hhi_hs6 |   -.237041   .0601083    -3.94   0.000     -.354853   -.1192291
                  |
          d_lnppi |  -.0256416   .0212339    -1.21   0.227      -.06726    .0159768
            _cons |   .0371796   .0006585    56.46   0.000      .035889    .0384703
-----------------------------------------------------------------------------------

Absorbed degrees of freedom:
----------------------------------------------------------------+
            Absorbed FE | Categories  - Redundant  = Num. Coefs |
------------------------+---------------------------------------|
     hs6#origin_id#firm |   2646668     2646668           0    *|
                   year |        13           1          12     |
----------------------------------------------------------------+
* = FE nested within cluster; treated as redundant for DoF computation

.   est store m1  

.   
.   outreg2 m1 using "$T/TableIII_1_第(2)列.doc", replace ///
>     keep($x1 $x2 $x3) ///
>     bdec(3) sdec(3) ///
>     bracket ///
>     nocons ///
>     addtext(Imp-Ind-Cty FE, YES, Year FE, YES)    ///
>     title("tableIII_1_(2)")
/Users/yangyanjun/Desktop/exchangerate/提交版本/tables/TableIII_1_第(2)列.doc
dir : seeout

. 
. /*------------------------------------------------------------------------------
>  * 附录V 表A 1 第(3)列:使用8位HS编码计算
>  *------------------------------------------------------------------------------*/
. 
.   use "$W/final_data_hs8.dta", clear

.   global y    "d_lnprice"                              //被解释变量

.   global x1   "d_lne"                                  //基本解释变量               

.   global x2   "hhi_hs8"                            //基本解释变量(主要观测)

.   global x3   "c.d_lne#c.hhi_hs8"                       

.   global c    "d_lnppi"                                                    

.   global f   ", absorb(hs8#origin_id#firm year)"               

.   global opt "vce(cluster i.origin_id#i.hs8)"

. 
.   reghdfe $y $x1 $x2 $x3  $c $f $opt
(dropped 2525827 singleton observations)
(MWFE estimator converged in 11 iterations)

HDFE Linear regression                            Number of obs   = 10,281,605
Absorbing 2 HDFE groups                           F(   4, 100242) =     186.65
Statistics robust to heteroskedasticity           Prob > F        =     0.0000
                                                  R-squared       =     0.1716
                                                  Adj R-squared   =    -0.1271
                                                  Within R-sq.    =     0.0003
Number of clusters (origin_id#hs8) =    100,243   Root MSE        =     1.0354

                         (Std. err. adjusted for 100,243 clusters in origin_id#hs8)
-----------------------------------------------------------------------------------
                  |               Robust
        d_lnprice | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
------------------+----------------------------------------------------------------
            d_lne |   .2436036   .0098876    24.64   0.000     .2242241    .2629831
          hhi_hs8 |  -.0168869     .00837    -2.02   0.044     -.033292   -.0004818
                  |
c.d_lne#c.hhi_hs8 |   -.222667   .0483647    -4.60   0.000    -.3174612   -.1278729
                  |
          d_lnppi |  -.0112012   .0199051    -0.56   0.574     -.050215    .0278126
            _cons |   .0365671   .0006625    55.20   0.000     .0352687    .0378656
-----------------------------------------------------------------------------------

Absorbed degrees of freedom:
----------------------------------------------------------------+
            Absorbed FE | Categories  - Redundant  = Num. Coefs |
------------------------+---------------------------------------|
     hs8#origin_id#firm |   2724409     2724409           0    *|
                   year |        13           1          12     |
----------------------------------------------------------------+
* = FE nested within cluster; treated as redundant for DoF computation

.   est store m1  

. 
.   outreg2 m1 using "$T/TableIII_1_第(3)列.doc", replace ///
>     keep($x1 $x2 $x3) ///
>     bdec(3) sdec(3) ///
>     bracket ///
>     nocons ///
>     addtext(Imp-Ind-Cty FE, YES, Year FE, YES)    ///
>     title("tableIII_1_(3)")
/Users/yangyanjun/Desktop/exchangerate/提交版本/tables/TableIII_1_第(3)列.doc
dir : seeout

. 
. /*------------------------------------------------------------------------------
>  * 附录V  表A 1 第（4）列:行业-出口来源国层面构建进口竞争度指标
>  *------------------------------------------------------------------------------*/
. 
.   use "$W/final_data.dta", clear

.   merge m:1 year hs4 origin_id using "$W/hhi_hs4_出口来源国层面.dta"

    Result                      Number of obs
    -----------------------------------------
    Not matched                       187,794
        from master                    25,441  (_merge==1)
        from using                    162,353  (_merge==2)

    Matched                        10,771,275  (_merge==3)
    -----------------------------------------

.   keep if _merge == 3
(187,794 observations deleted)

.   drop _merge

.   xtset firm_origin_id_hs4 year 

Panel variable: firm_origin_id_hs4 (unbalanced)
 Time variable: year, 2001 to 2013, but with gaps
         Delta: 1 unit

.   replace hhi_hs4_c =hhi_hs4_c / 10000 
(10,771,275 real changes made)

.   global y    "d_lnprice"                              

.   global x1   "d_lne"                                             

.   global x2   "hhi_hs4_c"                           

.   global x3   "c.d_lne#c.hhi_hs4_c"                  

.   global c    "d_lnppi"                                                    

.   global f   ", absorb(hs4#origin_id#firm year)"               

.   global opt "vce(cluster i.origin_id#i.hs4)"

. 
.   reghdfe $y $x1 $x2 $x3  $c $f $opt
(dropped 1695606 singleton observations)
(MWFE estimator converged in 10 iterations)

HDFE Linear regression                            Number of obs   =  9,075,669
Absorbing 2 HDFE groups                           F(   4,  26836) =     105.82
Statistics robust to heteroskedasticity           Prob > F        =     0.0000
                                                  R-squared       =     0.1513
                                                  Adj R-squared   =    -0.1183
                                                  Within R-sq.    =     0.0003
Number of clusters (origin_id#hs4) =     26,837   Root MSE        =     1.2551

                            (Std. err. adjusted for 26,837 clusters in origin_id#hs4)
-------------------------------------------------------------------------------------
                    |               Robust
          d_lnprice | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
--------------------+----------------------------------------------------------------
              d_lne |   .3701976    .018449    20.07   0.000     .3340367    .4063586
          hhi_hs4_c |  -.0070982   .0060972    -1.16   0.244     -.019049    .0048527
                    |
c.d_lne#c.hhi_hs4_c |  -.4975982   .0295163   -16.86   0.000    -.5554517   -.4397447
                    |
            d_lnppi |   .0144652   .0286876     0.50   0.614     -.041764    .0706943
              _cons |   .0324921   .0009801    33.15   0.000     .0305711    .0344131
-------------------------------------------------------------------------------------

Absorbed degrees of freedom:
----------------------------------------------------------------+
            Absorbed FE | Categories  - Redundant  = Num. Coefs |
------------------------+---------------------------------------|
     hs4#origin_id#firm |   2187955     2187955           0    *|
                   year |        13           1          12     |
----------------------------------------------------------------+
* = FE nested within cluster; treated as redundant for DoF computation

.   est store m1  

.   
.   outreg2 m1 using "$T/TableIII_1_第(4)列.doc", replace ///
>     keep($x1 $x2 $x3) ///
>     bdec(3) sdec(3) ///
>     bracket ///
>     nocons ///
>     addtext(Imp-Ind-Cty FE, YES, Year FE, YES)    ///
>     title("tableIII_1_(4)")
/Users/yangyanjun/Desktop/exchangerate/提交版本/tables/TableIII_1_第(4)列.doc
dir : seeout

. 
. /*------------------------------------------------------------------------------
>  * 附录V  表A 1 第（5）列:几何平均价格
>  *------------------------------------------------------------------------------*/
. 
.   use "$W/final_data_几何平均价格.dta", clear

.   global y    "d_lnprice"                              

.   global x1   "d_lne"                                             

.   global x2   "hhi_hs4"                           

.   global x3   "c.d_lne#c.hhi_hs4"                  

.   global c    "d_lnppi"                                                    

.   global f   ", absorb(hs4#origin_id#firm year)"               

.   global opt "vce(cluster i.origin_id#i.hs4)"

. 
.   reghdfe $y $x1 $x2 $x3  $c $f $opt
(dropped 1698839 singleton observations)
(MWFE estimator converged in 10 iterations)

HDFE Linear regression                            Number of obs   =  9,097,873
Absorbing 2 HDFE groups                           F(   4,  28829) =      79.62
Statistics robust to heteroskedasticity           Prob > F        =     0.0000
                                                  R-squared       =     0.1494
                                                  Adj R-squared   =    -0.1208
                                                  Within R-sq.    =     0.0002
Number of clusters (origin_id#hs4) =     28,830   Root MSE        =     1.2343

                          (Std. err. adjusted for 28,830 clusters in origin_id#hs4)
-----------------------------------------------------------------------------------
                  |               Robust
       d_lnprice2 | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
------------------+----------------------------------------------------------------
            d_lne |   .2360235   .0144397    16.35   0.000     .2077211    .2643259
          hhi_hs4 |  -.0070556   .0182311    -0.39   0.699    -.0427893    .0286782
                  |
c.d_lne#c.hhi_hs4 |  -.4274064   .1160044    -3.68   0.000    -.6547803   -.2000325
                  |
          d_lnppi |   -.041666   .0283715    -1.47   0.142    -.0972754    .0139434
            _cons |   .0301611   .0007705    39.14   0.000     .0286508    .0316713
-----------------------------------------------------------------------------------

Absorbed degrees of freedom:
----------------------------------------------------------------+
            Absorbed FE | Categories  - Redundant  = Num. Coefs |
------------------------+---------------------------------------|
     hs4#origin_id#firm |   2193666     2193666           0    *|
                   year |        13           1          12     |
----------------------------------------------------------------+
* = FE nested within cluster; treated as redundant for DoF computation

.   est store m1  

. 
.   outreg2 m1 using "$T/TableIII_1_第(5)列.doc", replace ///
>     keep($x1 $x2 $x3) ///
>     bdec(3) sdec(3) ///
>     bracket ///
>     nocons ///
>     addtext(Imp-Ind-Cty FE, YES, Year FE, YES)    ///
>     title("tableIII_1_(5)")
/Users/yangyanjun/Desktop/exchangerate/提交版本/tables/TableIII_1_第(5)列.doc
dir : seeout

. 
. /*------------------------------------------------------------------------------
>  * 附录V  表A 1 第（6）列:缩尾处理
>  *------------------------------------------------------------------------------*/
. 
.   use "$W/final_data.dta", clear

.   xtset firm_origin_id_hs4 year

Panel variable: firm_origin_id_hs4 (unbalanced)
 Time variable: year, 2001 to 2013, but with gaps
         Delta: 1 unit

.   winsor2 d_lnprice ,cut(1 99)  replace 

.   global y    "d_lnprice"                                  //被解释变量

.   global x1   "d_lne"                                      //基本解释变量

.   global x2   "hhi_hs4"                                    //基本解释变量

.   global x3   "c.d_lne#c.hhi_hs4"                          //基本解释变量(主要观测)   

.   global c    "d_lnppi"                                    //基本控制变量  

.   global f    ", absorb(hs4#origin_id#firm year)"          //固定效应  

.   global opt  "vce(cluster i.origin_id#i.hs4)"

. 
.   reghdfe $y $x1 $x2 $x3  $c $f  $opt
(dropped 1698839 singleton observations)
(MWFE estimator converged in 10 iterations)

HDFE Linear regression                            Number of obs   =  9,097,877
Absorbing 2 HDFE groups                           F(   4,  28829) =      80.95
Statistics robust to heteroskedasticity           Prob > F        =     0.0000
                                                  R-squared       =     0.1507
                                                  Adj R-squared   =    -0.1192
                                                  Within R-sq.    =     0.0003
Number of clusters (origin_id#hs4) =     28,830   Root MSE        =     1.1146

                          (Std. err. adjusted for 28,830 clusters in origin_id#hs4)
-----------------------------------------------------------------------------------
                  |               Robust
        d_lnprice | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
------------------+----------------------------------------------------------------
            d_lne |   .2361796   .0142769    16.54   0.000     .2081962     .264163
          hhi_hs4 |  -.0110153   .0165965    -0.66   0.507    -.0435452    .0215147
                  |
c.d_lne#c.hhi_hs4 |  -.4083534   .1136849    -3.59   0.000     -.631181   -.1855258
                  |
          d_lnppi |  -.0315114   .0268614    -1.17   0.241     -.084161    .0211382
            _cons |   .0320577    .000718    44.65   0.000     .0306505     .033465
-----------------------------------------------------------------------------------

Absorbed degrees of freedom:
----------------------------------------------------------------+
            Absorbed FE | Categories  - Redundant  = Num. Coefs |
------------------------+---------------------------------------|
     hs4#origin_id#firm |   2193666     2193666           0    *|
                   year |        13           1          12     |
----------------------------------------------------------------+
* = FE nested within cluster; treated as redundant for DoF computation

.   est store m1

. 
.   outreg2 m1 using "$T/TableIII_1_第(6)列.doc", replace ///
>     keep($x1 $x2 $x3) ///
>     bdec(3) sdec(3) ///
>     bracket ///
>     nocons ///
>     addtext(Imp-Ind-Cty FE, YES, Year FE, YES)    ///
>     title("tableIII_1_(6)")
/Users/yangyanjun/Desktop/exchangerate/提交版本/tables/TableIII_1_第(6)列.doc
dir : seeout

.   
. /*------------------------------------------------------------------------------
>  * 附录V  表A 1 第（7）列:回归中加入权重分析
>  *------------------------------------------------------------------------------*/
. 
.   use "$W/final_data.dta", clear

.   bys hs4 year :egen share=pc(value)

.   xtset firm_origin_id_hs4 year

Panel variable: firm_origin_id_hs4 (unbalanced)
 Time variable: year, 2001 to 2013, but with gaps
         Delta: 1 unit

.   global y    "d_lnprice"                                  //被解释变量

.   global x1   "d_lne"                                      //基本解释变量

.   global x2   "hhi_hs4"                                    //基本解释变量

.   global x3   "c.d_lne#c.hhi_hs4"                          //基本解释变量(主要观测)   

.   global c    "d_lnppi"                                    //基本控制变量  

.   global w    "[aw= share]"                                //按照份额取权重

.   global f    ", absorb(hs4#origin_id#firm year)"          //固定效应  

.   global opt  "vce(cluster i.origin_id#i.hs4)"

. 
.   reghdfe $y $x1 $x2 $x3 $c $w $f  $opt
(dropped 1698839 singleton observations)
(MWFE estimator converged in 11 iterations)

HDFE Linear regression                            Number of obs   =  9,097,877
Absorbing 2 HDFE groups                           F(   4,  28829) =      16.59
Statistics robust to heteroskedasticity           Prob > F        =     0.0000
                                                  R-squared       =     0.4190
                                                  Adj R-squared   =     0.2343
                                                  Within R-sq.    =     0.0007
Number of clusters (origin_id#hs4) =     28,830   Root MSE        =     0.7108

                          (Std. err. adjusted for 28,830 clusters in origin_id#hs4)
-----------------------------------------------------------------------------------
                  |               Robust
        d_lnprice | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
------------------+----------------------------------------------------------------
            d_lne |   .2902666   .0360912     8.04   0.000     .2195262     .361007
          hhi_hs4 |   .0259273   .0564213     0.46   0.646    -.0846611    .1365157
                  |
c.d_lne#c.hhi_hs4 |  -.3634656   .1555983    -2.34   0.020    -.6684455   -.0584858
                  |
          d_lnppi |   .2507452   .0837732     2.99   0.003     .0865458    .4149446
            _cons |   .0778966   .0093934     8.29   0.000     .0594851    .0963081
-----------------------------------------------------------------------------------

Absorbed degrees of freedom:
----------------------------------------------------------------+
            Absorbed FE | Categories  - Redundant  = Num. Coefs |
------------------------+---------------------------------------|
     hs4#origin_id#firm |   2193666     2193666           0    *|
                   year |        13           1          12     |
----------------------------------------------------------------+
* = FE nested within cluster; treated as redundant for DoF computation

.   est store m1

. 
.   outreg2 m1 using "$T/TableIII_1_第(7)列.doc", replace ///
>     keep($x1 $x2 $x3) ///
>     bdec(3) sdec(3) ///
>     bracket ///
>     nocons ///
>     addtext(Imp-Ind-Cty FE, YES, Year FE, YES)    ///
>     title("tableIII_1_(7)")
/Users/yangyanjun/Desktop/exchangerate/提交版本/tables/TableIII_1_第(7)列.doc
dir : seeout

. 
. /*------------------------------------------------------------------------------
>  * 附录V  表A 2  替换固定效应
>  *------------------------------------------------------------------------------*/
. 
.   use "$W/final_data.dta", clear

.   xtset firm_origin_id_hs4 year

Panel variable: firm_origin_id_hs4 (unbalanced)
 Time variable: year, 2001 to 2013, but with gaps
         Delta: 1 unit

.   global y    "d_lnprice"                                  //被解释变量

.   global x1   "d_lne"                                      //基本解释变量

.   global x2   "hhi_hs4"                                    //基本解释变量

.   global x3   "c.d_lne#c.hhi_hs4"                          //基本解释变量(主要观测)   

.   global c    "d_lnppi"                                    //基本控制变量  

.   global f    ", absorb(hs4#origin_id#firm year)"          //固定效应 

.   global f1   ", absorb(firm hs4 origin_id year)"          //固定效应  

.   global f2   ", absorb(hs4#origin_id firm year)"          //固定效应  

.   global f3   ", absorb(hs4#origin_id firm#year)"          //固定效应

.   global opt  "vce(cluster i.origin_id#i.hs4)"

.   global opt1 "vce(cluster origin_id#year hs4#year)"

. 
.   reghdfe $y $x1 $x2 $x3 $c  $f1  $opt
(dropped 39743 singleton observations)
(MWFE estimator converged in 22 iterations)

HDFE Linear regression                            Number of obs   = 10,756,973
Absorbing 4 HDFE groups                           F(   4,  36005) =      84.29
Statistics robust to heteroskedasticity           Prob > F        =     0.0000
                                                  R-squared       =     0.0185
                                                  Adj R-squared   =     0.0009
                                                  Within R-sq.    =     0.0002
Number of clusters (origin_id#hs4) =     36,006   Root MSE        =     1.2318

                          (Std. err. adjusted for 36,006 clusters in origin_id#hs4)
-----------------------------------------------------------------------------------
                  |               Robust
        d_lnprice | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
------------------+----------------------------------------------------------------
            d_lne |   .2150986   .0126825    16.96   0.000     .1902405    .2399568
          hhi_hs4 |   -.019042   .0141128    -1.35   0.177    -.0467035    .0086194
                  |
c.d_lne#c.hhi_hs4 |  -.4263652   .1148332    -3.71   0.000    -.6514418   -.2012887
                  |
          d_lnppi |  -.0576585   .0248197    -2.32   0.020    -.1063058   -.0090112
            _cons |   .0267649    .000811    33.00   0.000     .0251753    .0283546
-----------------------------------------------------------------------------------

Absorbed degrees of freedom:
-----------------------------------------------------+
 Absorbed FE | Categories  - Redundant  = Num. Coefs |
-------------+---------------------------------------|
        firm |    188862           0      188862     |
         hs4 |      1136           2        1134     |
   origin_id |        98           1          97    ?|
        year |        13           1          12    ?|
-----------------------------------------------------+
? = number of redundant parameters may be higher

.   est store m1

.   reghdfe $y $x1 $x2 $x3 $c  $f2  $opt
(dropped 44427 singleton observations)
(MWFE estimator converged in 29 iterations)

HDFE Linear regression                            Number of obs   = 10,752,289
Absorbing 3 HDFE groups                           F(   4,  31403) =      84.19
Statistics robust to heteroskedasticity           Prob > F        =     0.0000
                                                  R-squared       =     0.0202
                                                  Adj R-squared   =    -0.0003
                                                  Within R-sq.    =     0.0002
Number of clusters (origin_id#hs4) =     31,404   Root MSE        =     1.2326

                          (Std. err. adjusted for 31,404 clusters in origin_id#hs4)
-----------------------------------------------------------------------------------
                  |               Robust
        d_lnprice | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
------------------+----------------------------------------------------------------
            d_lne |    .219664   .0130113    16.88   0.000     .1941613    .2451666
          hhi_hs4 |  -.0169537   .0147179    -1.15   0.249    -.0458013    .0118939
                  |
c.d_lne#c.hhi_hs4 |  -.4413609   .1265464    -3.49   0.000    -.6893968   -.1933249
                  |
          d_lnppi |   -.057333   .0253177    -2.26   0.024    -.1069566   -.0077093
            _cons |   .0267774   .0006591    40.62   0.000     .0254855    .0280693
-----------------------------------------------------------------------------------

Absorbed degrees of freedom:
---------------------------------------------------------+
     Absorbed FE | Categories  - Redundant  = Num. Coefs |
-----------------+---------------------------------------|
   hs4#origin_id |     31404       31404           0    *|
            firm |    188773           1      188772     |
            year |        13           1          12     |
---------------------------------------------------------+
* = FE nested within cluster; treated as redundant for DoF computation

.   est store m2

.   reghdfe $y $x1 $x2 $x3 $c  $f3  $opt
(dropped 253555 singleton observations)
(MWFE estimator converged in 36 iterations)

HDFE Linear regression                            Number of obs   = 10,543,161
Absorbing 2 HDFE groups                           F(   4,  31137) =      53.97
Statistics robust to heteroskedasticity           Prob > F        =     0.0000
                                                  R-squared       =     0.0792
                                                  Adj R-squared   =     0.0121
                                                  Within R-sq.    =     0.0000
Number of clusters (origin_id#hs4) =     31,138   Root MSE        =     1.2274

                          (Std. err. adjusted for 31,138 clusters in origin_id#hs4)
-----------------------------------------------------------------------------------
                  |               Robust
        d_lnprice | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
------------------+----------------------------------------------------------------
            d_lne |   .1210812   .0091353    13.25   0.000     .1031757    .1389868
          hhi_hs4 |  -.0140636    .014813    -0.95   0.342    -.0430977    .0149705
                  |
c.d_lne#c.hhi_hs4 |   -.309744   .0859415    -3.60   0.000    -.4781927   -.1412953
                  |
          d_lnppi |   -.076703    .022288    -3.44   0.001    -.1203884   -.0330176
            _cons |   .0261514   .0006071    43.08   0.000     .0249614    .0273413
-----------------------------------------------------------------------------------

Absorbed degrees of freedom:
---------------------------------------------------------+
     Absorbed FE | Categories  - Redundant  = Num. Coefs |
-----------------+---------------------------------------|
   hs4#origin_id |     31138       31138           0    *|
       firm#year |    684433           1      684432     |
---------------------------------------------------------+
* = FE nested within cluster; treated as redundant for DoF computation

.   est store m3

.   reghdfe $y $x1 $x2 $x3 $c  $f   $opt1
(dropped 1698839 singleton observations)
(MWFE estimator converged in 10 iterations)

HDFE Linear regression                            Number of obs   =  9,097,877
Absorbing 2 HDFE groups                           F(   4,   1102) =       3.51
Statistics robust to heteroskedasticity           Prob > F        =     0.0074
                                                  R-squared       =     0.1512
                                                  Adj R-squared   =    -0.1185
Number of clusters (origin_id#year) =      1,103  Within R-sq.    =     0.0002
Number of clusters (hs4#year) =     13,917        Root MSE        =     1.2544

                 (Std. err. adjusted for 1,103 clusters in origin_id#year hs4#year)
-----------------------------------------------------------------------------------
                  |               Robust
        d_lnprice | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
------------------+----------------------------------------------------------------
            d_lne |    .238408   .0687555     3.47   0.001     .1035016    .3733144
          hhi_hs4 |    -.00225   .0315565    -0.07   0.943    -.0641676    .0596676
                  |
c.d_lne#c.hhi_hs4 |  -.4136731   .1713545    -2.41   0.016     -.749891   -.0774552
                  |
          d_lnppi |  -.0371079   .0800478    -0.46   0.643    -.1941712    .1199554
            _cons |   .0314054   .0025821    12.16   0.000     .0263391    .0364718
-----------------------------------------------------------------------------------

Absorbed degrees of freedom:
----------------------------------------------------------------+
            Absorbed FE | Categories  - Redundant  = Num. Coefs |
------------------------+---------------------------------------|
     hs4#origin_id#firm |   2193666           0     2193666     |
                   year |        13           1          12     |
----------------------------------------------------------------+

.   est store m4

. 
.   outreg2 [m1 m2 m3 m4] using "$T/TableIII_2.doc", replace ///
>     keep($x1 $x2 $x3) ///
>     bdec(3) sdec(3) ///
>     bracket ///
>     nocons ///
>     title("tableIII_2")
/Users/yangyanjun/Desktop/exchangerate/提交版本/tables/TableIII_2.doc
dir : seeout

. 
.   display "表格生成模块完成"
表格生成模块完成

.   
. 
end of do-file

.   log close
      name:  <unnamed>
       log:  /Users/yangyanjun/Desktop/exchangerate/提交版本/logs/tables_log.txt
  log type:  text
 closed on:  26 Jul 2025, 16:20:36
-----------------------------------------------------------------------------------------------------
