楼主: hzsh2009
4247 35

[其他] 储存 运行regression完的数据 [推广有奖]

21
大白菜2012 发表于 2012-10-14 02:43:43
hzsh2009 发表于 2012-10-14 02:27
还有个小问题,如果还有个变量index要加入怎么办呢? 就是比如数据是4项
y   x    year   index, 那我先 ...
it works. see this sample,

sysuse auto, clear
statsby _b, by(rep78 foreign):  reg price mpg
l
元芳,侬怎么L00K?

22
sungmoo 发表于 2012-10-14 06:35:54
我试了下 statsby _b, clear by(year&index): reg y x* 好像不行
statsby _b, clear by(year index): reg y x*

*前面给出的链接中其实就是二维分类的

23
hzsh2009 发表于 2012-10-14 08:24:49
sungmoo 发表于 2012-10-14 06:35
statsby _b, clear by(year index): reg y x*

*前面给出的链接中其实就是二维分类的
恩这个的确可以了,但现在我的问题是想用 xtreg 而不是reg。
但xtreg要先xtset数据好像。我xtset ind year时又出现repeated time values within panel。
于是我用 duplicates drop id year, force把重复的数据删了。 再重新
xtset ind year
statsby _b, clear by(ind year): xtreg y x*
这时又显示
      command:  xtreg y x*
           by:  ind year

Statsby groups
----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5
xxxxxxxx

然后只剩 ind 和 year , _b_x        _b_cons 都没数据显示
ind        year        _b_x        _b_cons
0        1997               
0        1998               
0        1999               
0        2000               
1        1997               
1        1998               
1        1999               
1        2000               
真是很奇怪。。能帮忙解释下吗?

24
hzsh2009 发表于 2012-10-14 08:25:56
大白菜2012 发表于 2012-10-14 02:43
it works. see this sample,

sysuse auto, clear
能再帮忙看下上面xtset这一问题吗?谢谢!

25
大白菜2012 发表于 2012-10-14 10:56:36
hzsh2009 发表于 2012-10-14 08:25
能再帮忙看下上面xtset这一问题吗?谢谢!
好奇,你的research question 是什么?为什么要用xtreg?你只有清楚的说明了你的Q,和你的rationale of statistics approach,大家才能有的放矢的帮你写code
元芳,侬怎么L00K?

26
sungmoo 发表于 2012-10-14 12:00:46
xtset ind year
statsby _b, clear by(ind year): xtreg y x*
你能把panel data模型的意义说一下吗?

27
hzsh2009 发表于 2012-10-14 12:17:52
大白菜2012 发表于 2012-10-14 10:56
好奇,你的research question 是什么?为什么要用xtreg?你只有清楚的说明了你的Q,和你的rationale of s ...
最终的目的是 exchange rate pass through,就是汇率变化对进口物品价格的影响吧。 但我因为是初学,现在任务只是学习编些简单的code。 所以数据什么都是要自己编的。 新建 Microsoft Office Excel 工作表.xlsx (13.47 KB) 比如excel中的x,y就是电脑随机设的,ind和year也是我任意设的。
然后我指令是
duplicates drop ind year, force
xtset ind year
statsby _b, clear by(ind year): xtreg y x*
结果就出现上述问题了。
xtreg是教授说试试的,还没说原因。。



28
hzsh2009 发表于 2012-10-14 12:29:57
sungmoo 发表于 2012-10-14 12:00
你能把panel data模型的意义说一下吗?
见上,我只是负责试验code现在,所以说没有什么直接的意义。xtreg也纯粹只是想找fixed effect。所以也不知道我code出错在哪。。

29
hzsh2009 发表于 2012-10-14 12:31:40
sungmoo 发表于 2012-10-14 12:00
你能把panel data模型的意义说一下吗?
见上,我只是负责试验code现在,所以说没有什么直接的意义。xtreg也纯粹只是想找fixed effect。所以也不知道我code出错在哪。。

30
大白菜2012 发表于 2012-10-14 12:53:48
hzsh2009 发表于 2012-10-14 12:17
最终的目的是 exchange rate pass through,就是汇率变化对进口物品价格的影响吧。 但我因为是初学,现在 ...
我和sungmoo想的一样,你应该先了解what is fixed effect,然后再回过头来看stata 里相关命令的运用。否则的话,真的是浪费你自己的时间。


题外话,学Stata,不光是编程技巧,更重要的是相关的统计学知识。共勉!
已有 1 人评分热心指数 收起 理由
hzsh2009 + 1 好的意见建议

总评分: 热心指数 + 1   查看全部评分

元芳,侬怎么L00K?

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

本版微信群
加好友,备注jltj
拉您入交流群
GMT+8, 2026-1-15 07:31