楼主: BIG钊钊
7089 4

[编程问题求助] code求解释,covs是什么? [推广有奖]

  • 0关注
  • 7粉丝

副教授

63%

还不是VIP/贵宾

-

威望
1
论坛币
17253 个
通用积分
97.8006
学术水平
37 点
热心指数
47 点
信用等级
30 点
经验
5076 点
帖子
528
精华
0
在线时间
716 小时
注册时间
2012-1-24
最后登录
2024-4-22

相似文件 换一批

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
今天读论文,学习作者的原代码。该论文是用stata做的数据,其中有一块不是很明白。已经标红,请各位帮忙解释解释。
  1. *Table 2 - Are Prices Lower When More Students Are Enrolled Online?*
  2. foreach x in pub nonpub {
  3.         xi: reg log_tuit share_alldist share_somedist i.year log_enroll `covs' if `x', robust
  4.         outreg2 using price_online, keep(share_alldist share_somedist) alpha(0.01, 0.05, 0.10) bracket nocons excel dec(3)
  5.         xtset cbsa
  6.         xi: xtreg log_tuit share_alldist share_somedist i.year log_enroll `covs' if `x'==1, fe vce(cluster cbsa)
  7.         outreg2 using price_online, keep(share_alldist share_somedist) alpha(0.01, 0.05, 0.10) bracket nocons excel dec(3)
  8.         xtset opeid_year_group
  9.         xi: xtreg log_tuit share_alldist share_somedist i.year log_enroll `covs' if `x'==1, fe vce(cluster opeid_year_group)
  10.         outreg2 using price_online, keep(share_alldist share_somedist) alpha(0.01, 0.05, 0.10) bracket nocons excel dec(3)                        
  11. }        
