楼主: lnulxg
4307 32

[编程问题求助] 编程我不会,只有求助朋友们帮助了! [推广有奖]

  • 69关注
  • 9粉丝

教师

已卖:989份资源

学科带头人

33%

还不是VIP/贵宾

-

威望
1
论坛币
16074 个
通用积分
5033.0465
学术水平
42 点
热心指数
55 点
信用等级
45 点
经验
53737 点
帖子
1749
精华
0
在线时间
1695 小时
注册时间
2004-8-31
最后登录
2025-12-24

楼主
lnulxg 发表于 2015-2-17 09:43:21 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
Home PC
cd "C:\Users\dell\Desktop\STATA20150120\20150303BOB"
capture log close
log using Econ4G03-assign2.log, text replace
capture drop _all
pause on
capture clear all
capture program drop hetero
program hetero, rclass
        clear
        args obs c
        set obs `obs'
        scalar df = `obs' - 2
        g x1 = rnormal(0,15)
        g error = rnormal(0,1) + rnormal(0,1)*x1*`c'
        egen double MeanError = mean(error)
        egen double SDError   = sd(error)
        replace error = ((error-MeanError)/SDError)*50
        g y  = 1 + 2*x1 + error
        reg  y x1
       
        return scalar b_ols                 = _b[x1]
        return scalar se_ols                 = _se[x1]
       
        return scalar p_ols1         = 2 * ttail(df, (abs(_b[x1]-2))/_se[x1])
        test x1=2
        return scalar p_ols2                = r(p)
       
        reg  y x1, vce(robust)
       
        return scalar b_r                 = _b[x1]
        return scalar se_r                 = _se[x1]
        return scalar p_r1       = 2 * ttail(df, (abs(_b[x1]-2))/_se[x1])
        test x1=2
        return scalar p_r2                = r(p)
end

set seed 2222
simulate b_ols=r(b_ols) se_ols=r(se_ols) p_ols1=r(p_ols1) p_ols2=r(p_ols2) ///
  b_r=r(b_r) se_r=r(se_r) p_r1=r(p_r1) p_r2=r(p_r2), ///
  saving(hetero,replace) reps(500) dots : hetero 15000 15


g StatSig_ols = (p_ols1<0.05)
g StatSig_r   = (p_r1<0.05)


tabstat b_ols se_ols se_r p_ols1 p_ols2 p_r1 p_r2 StatSig_ols StatSig_r, stat(mean q iqr)
pause
sum Stat*, d
pause

kdensity p_ols1, addplot(kdensity p_r1) legend(label(1 "P-values from OLS VCE") label(2 "P-values from Hetero VCE")) lpattern(dash)
pause


histogram p_ols1, bin (22)
pause
histogram p_r1, bin (22)
pause


Assignment 2 -- Questions

1) Run the Monte Carlo simulation above as it is currently structured
   and discuss the file and the output.
   There are two intermingled aspects to this:
   i) understanding and describing the Stata code; and
   ii) understanding the describing the substantive issue being addressed.
   (i.e., What is this simulation trying to illustrate?)

2) Play with the structure of the Monte Carlo (focus on adjusting the two
   arguments, but you may also want to make other ajustments).
   What patterns you can see? One simple approach is to see how the
   two Var-Cov estimators perform as the sample size and/or
   the "amount" of hetero changes. You could graph the results.
   More sophisticated questions could also be explored. Thinking about how
   to present the results is also an interesting exersize.

   In undertaking these
   simple experiments, think of the econometric theory you are learning
   (and maybe read the text to learn more).

   Warning: Clearly this is a question without an endpoint,
   so you need to judge how much effort to allocate to it
   -- do not go to an extreme in doing this.
   Think about identifying a specific research question, and then approach it
   in a structured manner.
   (In part, this sub-question might get you started in
   thinking about research in econometric theory.)

3) Hard part of the assignment. In their provocative textbook, Mostly Harmless
   Econometrics, Josh Angrist and Jorn-Steffen Pischke argue (albeit in a
   slightly different context) that a better approach to dealing with
   heteroskdasticity than using heteroskdasticity consistent standard
   errors is to estimate BOTH the traditional OLS std error and the
   heteroskedasticity consistent one and to use the larger of the two for
   inference. Modify the code above to explore this contention in a  
   limited -- i.e., choose case specific -- Monte Carlo consistent
   with the the approach above).

Warning: Relevant for (2) and (3). As currently written the Monte Carlo above
                 does not track many
                 features of the regressions being performed. For example, it does not
                 list the R2. If your Monte Carlo tests an extreme
                 case (say R2 = 0.001 or 0.98 -- that is, one extreme or the other)
                 this might be more or less interesting than a more "typical" case.
                 Extreme cases are OK, but you should be aware about whether the
                 case you are looking at is "typical" or not. For example,
                 most simple cross-sectional regressions in many areas of
                 economics have R2's of between 0.10 and 0.40; few would have R2's
                 of, say, 0.98 (although an R2 of 0.98 might be common in time series).

二维码

扫码加我 拉你入群

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

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

关键词:simulate capture replace Program Desktop 朋友

回帖推荐

夏目贵志 发表于22楼  查看完整内容

本科能教到这个程度,学校应该不错。不过这个明显也不到研究生的水平,所以努努力还是能搞定的。楼主加油!

沙发
lnulxg 发表于 2015-2-17 09:44:23
拜托大家了!

藤椅
yizst2 发表于 2015-2-17 10:07:25 来自手机
你在哪里上的这么高大上的课。

板凳
lnulxg 发表于 2015-2-17 13:24:15
我知道:大过年的,让朋友们帮忙,确实不应该!可我自己真的不懂STATA是如何进行编码的!祝朋友春节好!

报纸
lnulxg 发表于 2015-2-19 00:39:02
请高手指导指导啊!

地板
lnulxg 发表于 2015-2-20 15:12:00
看来是真不好弄啊!没有朋友回答嘛!

7
xiongjerry 发表于 2015-2-20 18:24:00
楼主就是高手

8
lnulxg 发表于 2015-2-20 19:07:13
不要笑话我了,我刚接触STATA,是朋友的孩子在美国读大学计量课程的作业题问我,我弄了一周了,还是不会啊!

9
soccy 发表于 2015-2-21 19:13:58
告诉人家你不会好了

10
lnulxg 发表于 2015-2-21 20:35:20
可是我也想弄明白阿,正好原来就想知道蒙特卡罗模拟如何做啊

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

本版微信群
加好友,备注jltj
拉您入交流群
GMT+8, 2025-12-28 14:04