楼主: 兵哥哥
3405 8

[数据管理求助] Stata怎么进行数据分半? 求助。。 [推广有奖]

  • 24关注
  • 6粉丝

已卖:744份资源

副教授

0%

还不是VIP/贵宾

-

威望
0
论坛币
9410 个
通用积分
10.8145
学术水平
11 点
热心指数
14 点
信用等级
10 点
经验
16149 点
帖子
331
精华
0
在线时间
748 小时
注册时间
2007-12-21
最后登录
2024-5-31

楼主
兵哥哥 在职认证  发表于 2013-3-21 16:52:17 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
我有一个900多case的Stata数据,想用其中的一半来做探索性因素分析,另一半做验证性因素分析。
用sample命令的时候,只能保留一半,另一半则被删除了

请问,我想将数据分半,随机的分成2份,2份做不同的分析。  这个随机分半的过程怎么实现?

谢谢!
二维码

扫码加我 拉你入群

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

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

关键词:Stata tata STATA数据 验证性因素分析 探索性因素分析 大侠

沙发
hplcdadong 发表于 2013-3-21 21:05:26
set seed 12345
gen random=runiform()
sort random
gen validation=_n<=450            //assume you sample size is 900
label define valid 1 "model_build" 0 "model_valid"
label val validation valid

藤椅
兵哥哥 在职认证  发表于 2013-3-21 23:32:55
hplcdadong 发表于 2013-3-21 21:05
set seed 12345
gen random=runiform()
sort random
感谢楼上!

我摸索了一个这样的
set obs 900
gen x=rnormal()
xtile x2=x, n(2)
然后导出数据到Mplus,加入一条if x2==1,或者if  x2==2

这样子可以吗?这样是随机分半了吗?

ps:怎么样将数据split成两个stata数据文件?

板凳
sewind_tj 发表于 2013-3-22 10:13:25
help bsample
善待你一生!
让网络基于真人的故事!

报纸
hplcdadong 发表于 2013-3-22 10:28:33
Your method may be Ok but it's not a standard procedure, especially the use of "rnormal()".  Personally I have never seen Stata experts use "rnormal()" instead of "runiform()" for the aim of random sampling.

As regards to splitting the Stata file, there are several methods, the simplest one is to find and install the command "savesome"

Good luck

地板
兵哥哥 在职认证  发表于 2013-3-22 17:31:48
hplcdadong 发表于 2013-3-22 10:28
Your method may be Ok but it's not a standard procedure, especially the use of "rnormal()".  Persona ...
如果我在上面原有的语句里面,用runiform()替换rnormal(),这样做没问题吧?
谢谢!

7
hplcdadong 发表于 2013-3-23 20:23:48
It should work for this case. But "xtile" can not handle complicated requirements. Actually there is a lit bit more simple way for your case

set seed 12345
gen random=runiform()
sort random
gen validation=group(2)            //any sample split half

8
兵哥哥 在职认证  发表于 2013-3-24 10:23:35
hplcdadong 发表于 2013-3-23 20:23
It should work for this case. But "xtile" can not handle complicated requirements. Actually there is ...
Thanks a lot

9
蓝_23 发表于 2013-3-27 10:13:26
直接复制,干嘛纠结,命令

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

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