--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  D:/stata17/Replication_paper/Logfile_forReg/Analysis_制造业异地投资_表4Column2.txt
  log type:  text
 opened on:  25 Jan 2026, 12:06:20

. 
. ***************
. * Run
. ***************
. 
. ***import data *******
. * 1.1 载入原始面板
. use "$DATA\intermediate\invest_flow_countyToCounty_robust1Revise_0914.dta" ,clear

. 
. 
. * 1.2 检查县区代码是否为字符串，长度应为6
. describe orig_county_code dest_county_code

Variable      Storage   Display    Value
    name         type    format    label      Variable label
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
orig_county_c~e str6    %9s                   DOMDISTRICT_2
dest_county_c~e str6    %9s                   DOMDISTRICT_1

. assert (strlen(orig_county_code)==6) & (strlen(dest_county_code)==6)

. 
. ***构造双边面板ID
. * 2.1 合并成一个字符串
. drop if substr(orig_county_code, 3, 4) == "0000"  //省级代码删除, 保留真正县级代码
(5,458 observations deleted)

. gen str13 pair =  orig_county_code + "_" + dest_county_code

. 
. * 2.2 编号
. egen pairID = group(pair)

. 
. * 检查
. describe orig_county_code dest_county_code

Variable      Storage   Display    Value
    name         type    format    label      Variable label
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
orig_county_c~e str6    %9s                   DOMDISTRICT_2
dest_county_c~e str6    %9s                   DOMDISTRICT_1

. 
. ****combine 县区层面变量
. * 3.1 合并来源地地价
. sort orig_county_code year

. destring orig_county_code,gen(investor_location)
orig_county_code: all characters numeric; investor_location generated as long

