
use "数据.dta",clear
xtset firmid year

//表1
gen lncapital=ln(capital)
gen lnlabor=ln(labor)
gen lninput=ln(input)
gen lnoutput=ln(output)
gen lnvalue=ln(valueadd)
gen lnage=ln(age)

acfest lnvalue,state(lncapital lnage) proxy(lninput) free(lnlabor) i(firmid) t(year) nbs(200)
predict acfvalue,omega
acfest lnoutput,state(lncapital lnage) proxy(lninput) free(lnlabor) i(firmid) t(year) nbs(200)
predict acfoutput,omega

gen acfvalue_rle=acfvalue*rle
gen acfoutput_rle=acfoutput*rle
gen acfvalue_cost=acfvalue*cost
gen acfoutput_cost=acfoutput*cost
gen acfvalue_time=acfvalue*lntime
gen acfoutput_time=acfoutput*lntime

xtlogit offshoring acfvalue acfvalue_rle research subsidy export lnlabor age i.firmid i.year,fe
xtlogit offshoring acfoutput acfoutput_rle research subsidy export lnlabor age i.firmid i.year,fe
xtlogit offshoring acfvalue acfvalue_cost research subsidy export lnlabor age i.firmid i.year,fe
xtlogit offshoring acfoutput acfoutput_cost research subsidy export lnlabor age i.firmid i.year,fe
xtlogit offshoring acfvalue acfvalue_time research subsidy export lnlabor age i.firmid i.year,fe
xtlogit offshoring acfoutput acfoutput_time research subsidy export lnlabor age i.firmid i.year,fe


//表2
xthreg offshoring acfvalue_rle research subsidy export lnlabor age,rx(acfvalue) qx(acfvalue) thnum(1) bs(300) trim(0.01) grid(100)

gen acfvalue_rleperfect=acfvalue*rleperfect
xthreg offshoring acfvalue_rleperfect research subsidy export lnlabor age,rx(acfvalue) qx(acfvalue) thnum(1) bs(300) trim(0.01) grid(100)


//表3
xthreg offshoring acfvalue_rle research subsidy export lnlabor age,rx(acfvalue) qx(acfvalue) thnum(1) bs(300) trim(0.01) grid(100)
xthreg offshoring acfoutput_rle research subsidy export lnlabor age,rx(acfoutput) qx(acfoutput) thnum(1) bs(300) trim(0.01) grid(100)
xthreg offshoring acfvalue_cost research subsidy export lnlabor age,rx(acfvalue) qx(acfvalue) thnum(1) bs(300) trim(0.01) grid(100)
xthreg offshoring acfoutput_cost research subsidy export lnlabor age,rx(acfoutput) qx(acfoutput) thnum(1) bs(300) trim(0.01) grid(100)
xthreg offshoring acfvalue_time research subsidy export lnlabor age,rx(acfvalue) qx(acfvalue) thnum(1) bs(300) trim(0.01) grid(100)
xthreg offshoring acfoutput_time research subsidy export lnlabor age,rx(acfoutput) qx(acfoutput) thnum(1) bs(300) trim(0.01) grid(100)


//表4
xtreg offshoring relativerle capitalintensity laborintensity rdintensity elasticity research subsidy export lnlabor age i.firmid i.year,fe
xtreg offshoring cost capitalintensity laborintensity rdintensity elasticity research subsidy export lnlabor age i.firmid i.year,fe
xtreg offshoring lntime capitalintensity laborintensity rdintensity elasticity research subsidy export lnlabor age i.firmid i.year,fe


//表5
xtivreg2 offshoring capitalintensity elasticity research subsidy export lnlabor age (relativerle=english french social german scandinavian),fe
xtivreg2 offshoring capitalintensity elasticity research subsidy export lnlabor age (cost=english french social german scandinavian),fe
xtivreg2 offshoring capitalintensity elasticity research subsidy export lnlabor age (lntime=english french social german scandinavian),fe
