全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件 Stata专版
3329 8
2013-03-21
我有一个900多case的Stata数据,想用其中的一半来做探索性因素分析,另一半做验证性因素分析。
用sample命令的时候,只能保留一半,另一半则被删除了

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

谢谢!
二维码

扫码加我 拉你入群

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

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

全部回复
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数据文件?
二维码

扫码加我 拉你入群

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

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

2013-3-22 10:13:25
help bsample
二维码

扫码加我 拉你入群

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

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

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(),这样做没问题吧?
谢谢!
二维码

扫码加我 拉你入群

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

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

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

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