楼主: hshly
4330 4

请教数据随机选择问题在stata中如何实现? [推广有奖]

  • 1关注
  • 25粉丝

高级会员

已卖:11份资源

学术权威

2%

还不是VIP/贵宾

-

威望
0
论坛币
1764352 个
通用积分
493.6863
学术水平
13 点
热心指数
17 点
信用等级
8 点
经验
37289 点
帖子
877
精华
0
在线时间
8660 小时
注册时间
2004-12-13
最后登录
2025-12-9

楼主
hshly 发表于 2012-11-5 11:05:13 |AI写论文
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)
关键词:Stata 如何实现 tata 选择问题 panel data 结构 面板 如何 影响

沙发
大白菜2012 发表于 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)
元芳,侬怎么L00K?

藤椅
大白菜2012 发表于 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/
元芳,侬怎么L00K?

板凳
hshly 发表于 2012-11-5 12:34:41
谢谢,我刚刚用sample实现了,你这个reshape不错

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


bsample 80, cluster(i)
已有 1 人评分热心指数 收起 理由
hshly + 1 精彩帖子

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

元芳,侬怎么L00K?

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

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