稿件:econometrics666@126.com
所有计量经济圈方法论丛的code程序, 宏微观数据库和各种软件都放在社群里.欢迎到计量经济圈社群交流访问.
近日,收到一群友投稿,为各位青年学者,尤其是研究生,分享了一份文章的代码和数据。可以完整复制出文章的实证结果,各位有需要的,可以以此练练手。
cd "C:\Users\xiwan\Desktop"
use cgss2013_14.dta, clear
quietly {
label var Female "if female"recode a7a (1=0) (2 3=1) (4=2) (5/8=3) (9 10=4) (11/13=5) (else=.), gen(Education)label var Education "education level"recode a501 (1=0) (0=1) (else=.), gen(Religion)recode s5a (5=0) (1 2 3 4=1)(else=.), gen(Urban)label var Urban "urban area"gen Inc = a8a if inrange(a8a,0,1000000)label var Inc "total income"recode a10 (3 4=0)(1=1) (else=.), gen(CPC)label var CPC "if CP member"recode a89c (1=1)(2/4=0)(else=.), gen(F_CPC)label var F_CPC "if father CP member"recode a90c (1=1)(2/4=0)(else=.), gen(M_CPC)label var M_CPC "if mather CP member"recode a89g (1 3 6=1)(2 4 5=0)(else=.), gen(F_Unit)label var F_Unit "Father's work unit"gen Health = a15 if a15>0 //越大越健康recode a311 (1/2=1) (3=2) (4/5=3) (else=.), gen(S_Activity)recode a44 (1=1) (2=0) (else=.), gen(Vote)label var Prov "province"recode a43a (1/2=1) (3=2) (4=3) (5=4) (6=5) (7/10=6) (else =.),gen(S_Class)label var S_Class "your social status"recode b1 (3=1)(1 2=0)(else=.), gen(Hstatus)recode b2 (3=1)(1 2=0)(else=.), gen(Vstatus)recode a89b (1=0) (2 3=1) (4=2) (5/8=3) (9 10=4) (11/13=5) (else=.), gen(F_Edu)recode a90b (1=0) (2 3=1) (4=2) (5/8=3) (9 10=4) (11/13=5) (else=.), gen(M_Edu)gen P_Education = round(max(F_Edu, M_Edu))gen P_CPC = 1 if F_CPC ==1 | M_CPC==1replace P_CPC = 0 if P_CPC==.recode b24 (1=0)(2=1)(3=2)(4=3)(5=4)(else=.), gen(Evaluate1)recode b23 (1=0)(2=1)(3=2)(4=3)(5=4)(else=.), gen(Evaluate2)gen Evaluation = Evaluate1 + Evaluate2recode b2201 (3=2)(2=1)(1=0)(else=.), gen(Category1)recode b2202 (3=2)(2=1)(1=0)(else=.), gen(Discuss1)recode b2203 (3=2)(2=1)(1=0)(else=.), gen(Bag1)recode b2204 (3=2)(2=1)(1=0)(else=.), gen(Recycle1)recode b2205 (3=2)(2=1)(1=0)(else=.), gen(Donate1)recode b2206 (3=2)(2=1)(1=0)(else=.), gen(Attention1)recode b2207 (3=2)(2=1)(1=0)(else=.), gen(Promote1)recode b2208 (3=2)(2=1)(1=0)(else=.), gen(Participate1)recode b2209 (3=2)(2=1)(1=0)(else=.), gen(Forest1)recode b2210 (3=2)(2=1)(1=0)(else=.), gen(Solution1)gen EPB = Category1 + Discuss1 + Bag1 + Recycle1 + Donate1 + Attention1 + Promote1 + Participate1 + Forest1 + Solution1gen DEPB = Category1 + Bag1 + Recycle1gen PEAP = Discuss1 + Donate1 + Attention1 + Promote1 +Participate1 + Solution1gen Environment3 =Donate1 +Promote1 + Participate1 + Forest1 + Solution1recode a285 (1=0)(2=1)(3=2)(4=3)(5=4)(else=.), gen(Internet)bysort s44: egen meanx=mean(Internet)by s44: egen ctx = count(Internet)gen Internetc = (meanx*ctx-Internet)/(ctx-1)recode a284 (1=0)(2 3 4 5=1)(else=.), gen(television)recode a283 (1=0)(2 3 4 5=1)(else=.), gen(broadcast)recode a282 (1=0)(2 3 4 5=1)(else=.), gen(magazine)recode a281 (1=0)(2 3 4 5=1)(else=.), gen(newspaper)
**测度环保知识:正确回答问题的个数或正确回答问题的个数占总问题的比例
recode b2501 (2=1)(1 3=0)(else=.), gen(Env1)recode b2502 (1=1)(2 3=0)(else=.), gen(Env2)recode b2503 (2=1)(1 3=0)(else=.), gen(Env3)recode b2504 (1=1)(2 3=0)(else=.), gen(Env4)recode b2505 (2=1)(1 3=0)(else=.), gen(Env5)recode b2506 (1=1)(2 3=0)(else=.), gen(Env6)recode b2507 (2=1)(1 3=0)(else=.), gen(Env7)recode b2508 (1=1)(2 3=0)(else=.), gen(Env8)recode b2509 (2=1)(1 3=0)(else=.), gen(Env9)recode b2510 (1=1)(2 3=0)(else=.), gen(Env10)gen Knowleadge = Env1 + Env2 + Env3 + Env4 + Env5 + Env6 + Env7 + Env8 + Env9 + Env10
**测度对当地环境污染问题的了解情况
recode b21a01 (1=1)(2=0)(else=.), gen(Sense1)recode b21a02 (1=1)(2=0)(else=.), gen(Sense2)recode b21a03 (1=1)(2=0)(else=.), gen(Sense3)recode b21a04 (1=1)(2=0)(else=.), gen(Sense4)recode b21a05 (1=1)(2=0)(else=.), gen(Sense5)recode b21a06 (1=1)(2=0)(else=.), gen(Sense6)recode b21a07 (1=1)(2=0)(else=.), gen(Sense7)recode b21a08 (1=1)(2=0)(else=.), gen(Sense8)recode b21a09 (1=1)(2=0)(else=.), gen(Sense9)recode b21a10 (1=1)(2=0)(else=.), gen(Sense10)recode b21a11 (1=1)(2=0)(else=.), gen(Sense11)recode b21a12 (1=1)(2=0)(else=.), gen(Sense12)gen Sense = Sense1 + Sense2 + Sense3 + Sense4 + Sense5 + Sense6 + Sense7 + Sense8 + Sense9 + Sense10 + Sense11 + Sense12merge m:1 s41 using pollute.dta, gen(merge)keep if merge==3 //与从中国环境统计年鉴中的数据污染数据合并, pollute为省级废水排放总量、二氧化硫排放总量、氮氧化物排放总量、烟(粉)尘排放总量、工业固体废物产生量5个指标(单位为万吨)gen Pollution = pollution
global yx EPB DEPB PEAP Internet Female Urban CPC Education Income Religion Health S_Activity S_Class Vote Age Age2 Pollution F_Unit P_CPC P_Education
foreach y of global yx {
}
use sample.dta, clear
/*****************************************
实证结果
******************************************/
quietly {
/*****************************************
Table 1.
******************************************/
global yx1 EPB Internet Female Urban CPC Education Income Religion Health S_Activity S_Class Vote Age Age2 Pollution F_Unit P_CPC P_Educationtabstat $yx1 Knowleadge Sense Evaluation, stat(N mean sd min max) format(%6.3f) saveputexcel set table1.xlsx, replaceputexcel A1 = ("descriptive statistics")
/*****************************************
Table 2
******************************************/
global xlist2 Female Urban CPC Education Income Religion Health S_Activity S_Class Vote Age Age2 Pollution i.Provglobal xlist3 Female Urban CPC Education Income Religion Health S_Activity S_Class Vote Age Age2 Pollution F_Unit P_CPC P_Education i.Provoprobit EPB Internet i.Prov, vce(robust)oprobit EPB Internet $xlist2, vce(robust)oprobit EPB Internet $xlist3, vce(robust)reg EPB Internet i.Prov, vce(robust)reg EPB Internet $xlist2, vce(robust)reg EPB Internet $xlist3, vce(robust)
/*****************************************
Table 3
******************************************/
gen age =1 if Age>=17 & Age<= 30 //青年群体replace age = 2 if Age>=31 & Age<=44 //replace age = 3 if Age>=45 & Age<=64 //中年群体replace age = 4 if Age>=65 //中年群体reg EPB c.Internet##i.age $xlist3, vce(robust) //年长一些互联网效应更为明显oprobit EPB c.Internet##i.age $xlist3, vce(robust) //年长一些互联网效应更为明显reg EPB c.Internet##i.Rural $xlist3, vce(robust) //农村地区互联网效应更为明显oprobit EPB c.Internet##i.Rural $xlist3, vce(robust) //农村地区互联网效应更为明显gen lowincome = 1 if Income < 9.615872replace lowincome = 0 if Income >= 9.615872reg EPB c.Internet##i.lowincome $xlist3, vce(robust) //收入越低互联网效应更为明显oprobit EPB c.Internet##i.lowincome $xlist3, vce(robust) //收入越低互联网效应更为明显
/*****************************************
Table 4
******************************************/
eoprobit EPB $xlist3, endog(Internet = Internetc $xlist3)ivreg2 EPB $xlist3 (Internet = Internetc), first
/*****************************************
Table 5
******************************************/
ivreg2 EPB Knowleadge $xlist3 (Internet = Internetc), firstivreg2 EPB Sense $xlist3 (Internet = Internetc), firstivreg2 EPB Knowleadge Sense $xlist3 (Internet = Internetc), firstivreg2 EPB Evaluation $xlist3 (Internet = Internetc), first
/*****************************************
Table 6
******************************************/
eoprobit DEPB $xlist3, endog(Internet = Internetc $xlist3)eoprobit PEAP $xlist3, endog(Internet = Internetc $xlist3)eoprobit EPB television broadcast newspaper $xlist3, endog(Internet = Internetc $xlist3)ivreg2 DEPB $xlist3 (Internet = Internetc), firstivreg2 PEAP $xlist3 (Internet = Internetc), firstivreg2 EPB television broadcast newspaper $xlist3 (Internet = Internetc), first
/*****************************************
输出回归结果
******************************************/
esttab m11 m21 m31 m1 m2 m3 using Table2.rtf, pr2 b(%9.3f) star(* 0.1 ** 0.05 *** 0.01) se r2 replace //Table 2esttab mmm1 mmm2 mmm3 mm1 mm2 mm3 using Table3.rtf, keep(2.age#c.Internet 3.age#c.Internet 4.age#c.Internet 1.Rural#c.Internet 1.lowincome#c.Internet ) pr2 b(%9.3f) star(* 0.1 ** 0.05 *** 0.01) se r2 replace //Table 3esttab miv1 miv2 using Table4.rtf, keep(Internet Internetc) pr2 b(%9.3f) star(* 0.1 ** 0.05 *** 0.01) se r2 replace //Table 4esttab miv2 ma1 mb1 mc1 md1 using Table5.rtf, keep(Internet Knowleadge Sense Evaluation) pr2 b(%9.3f) star(* 0.1 ** 0.05 *** 0.01) se r2 replace //Table 5esttab xm1 xm2 xm3 xm11 xm21 xm31 using Table6.rtf, keep(Internet television broadcast newspaper) pr2 b(%9.3f) star(* 0.1 ** 0.05 *** 0.01) se r2 replace //Table 6
}
***脚注⑥的回归结果
oprobit Knowleadge Internet $xlist3, vce(robust)oprobit Sense Internet $xlist3, vce(robust)oprobit Evaluation Internet $xlist3, vce(robust)esttab x1 x2 x3 using jiaozhu6.rtf, keep(Internet) pr2 b(%9.3f) star(* 0.1 ** 0.05 *** 0.01) se r2 replace //脚注⑥
数据和代码下载地址:https://doi.org/10.7910/DVN/GPC4DI
进入之后,选择右下方的“RAR Archive”下载即可。
互联网使用提升了个体环保参与度吗?[J].环境经济研究,2021,6(02):100-119.