复制代码
`covs' if `x'及下面对应的几个是什么意思呢?
Can online learning bend the higher education cost curve.pdf (478.44 KB) DGKY_online_replication.dta (71.78 MB)
不知道为什么do文件上传失败,贴在这里吧:
  1. /*

  2. Replication file for Deming, Goldin, Katz and Yuchtman. "Can Online Education Bend the Higher Education Cost Curve?"
  3. American Economic Review: Papers & Proceedings, 105(5): 496-501.

  4. We provide a cleaned data set for replication. To replicate from the raw IPEDS files, here are the steps:

  5. Start by obtaining raw csv files from the IPEDS website
  6. They can be found here - http://nces.ed.gov/ipeds/datacenter/DataFiles.aspx
  7. The site includes stata do files for reading csv into .dta format and labeling vars.
  8. For tables 1 and 2, only 2012 and 2013 data are necessary.
  9. Download the following files - hd2012, efa2012 and efa2012_dist - same for 2013.
  10. Add local and state unemployment rate data from the BLS - http://www.bls.gov/lau/#data.
  11. Finally, add data from the 2009 Barron's college rankings, merging on unitid.
  12. */
  13. cd "YOUR DIR HERE"
  14. use DGKY_online_replication, clear

  15. drop if opeflag==5 | opeflag==6
  16. keep if year==2012 | year==2013
  17. drop if cyactive!=1
  18. drop if sector==0
  19. gen type_cat=type
  20. replace type_cat=6 if type_cat==5
  21. replace type_cat=5 if type_cat==4
  22. replace type_cat=4 if type_cat==3
  23. replace type_cat=3 if type_cat==2 & (sector==4 | sector==7)

  24. *replace tot variable with enroll_UGdegseek - small number of institutions that didnt' respond to distance ed survey - all FPs*
  25. *assume zero online enrollment*
  26. replace tot=enroll_UGdegseek if tot==.
  27. foreach x in alldist somedist nodist {
  28.         gen share_`x'=`x'/tot
  29. }
  30. foreach x in alldist_instate alldist_outstate alldist_outUS {
  31.         gen share_`x'=`x'/alldist
  32. }

  33. *Table 1 - Enrollment in Online Courses by Undergraduate, Degree-Seeking US Students 2013*
  34. *Divide percentages in first three columns by fourth column to get totals*
  35. tabstat alldist somedist nodist tot if year==2013, by(type_cat) s(sum)
  36. *Divide percentages in first three columns by fourth column to get totals*
  37. tabstat alldist_instate alldist_outstate alldist_outUS alldist if year==2013, by(type_cat) s(sum)

  38. *Set up for price regressions*
  39. gen log_enroll=ln(tot)
  40. gen log_tuit=ln(statetuit)
  41. gen log_charge=ln(hrchg2)

  42. *geographic FE use CBSA, CSA, county - results don't change that much*
  43. *for chain results, use first 5 digits of opeid*
  44. gen length=length(opeid)
  45. gen temp1="0"
  46. gen temp2="00"
  47. egen temp3=concat(temp1 opeid) if length==7
  48. egen temp4=concat(temp2 opeid) if length==6
  49. gen opeid_string=temp3 if length==7
  50. replace opeid_string=temp4 if length==6
  51. replace opeid_string=opeid if length==8

  52. gen opeid_6=substr(opeid_string,1,6)
  53. egen opeid_year_group=group(opeid_6 year sector)

  54. set more off
  55. local covs "i.sector i.type_cat i.iclevel i.control i.hloffer i.deggrant i.locale unemp_rate miss_unemp i.barrons_rank_2009 i.admcon1 i.admcon2 i.admcon3 i.admcon4 i.admcon5 i.admcon6 i.admcon7 i.admcon8 i.admcon9 i.openadmp satpct- actwr75 satpct_miss- actwr75_miss"
  56. gen nonpub=nfp==1 | fp==1

  57. *Table 2 - Are Prices Lower When More Students Are Enrolled Online?*
  58. foreach x in pub nonpub {
  59.         xi: reg log_tuit share_alldist share_somedist i.year log_enroll `covs' if `x', robust
  60.         outreg2 using price_online, keep(share_alldist share_somedist) alpha(0.01, 0.05, 0.10) bracket nocons excel dec(3)
  61.         xtset cbsa
  62.         xi: xtreg log_tuit share_alldist share_somedist i.year log_enroll `covs' if `x'==1, fe vce(cluster cbsa)
  63.         outreg2 using price_online, keep(share_alldist share_somedist) alpha(0.01, 0.05, 0.10) bracket nocons excel dec(3)
  64.         xtset opeid_year_group
  65.         xi: xtreg log_tuit share_alldist share_somedist i.year log_enroll `covs' if `x'==1, fe vce(cluster opeid_year_group)
  66.         outreg2 using price_online, keep(share_alldist share_somedist) alpha(0.01, 0.05, 0.10) bracket nocons excel dec(3)                       
  67. }

  68.        
  69. /*
  70. For Figure 1, need trend data going back to 2000.
  71. Pull the following IPEDS files (in addition to files from 2000-2011:
  72. hd (directory variables
  73. efa (enrollment - note file is by race and gender but just use overall)
  74. ic_ay - (tuition and fees - note some schools report tuition by program rather than overall. when overall tuition is missing, replace with tuition of most common program)

  75. Merge these files on unitid and year.
  76. */

  77. use DGKY_online_replication, clear

  78. *Create indicator variable for online schools, based on having more than 50% of students enrolled in exclusively distance education in 2012*
  79. *Backcast after that for years with no distance education data*

  80. gen share_alldist= alldist/ tot if year==2012
  81. gen temp=share_alldist>0.5 & share_alldist!=.
  82. bysort unitid: egen online=max(temp)
  83. drop temp
  84. *drop very competitive or higher, using Barron's rankings*
  85. drop if barrons_rank>=1 & barrons_rank<=3
  86. *Restrict to active, Title IV eligible institutions*
  87. keep if cyactive==1
  88. keep if opeflag==1

  89. *Fix an obvious mistake in U Phoenix tuition variable - in 2001, data was reported as the total cost of a 4 year degree instead of per-year tuition cost*
  90. *This typically happens when tuition is reported at the program level*
  91. *Ideally would not use this variable, but then tuition is missing for many for-profits and not evenly by year*
  92. *Price goes from around $15k to $63k in a single year, and then back down*
  93. *Solution is to divide by four*
  94. gen phoenix=regexm(instnm, "University Of Phoenix")
  95. replace statetuit=statetuit/4 if phoenix==1 & year==2001

  96. *Fix a small number of other similar mistakes - dividing by four or two, as appropriate*
  97. *Issue is that tuition is inconsistently reported at program vs. school level*
  98. *These fixes are conservative - needs to be almost exactly 4x or 2x tuition in years right around*
  99. *This is an art, not a science!*
  100. replace statetuit=statetuit/4 if unitid==102845 & year>=2002 & year<=2003
  101. replace statetuit=statetuit/2 if unitid==438601 & year>=2001 & year<=2002
  102. replace statetuit=statetuit/4 if unitid==438601 & year>=2003 & year<=2004
  103. replace statetuit=statetuit/4 if unitid==448628 & year==2006
  104. replace statetuit=statetuit/2 if unitid==121275 & year>=2003 & year<=2004
  105. replace statetuit=statetuit/2 if unitid==234216 & year>=2002 & year<=2003
  106. replace statetuit=statetuit/4 if unitid==234216 & year>=2004 & year<=2009
  107. replace statetuit=statetuit/4 if unitid==142054 & year>=2004 & year<=2005
  108. replace statetuit=statetuit/2 if unitid==197832 & year>=2002 & year<=2004
  109. replace statetuit=statetuit/2 if unitid==440925 & year>=2002 & year<=2003
  110. replace statetuit=statetuit/2 if unitid==441061 & year>=2003 & year<=2005
  111. replace statetuit=statetuit/2 if unitid==262305 & year>=2003 & year<=2005
  112. replace statetuit=statetuit/2 if unitid==436474 & year>=2003 & year<=2004
  113. replace statetuit=statetuit/2 if unitid==260813 & year>=2000 & year<=2004
  114. replace statetuit=statetuit/2 if unitid==432834 & year>=2003 & year<=2009
  115. replace statetuit=statetuit/2 if unitid==260789 & year>=2003 & year<=2009
  116. replace statetuit=statetuit/4 if unitid==437848 & year==2002
  117. replace statetuit=statetuit/2 if unitid==135939 & year>=2004 & year<=2005
  118. replace statetuit=statetuit/2 if unitid==103893 & year>=2000 & year<=2001

  119. *adjust for inflation, expressing in 2014 dollars, using http://data.bls.gov/cgi-bin/cpicalc.pl*
  120. replace statetuit=statetuit*1.37 if year==2000
  121. replace statetuit=statetuit*1.34 if year==2001
  122. replace statetuit=statetuit*1.32 if year==2002
  123. replace statetuit=statetuit*1.29 if year==2003
  124. replace statetuit=statetuit*1.25 if year==2004
  125. replace statetuit=statetuit*1.21 if year==2005
  126. replace statetuit=statetuit*1.17 if year==2006
  127. replace statetuit=statetuit*1.14 if year==2007
  128. replace statetuit=statetuit*1.10 if year==2008
  129. replace statetuit=statetuit*1.10 if year==2009
  130. replace statetuit=statetuit*1.09 if year==2010
  131. replace statetuit=statetuit*1.05 if year==2011
  132. replace statetuit=statetuit*1.03 if year==2012
  133. replace statetuit=statetuit*1.02 if year==2013

  134. gen cat=1 if online==1 & pub!=1 & (barrons_rank==5 | barrons_rank==.)
  135. replace cat=2 if online!=1 & (barrons_rank==5 | barrons_rank==.) & (sector==2 | sector==3)
  136. replace cat=3 if sector==1

  137. collapse (mean) statetuit [w=enrollFTUG], by(cat year)
  138. drop if cat==.
  139. forvalues y=1(1)3 {
  140. gen temp=statetuit if cat==`y'
  141. bysort year: egen statetuit_`y'=max(temp)
  142. drop temp
  143. }
  144. drop cat statetuit
  145. duplicates drop
  146. tsset year

  147. *Figure 1 - Trends in Tuition by Institution Type*
  148. tsline statetuit_1 statetuit_2 statetuit_3
