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

. 
. ***************
. * Run
. ***************
. 
. ***import data *******
. * 1.1 载入原始面板
. use "$DATA\intermediate\invest_flow_countyToCountyRevise_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,308 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,012
        from master                    21,085  (_merge==1)
        from using                        927  (_merge==2)

    Matched                            28,888  (_merge==3)
    -----------------------------------------

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

. drop _merge

. 
. egen investor_indPrice = rowmean(indPrice2010 indPrice2009 indPrice2011) //3年来源地平均地价
(228 missing values generated)

. 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 = .
(28,888 missing values generated)

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

. replace policy_year = 2013 if inlist(orig_prov, 11,32, 33, 34, 42,12,35,44)
(14,738 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,745 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        999          0 |       999 
        12 |         0        650          0 |       650 
        13 |         0          0      1,624 |     1,624 
        14 |         0          0        371 |       371 
        15 |         0          0        173 |       173 
        21 |         0          0        950 |       950 
        22 |         0          0        298 |       298 
        23 |         0          0        432 |       432 
        31 |     1,405          0          0 |     1,405 
        32 |         0      3,801          0 |     3,801 
        33 |         0      4,098          0 |     4,098 
        34 |         0        929          0 |       929 
        35 |         0      1,447          0 |     1,447 
        36 |         0          0        838 |       838 
        37 |         0          0      1,637 |     1,637 
        41 |         0          0        907 |       907 
        42 |         0      1,258          0 |     1,258 
        43 |         0          0        764 |       764 
        44 |         0      1,556          0 |     1,556 
        45 |         0          0        184 |       184 
        50 |         0          0        831 |       831 
        51 |         0          0      1,611 |     1,611 
        52 |         0          0        414 |       414 
        53 |         0          0        569 |       569 
        61 |         0          0        440 |       440 
        62 |         0          0        192 |       192 
        63 |         0          0         15 |        15 
        64 |         0          0        104 |       104 
        65 |         0          0        391 |       391 
-----------+---------------------------------+----------
     Total |     1,405     14,738     12,745 |    28,888 

. tab policy_orig

policy_orig |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |     19,809       68.57       68.57
          1 |      9,079       31.43      100.00
------------+-----------------------------------
      Total |     28,888      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,177
        from master                    10,222  (_merge==1)
        from using                        955  (_merge==2)

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

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

. drop _merge 

. 
. egen investee_indPrice = rowmean(indPrice2010 indPrice2009 indPrice2011) //3年目的地平均地价
(217 missing values generated)

. drop indPrice* commercePricehouse* investor_location

. 
. *****计算地价差*****
. * 4.1 地价差
. gen delta_indprice = log(investor_indPrice) - log(investee_indPrice)  
(293 missing values generated)

. //来源地地价-目的地地价(3年平均地价)
. 
. drop if orig_county_code == dest_county_code // delete 来源地和目的地相同的样本
(6,477 observations deleted)

. 
. 
. 
. ********************************************************************************
. **********PPML估计 regression : 表4 制造业企业异地投资 第(3)列: 替换地价差交互项 
. 
. 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,280
        from master                       421  (_merge==1)
        from using                     20,859  (_merge==2)

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

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

. drop _merge

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

. gen industryratio = thirdgdp/secondgdp  //产业结构 = 三产/二产
(928 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 3207 observations that are either singletons or separated by a fixed effect)
warning: dependent variable takes very low values after standardizing (6.8215e-10)
note: 2 variables omitted because of collinearity: 1bn.policy_orig delta_indprice
Iteration 1:   deviance = 1.0504e+09  eps = .         iters = 12   tol = 1.0e-04  min(eta) =  -5.89  P   
Iteration 2:   deviance = 3.8787e+08  eps = 1.71e+00  iters = 10   tol = 1.0e-04  min(eta) =  -7.83      
Iteration 3:   deviance = 1.6297e+08  eps = 1.38e+00  iters = 10   tol = 1.0e-04  min(eta) = -11.60      
Iteration 4:   deviance = 8.0285e+07  eps = 1.03e+00  iters = 11   tol = 1.0e-04  min(eta) = -16.08      
Iteration 5:   deviance = 5.2189e+07  eps = 5.38e-01  iters = 11   tol = 1.0e-04  min(eta) = -21.25      
Iteration 6:   deviance = 4.3530e+07  eps = 1.99e-01  iters = 11   tol = 1.0e-04  min(eta) = -25.41      
Iteration 7:   deviance = 4.1231e+07  eps = 5.57e-02  iters = 13   tol = 1.0e-04  min(eta) = -27.96      
Iteration 8:   deviance = 4.0873e+07  eps = 8.76e-03  iters = 12   tol = 1.0e-04  min(eta) = -29.22      
Iteration 9:   deviance = 4.0854e+07  eps = 4.88e-04  iters = 11   tol = 1.0e-04  min(eta) = -29.64      
Iteration 10:  deviance = 4.0853e+07  eps = 2.56e-05  iters = 8    tol = 1.0e-04  min(eta) = -29.71      
Iteration 11:  deviance = 4.0852e+07  eps = 2.96e-06  iters = 10   tol = 1.0e-05  min(eta) = -29.72      
Iteration 12:  deviance = 4.0852e+07  eps = 3.22e-07  iters = 10   tol = 1.0e-06  min(eta) = -29.72      
Iteration 13:  deviance = 4.0852e+07  eps = 5.02e-08  iters = 12   tol = 1.0e-07  min(eta) = -29.72   S  
Iteration 14:  deviance = 4.0852e+07  eps = 7.29e-09  iters = 6    tol = 1.0e-08  min(eta) = -29.72   S O
------------------------------------------------------------------------------------------------------------
(legend: p: exact partial-out   s: exact solver   h: step-halving   o: epsilon below tolerance)
Converged in 14 iterations and 147 HDFE sub-iterations (tol = 1.0e-08)

HDFE PPML regression                              No. of obs      =      2,631
Absorbing 2 HDFE groups                           Residual df     =      1,056
Statistics robust to heteroskedasticity           Wald chi2(3)    =      21.83
Deviance             =  40852392.11               Prob > chi2     =     0.0001
Log pseudolikelihood = -20435064.94               Pseudo R2       =     0.9926

Number of clusters (pairID) =      1,057
                                             (Std. err. adjusted for 1,057 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.053845   1.604961     4.40   0.000     3.908178    10.19951
                             |
                      gdpper |   7.12e-06   4.89e-06     1.46   0.145    -2.45e-06    .0000167
                     pophuji |   .0966233   .5124912     0.19   0.850    -.9078409    1.101088
                       _cons |   7.035798   47.68223     0.15   0.883    -86.41966    100.4913
----------------------------------------------------------------------------------------------

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

. estimates store m1

. 
. * 导出到word
. outreg2 [m1] using "$EXHIBIT/results.doc", replace ///
>     ctitle("replace Interaction")          /// 列标题
>     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_制造业异地投资_表4Column3.txt
  log type:  text
 closed on:  25 Jan 2026, 12:06:22
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
