楼主: fishkk123
1925 5

[其他] 求教stata代码 [推广有奖]

  • 0关注
  • 0粉丝

等待验证会员

学前班

60%

还不是VIP/贵宾

-

威望
0
论坛币
0 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
26 点
帖子
3
精华
0
在线时间
0 小时
注册时间
2012-10-16
最后登录
2012-10-16

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
研究了很久stata都不是很会,老师给的作业做了一天也不懂

求教高手..其中一个题目感觉很简单就是不会做...

assume a model and a disturbance term u: Y= a+b*x+u
choose 30 obs of data for x, and values for the parameters of the model
c)generate a disturbance term using a normal disturibution with zero mean and unit varinace. then generate the value of Y
d)regress Y on x using the ols estimation technique and collect the estimated coefficient b1 and b2
repeat c) and d) 200 times and generate two scatter plot graphs, one for each b1 and b2.

需要先设置model吗?基本做到b问就卡住了,以前学都是winrats什么之类的,stata第一次接触,有没有比较好的教程....谢谢
二维码

扫码加我 拉你入群

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

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

关键词:求教stata Stata tata Disturbance coefficient generate collect normal values

沙发
大白菜2012 发表于 2012-10-16 05:10:31 |只看作者 |坛友微信交流群
enjoy!


clear

//here is ur data;
set obs 300
gen x=runiform()

//randomly select 10% of data
sample 10


gen a=2
gen b=3

//run 200 times
forval x=1/200 {
preserve

//generate a disturbance term using a normal disturibution with zero mean and 1 varinace
gen u=rnormal(0,1)

//create y based on a and b
gen  y=a+b*x+u

//save coefficents into matrix
qui regress y x
if `x'==1 {
matrix M=e(b)
}
else {
matrix M=M\e(b)
}

restore
}

//matrix into data
clear
svmat M, names(b)

//plot
scatter b1 b2
元芳,侬怎么L00K?

使用道具

藤椅
fishkk123 发表于 2012-10-16 08:02:40 |只看作者 |坛友微信交流群
大白菜2012 发表于 2012-10-16 05:10
enjoy!
非常感性大神

使用道具

板凳
fgleric 发表于 2012-10-16 08:17:00 |只看作者 |坛友微信交流群
哈哈,小朋友是在学习计量吧,你老师风格很像我认识的某位澳大利亚籍老师。

楼上给出的是stata,你还是用matlab做吧。

使用道具

报纸
fishkk123 发表于 2012-10-16 08:53:55 |只看作者 |坛友微信交流群
大白菜2012 发表于 2012-10-16 05:10
enjoy!
大神,

if 'x' == 1{
matrix M=e(b)
}

else{
matrix M=M\e(b)
}


这好像不对,出不来,然后最后的clear需要吗?最后
svmat M, names(b)


scatter b1 b2

也出不来.....求解....谢谢

使用道具

地板
大白菜2012 发表于 2012-10-16 09:09:57 |只看作者 |坛友微信交流群
fishkk123 发表于 2012-10-16 08:53
大神,

if 'x' == 1{
`x' instead of 'x'
元芳,侬怎么L00K?

使用道具

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

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

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

GMT+8, 2024-5-12 01:09