复制代码


二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:code COD ODE Institutions unemployment Online excel 论文

沙发
BIG钊钊 学生认证  发表于 2015-12-2 06:19:02 来自手机 |只看作者 |坛友微信交流群
自己顶起来一下下

使用道具

藤椅
夏目贵志 发表于 2015-12-2 12:17:48 |只看作者 |坛友微信交流群
请看一下帮助文件里关于macro的部分。你给的程序里好像没有定义covs,x的话就是pub nonpub这两个值。这两个因该是0/1型的变量,可以直接用于判断。相当于是if `x'==1

使用道具

板凳
BIG钊钊 学生认证  发表于 2015-12-2 12:29:42 |只看作者 |坛友微信交流群
夏目贵志 发表于 2015-12-2 12:17
请看一下帮助文件里关于macro的部分。你给的程序里好像没有定义covs,x的话就是pub nonpub这两个值。这两个 ...
  1. set more off
  2. local covs "i.sector i.type_cat i.iclevel i.control i.hloffer i.deggrant i.locale unemp_rate miss_unemp i.barrons_rank_2009 i.admcon1 i.admcon2 i.admcon3 i.admcon4 i.admcon5 i.admcon6 i.admcon7 i.admcon8 i.admcon9 i.openadmp satpct- actwr75 satpct_miss- actwr75_miss"
  3. gen nonpub=nfp==1 | fp==1
复制代码
这个是不是就是定义covs啊?因为我一直用的是R,所以对stata完全不熟悉,赶上又要做这篇论文,我把整个数据,论文,do文件什么的都上传一下吧

使用道具

报纸
夏目贵志 发表于 2015-12-2 13:17:01 |只看作者 |坛友微信交流群
BIG钊钊 发表于 2015-12-2 12:29
这个是不是就是定义covs啊?因为我一直用的是R,所以对stata完全不熟悉,赶上又要做这篇论文,我把整个数 ...
第二行是定义covs的。没错!
你这个程序其实不看文章很难彻底搞明白吧。祝好运~!

使用道具

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注jltj
拉您入交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-4-26 18:10