. merge m:1 investor_location using "$DATA\sourcedata\landprice_countyAdjust.dta"
(variable investor_location was long, now double to accommodate using data's values)

    Result                      Number of obs
    -----------------------------------------
    Not matched                        22,478
        from master                    21,552  (_merge==1)
        from using                        926  (_merge==2)

    Matched                            29,400  (_merge==3)
    -----------------------------------------

. keep if _merge == 3
(22,478 observations deleted)

. drop _merge

. 
. rename indPrice2010 investor_indPrice2010

. rename commercePricehouse2010 investor_commercePricehouse2010

. drop indPrice* commercePricehouse* investee_location

. 
. * 3.2 设定来源地县区为政策实施地
. 
. * 指定各省份的政策实施年份
. drop orig_prov dest_prov

. gen orig_prov = real(substr(orig_county_code,1,2))

. gen int policy_year = .
(29,400 missing values generated)

. replace policy_year = 2012 if orig_prov == 31
(1,433 real changes made)

. replace policy_year = 2013 if inlist(orig_prov, 11,32, 33, 34, 42,12,35,44)
(15,021 real changes made)

. replace policy_year = 2014 if inlist(orig_prov, 13,14,15,21,22,23,36,37,41,43,45,46,50,51,52,53,54,61,62,63,64,65)
(12,946 real changes made)

. 
. * 生成来源地政策 dummy：实施年份及以后为 1，之前为 0
. gen byte policy_orig = (year >= policy_year) 

. count if missing(policy_orig)
  0

. 
. * 检查
. tab orig_prov policy_year

           |           policy_year
 orig_prov |      2012       2013       2014 |     Total
-----------+---------------------------------+----------
        11 |         0      1,017          0 |     1,017 
        12 |         0        656          0 |       656 
        13 |         0          0      1,638 |     1,638 
        14 |         0          0        376 |       376 
        15 |         0          0        173 |       173 
        21 |         0          0        964 |       964 
        22 |         0          0        305 |       305 
        23 |         0          0        438 |       438 
        31 |     1,433          0          0 |     1,433 
        32 |         0      3,862          0 |     3,862 
        33 |         0      4,189          0 |     4,189 
        34 |         0        943          0 |       943 
        35 |         0      1,468          0 |     1,468 
        36 |         0          0        852 |       852 
        37 |         0          0      1,666 |     1,666 
        41 |         0          0        918 |       918 
        42 |         0      1,294          0 |     1,294 
        43 |         0          0        774 |       774 
        44 |         0      1,592          0 |     1,592 
        45 |         0          0        187 |       187 
        50 |         0          0        856 |       856 
        51 |         0          0      1,634 |     1,634 
        52 |         0          0        422 |       422 
        53 |         0          0        578 |       578 
        61 |         0          0        453 |       453 
        62 |         0          0        194 |       194 
        63 |         0          0         16 |        16 
        64 |         0          0        107 |       107 
        65 |         0          0        395 |       395 
-----------+---------------------------------+----------
     Total |     1,433     15,021     12,946 |    29,400 

. tab policy_orig

policy_orig |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |     20,076       68.29       68.29
          1 |      9,324       31.71      100.00
------------+-----------------------------------
      Total |     29,400      100.00

. 
. * 3.3 合并目的地地价
. sort pairID year

. destring dest_county_code,gen(investee_location)
dest_county_code: all characters numeric; investee_location generated as long

. merge m:1 investee_location using "$DATA\sourcedata\landprice_countyAdjust.dta"
(variable investee_location was long, now double to accommodate using data's values)

    Result                      Number of obs
    -----------------------------------------
    Not matched                        11,415
        from master                    10,460  (_merge==1)
        from using                        955  (_merge==2)

    Matched                            18,940  (_merge==3)
    -----------------------------------------

. keep if _merge ==3 
(11,415 observations deleted)

. drop _merge 

. 
. rename indPrice2010 investee_indPrice2010

. rename commercePricehouse2010 investee_commercePricehouse2010

. drop indPrice* commercePricehouse* investor_location

. 
. *****计算地价差*****
. * 4.1 地价差
. gen delta_indprice = log(investor_indPrice2010) - log(investee_indPrice2010)  
(1,985 missing values generated)

. //来源地地价-目的地地价(工业地价)
. 
. drop if orig_county_code == dest_county_code //delete 来源地和目的地相同的样本
(6,519 observations deleted)

. 
. 
. ********************************************************************************
. **********PPML估计 regression : 表4 制造业企业异地投资 第(2)列: Y=累计实缴额 
. 
. xtset pairID year

Panel variable: pairID (unbalanced)
 Time variable: year, 2009 to 2014, but with gaps
         Delta: 1 unit

. 
. *  补充来源地县区控制变量
. *orig 县区人均gdp, 产业结构(三产/二产)
. destring orig_county_code,gen(xx)
orig_county_code: all characters numeric; xx generated as long

. rename year years

. merge m:1 xx years using "$DATA\sourcedata\区县控制变量_带Label.dta"

    Result                      Number of obs
    -----------------------------------------
    Not matched                        21,251
        from master                       427  (_merge==1)
        from using                     20,824  (_merge==2)

    Matched                            11,994  (_merge==3)
    -----------------------------------------

. keep if _merge == 3
(21,251 observations deleted)

. drop _merge

. 
. gen gdpper = gdp/pophuji   // gdp/户籍人口
(835 missing values generated)

. gen industryratio = thirdgdp/secondgdp  //产业结构 = 三产/二产
(946 missing values generated)

. 
. ppmlhdfe invest_flow i.policy_orig##c.delta_indprice gdpper   pophuji if delta_indprice > 0 , absorb(pairID orig_prov#year) cluster(pairID)  // 来源地地价>目的地地价
(dropped 2834 observations that are either singletons or separated by a fixed effect)
warning: dependent variable takes very low values after standardizing (5.4357e-08)
note: 2 variables omitted because of collinearity: 1bn.policy_orig delta_indprice
Iteration 1:   deviance = 1.2483e+09  eps = .         iters = 12   tol = 1.0e-04  min(eta) =  -6.48  P   
Iteration 2:   deviance = 4.8120e+08  eps = 1.59e+00  iters = 11   tol = 1.0e-04  min(eta) =  -8.65      
Iteration 3:   deviance = 2.2225e+08  eps = 1.17e+00  iters = 11   tol = 1.0e-04  min(eta) = -11.33      
Iteration 4:   deviance = 1.3000e+08  eps = 7.10e-01  iters = 13   tol = 1.0e-04  min(eta) = -18.10      
Iteration 5:   deviance = 9.8376e+07  eps = 3.21e-01  iters = 16   tol = 1.0e-04  min(eta) = -35.32      
Iteration 6:   deviance = 8.8579e+07  eps = 1.11e-01  iters = 15   tol = 1.0e-04  min(eta) = -46.36      
Iteration 7:   deviance = 8.4912e+07  eps = 4.32e-02  iters = 15   tol = 1.0e-04  min(eta) = -50.84      
Iteration 8:   deviance = 8.4005e+07  eps = 1.08e-02  iters = 14   tol = 1.0e-04  min(eta) = -52.94      
Iteration 9:   deviance = 8.3961e+07  eps = 5.34e-04  iters = 14   tol = 1.0e-04  min(eta) = -53.66      
Iteration 10:  deviance = 8.3960e+07  eps = 6.23e-06  iters = 10   tol = 1.0e-04  min(eta) = -53.85      
Iteration 11:  deviance = 8.3960e+07  eps = 5.17e-07  iters = 11   tol = 1.0e-05  min(eta) = -53.87   S  
Iteration 12:  deviance = 8.3960e+07  eps = 1.08e-08  iters = 22   tol = 1.0e-07  min(eta) = -53.87   S  
Iteration 13:  deviance = 8.3960e+07  eps = 9.90e-09  iters = 14   tol = 1.0e-08  min(eta) = -53.87   S O
------------------------------------------------------------------------------------------------------------
(legend: p: exact partial-out   s: exact solver   h: step-halving   o: epsilon below tolerance)
Converged in 13 iterations and 178 HDFE sub-iterations (tol = 1.0e-08)

HDFE PPML regression                              No. of obs      =      2,560
Absorbing 2 HDFE groups                           Residual df     =      1,016
Statistics robust to heteroskedasticity           Wald chi2(3)    =      16.74
Deviance             =   83960013.2               Prob > chi2     =     0.0008
Log pseudolikelihood = -41990499.52               Pseudo R2       =     0.9835

Number of clusters (pairID) =      1,017
                                             (Std. err. adjusted for 1,017 clusters in pairID)
----------------------------------------------------------------------------------------------
                             |               Robust
                 invest_flow | Coefficient  std. err.      z    P>|z|     [95% conf. interval]
-----------------------------+----------------------------------------------------------------
               1.policy_orig |          0  (omitted)
              delta_indprice |          0  (omitted)
                             |
policy_orig#c.delta_indprice |
                          1  |   7.868312   1.989211     3.96   0.000      3.96953    11.76709
                             |
                      gdpper |  -.0000172   8.33e-06    -2.07   0.039    -.0000335   -8.97e-07
                     pophuji |   .8962761   .4407903     2.03   0.042     .0323429    1.760209
                       _cons |  -76.65551   46.46936    -1.65   0.099    -167.7338    14.42276
----------------------------------------------------------------------------------------------

Absorbed degrees of freedom:
-----------------------------------------------------------+
       Absorbed FE | Categories  - Redundant  = Num. Coefs |
-------------------+---------------------------------------|
            pairID |      1017        1017           0    *|
   orig_prov#years |       128           1         127     |
-----------------------------------------------------------+
* = FE nested within cluster; treated as redundant for DoF computation

. estimates store m1

.         
. * 导出
. outreg2 [m1] using "$EXHIBIT/results.doc", replace ///
>     ctitle("replace Yvar")          /// 列标题
>     se                       /// 报告括号内标准误
>     dec(3) nocons addtext(Pair-County FE, Yes, OrigProvince-Year FE, Yes)
D:/stata17/Replication_paper/Exhibits/results.doc
dir : seeout

.         
. 
. 
. *****************
. * close log txt
. *****************
. 
. log close
      name:  <unnamed>
       log:  D:/stata17/Replication_paper/Logfile_forReg/Analysis_制造业异地投资_表4Column2.txt
  log type:  text
 closed on:  25 Jan 2026, 12:06:21
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
