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

. 
. ***************
. * 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

. 
. 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 = .
(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 

. 
. 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,955 missing values generated)

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

. 
. 
. ********************************************************************************
. *******PPML估计 regression : 表4 制造业企业异地投资 第(4)列: 控制地价差的时间趋势项 
. 
. 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)

. 
. ****控制2009年地价差的time trend
. gen int t2009 = year - 2009

. label var t2009 "年份自 2009 起的差值"

. 
. ppmlhdfe invest_flow ///
>     i.policy_orig##c.delta_indprice c.delta_indprice#c.t2009##c.t2009  gdpper   pophuji if delta_indprice > 0 , absorb(pairID orig_prov#year ) cluster(pairID) 
(dropped 2911 observations that are either singletons or separated by a fixed effect)
warning: dependent variable takes very low values after standardizing (6.1832e-08)
note: 3 variables omitted because of collinearity: 1bn.policy_orig delta_indprice t2009
Iteration 1:   deviance = 1.2040e+09  eps = .         iters = 12   tol = 1.0e-04  min(eta) =  -6.06  P   
Iteration 2:   deviance = 4.5240e+08  eps = 1.66e+00  iters = 10   tol = 1.0e-04  min(eta) =  -7.93      
Iteration 3:   deviance = 1.9505e+08  eps = 1.32e+00  iters = 9    tol = 1.0e-04  min(eta) = -11.08      
Iteration 4:   deviance = 9.7478e+07  eps = 1.00e+00  iters = 9    tol = 1.0e-04  min(eta) = -17.06      
Iteration 5:   deviance = 6.3965e+07  eps = 5.24e-01  iters = 13   tol = 1.0e-04  min(eta) = -24.95      
Iteration 6:   deviance = 5.4119e+07  eps = 1.82e-01  iters = 14   tol = 1.0e-04  min(eta) = -34.39      
Iteration 7:   deviance = 4.2044e+08  eps = 6.77e+00  iters = 18   tol = 1.0e-04  min(eta) = -43.00      
Iteration 8:   deviance = 1.8697e+08  eps = 1.25e+00  iters = 17   tol = 1.0e-04  min(eta) = -46.97      
Iteration 9:   deviance = 1.0127e+08  eps = 8.46e-01  iters = 17   tol = 1.0e-04  min(eta) = -47.65      
Iteration 10:  deviance = 6.9632e+07  eps = 4.54e-01  iters = 10   tol = 1.0e-04  min(eta) = -47.56      
Iteration 11:  deviance = 5.8008e+07  eps = 2.00e-01  iters = 7    tol = 1.0e-04  min(eta) = -47.58      
Iteration 12:  deviance = 5.3739e+07  eps = 7.95e-02  iters = 4    tol = 1.0e-04  min(eta) = -47.57      
Iteration 13:  deviance = 5.2170e+07  eps = 3.01e-02  iters = 4    tol = 1.0e-04  min(eta) = -47.58      
Iteration 14:  deviance = 5.1594e+07  eps = 1.12e-02  iters = 3    tol = 1.0e-04  min(eta) = -47.58      
Iteration 15:  deviance = 5.1384e+07  eps = 4.10e-03  iters = 4    tol = 1.0e-04  min(eta) = -47.58      
Iteration 16:  deviance = 5.1307e+07  eps = 1.49e-03  iters = 5    tol = 1.0e-04  min(eta) = -47.58      
Iteration 17:  deviance = 5.1280e+07  eps = 5.36e-04  iters = 5    tol = 1.0e-04  min(eta) = -47.59      
Iteration 18:  deviance = 5.1270e+07  eps = 1.81e-04  iters = 5    tol = 1.0e-04  min(eta) = -47.59      
Iteration 19:  deviance = 5.1268e+07  eps = 4.97e-05  iters = 5    tol = 1.0e-04  min(eta) = -47.60      
Iteration 20:  deviance = 5.1267e+07  eps = 8.07e-06  iters = 6    tol = 1.0e-05  min(eta) = -47.60      
Iteration 21:  deviance = 5.1267e+07  eps = 4.39e-07  iters = 13   tol = 1.0e-06  min(eta) = -47.60   S  
Iteration 22:  deviance = 5.1267e+07  eps = 4.96e-07  iters = 13   tol = 1.0e-07  min(eta) = -47.60   S  
Iteration 23:  deviance = 5.1267e+07  eps = 2.57e-08  iters = 13   tol = 1.0e-07  min(eta) = -47.60   S  
Iteration 24:  deviance = 5.1267e+07  eps = 4.80e-09  iters = 12   tol = 1.0e-08  min(eta) = -47.60   S O
------------------------------------------------------------------------------------------------------------
(legend: p: exact partial-out   s: exact solver   h: step-halving   o: epsilon below tolerance)
Converged in 24 iterations and 228 HDFE sub-iterations (tol = 1.0e-08)

HDFE PPML regression                              No. of obs      =      2,379
Absorbing 2 HDFE groups                           Residual df     =        946
Statistics robust to heteroskedasticity           Wald chi2(5)    =      25.33
Deviance             =  51267421.57               Prob > chi2     =     0.0001
Log pseudolikelihood = -25641816.27               Pseudo R2       =     0.9921

Number of clusters (pairID) =        947
                                                   (Std. err. adjusted for 947 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  |   18.49648   4.692028     3.94   0.000     9.300274    27.69268
                                 |
        c.delta_indprice#c.t2009 |  -3.169656   3.856904    -0.82   0.411    -10.72905    4.389736
                                 |
                           t2009 |          0  (omitted)
                                 |
c.delta_indprice#c.t2009#c.t2009 |  -.2524878    .598311    -0.42   0.673    -1.425156    .9201802
                                 |
                          gdpper |   5.88e-06   8.45e-06     0.70   0.487    -.0000107    .0000224
                         pophuji |  -.3665558   .7216917    -0.51   0.612    -1.781046    1.047934
                           _cons |   54.79523   67.30935     0.81   0.416    -77.12868    186.7191
--------------------------------------------------------------------------------------------------

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

. estimates store m1

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