全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件 Stata专版
3471 22
2012-11-23
  比如rankext 3 6 结果有问题。
附件列表

exact.rar

大小:571 Bytes

 马上下载

本附件包括:

  • exact.do

二维码

扫码加我 拉你入群

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

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

全部回复
2012-12-27 08:39:47
这个程序的目的,可否简介一下?
二维码

扫码加我 拉你入群

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

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

2012-12-27 08:52:00
sungmoo 发表于 2012-12-27 08:39
这个程序的目的,可否简介一下?
样本含量小的时候 计算配对符号秩检验的确切概率。
二维码

扫码加我 拉你入群

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

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

2012-12-28 23:41:00
*上面的程序可以大幅减化(首数是样本量,末数是可能的秩和,求给定首数时末数对应的概率)
clear
cap pr drop rankext
pr rankext
args n e
if wordcount("`*'")!=2|int(`e')!=`e'|int(`n')!=`n'|`e'<0|`n'<0|`e'>`n'*(`n'+1)/2 {
n di as error "Two and only two nonnegative integers, of which"
n di as error "the last is smaller than the accumlated sum by the first, are allowed"
exit
}
qui{
clear
set ob `=2^`n''
forv i=1/`n'{
g v`i'=`i'*mod(int((_n-1)/2^(`n'-`i')),2)
}
egen exp=rowtotal(v*)
collapse (count)t=v1,by(exp)
egen p=pc(t),prop
su p if exp<=`e'

n di
n di in yellow "exact P-value for the ranksum of `e' given the sample size of `n' = " r(sum)
clear
}
end
二维码

扫码加我 拉你入群

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

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

2012-12-28 23:49:24
*上面的程序可以大幅减化:

clear
cap pr drop rankext
pr rankext
args e n
if wordcount("`*'")!=2|int(`e')!=`e'|int(`n')!=`n'|`e'<0|`n'<0|`e'>`n' {
n di in red "Two and only two nonnegative integers, of  which the 2nd is larger, are allowed"
exit
}
clear
qui{
set ob `=2^`n''
forv i=1/`n'{
g v`i'=0
replace v`i'=`i' if mod(int((_n-1)/2^(`n'-`i')),2)
}
egen exp=rowtotal(v*)
collapse (count)t=v1,by(exp)
egen p=pc(t),prop
keep if exp==`e'
n di
n di in yellow "exact P Value for `e'/`n' = " p
}
clear
end
谢谢!
二维码

扫码加我 拉你入群

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

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

2012-12-28 23:58:07
sungmoo 发表于 2012-12-28 23:41
*上面的程序可以大幅减化:

clear
运行 rankext 9 10.5 出错
二维码

扫码加我 拉你入群

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

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

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

说点什么

分享

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