全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件 Stata专版
4361 4
2012-11-05
悬赏 100 个论坛币 已解决
现有一个panel data数据集,结构如下
i   t  y   x
1 1  1  2
1 2  3  4
2 1  5  6
2 2  7  8
...
个体i有100个,如果我想从i中随机选择80个,其面板结构不受影响,请问在stata里该如何操作?谢谢

最佳答案

大白菜2012 查看完整内容

input /// i t y x 1 1 1 2 1 2 3 4 2 1 5 6 2 2 7 8 3 1 4 5 3 2 4 7 end set seed 2012 sort i t reshape wide y x, i(i) j(t) sample 80 //draw a 80% sample reshape long y x, i(i) j(t)
二维码

扫码加我 拉你入群

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

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

全部回复
2012-11-5 11:05:14
input                 ///
i   t  y   x
1 1  1  2
1 2  3  4
2 1  5  6
2 2  7  8
3 1  4  5
3 2  4  7

end

set seed 2012

sort i t

reshape wide y x, i(i) j(t)

sample 80                //draw a 80% sample

reshape long y x, i(i) j(t)
二维码

扫码加我 拉你入群

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

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

2012-11-5 12:26:30
also, there are a couple of other ways to handle this issue.

please see

http://www.stata.com/support/faq ... /sampling-clusters/
二维码

扫码加我 拉你入群

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

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

2012-11-5 12:34:41
谢谢,我刚刚用sample实现了,你这个reshape不错
二维码

扫码加我 拉你入群

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

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

2012-11-5 13:16:48
hshly 发表于 2012-11-5 12:34
谢谢,我刚刚用sample实现了,你这个reshape不错
是, 这个更简单


bsample 80, cluster(i)
二维码

扫码加我 拉你入群

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

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

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群