1.permutation test

用途:用于检验两组数据是否出生于同一分布

思路:如果产生于同一分布,两组数据混合,重新排列后,计算的基于两组数据的函数值(均值,中位数,方差等,下面程序中使用f指定)应该相差不大

方法:

library("gtools");
permuTest<-function(g1,g2,f=mean){
tobs<-abs(f(g1)-f(g2)); lg1<-length(g1);
lg2<-length(g2);
perms<-combinations(n = lg1+lg2, r = lg1);
B<-dim(perms)[1]; tper<-0;
data<-c(g1,g2); for(i in 1:B){
tper<-tper+ifelse(abs(f(data[perms[i,]])-f(data[-perms[i,]]))>tobs,1,0);
}
return(tper/B);
}

2.Benjamini-Hochberg test

用途:给定一组检验p值,在给定显著性水平下,哪些检验应该拒绝

方法:

BHTest<-function(p_values,alpha,unrelated=T){
lp<-length(p_values); li<-(alpha/lp)*(1:lp);
if(!unrelated){
li<-li/sum(1/(1:lp));
} sp_values<-sort(p_values);
indexs<-1:lp;
rejuctIndex<-max(indexs[sp_values<li]); rejuctThres<-sp_values[rejuctIndex]; return(p_values<=rejuctThres)
}

3.比较 wald test 和 likelihood ratio test

compareWaldAndLikelihood_mu<-function(n=1000,mu=0,fai=1){
d<-rnorm(n,mu,fai);
est_mu<-mean(d); sd<-sd(d); estimator_likelihood<-(n*(mu^2-est_mu^2) + 2*sum(d)*(est_mu-mu))/sd^2;
p_likelihood<-1-pchisq(estimator_likelihood,df=1); estimator_wald<-abs(est_mu-mu)*n^0.5/sd;
p_wald<-2*pnorm(-estimator_wald,mean=mu,sd=sd); return(c(p_wald,p_likelihood));
}

---恢复内容结束---

最新文章

  1. 使用Jenkins配置自动化构建
  2. Meteor+AngularJS:超快速Web开发
  3. iOS MJRefresh设置MJRefreshStateNoMoreData状态图片
  4. 我们的相识,总是那么巧。-------eclipse中搭建maven项目
  5. oracle plsql 捕获异常和抛出异常
  6. c# winForm使用Aspose.Cells读取CSV文件中文乱码问题
  7. Android Handler与多线程
  8. C++的64位整数
  9. 51nod1264线段相交
  10. Hook SSDT中NtCreateProcessEx
  11. Python学习笔记——基础篇2【第三周】——计数器、有序字典、元组、单(双)向队列、深浅拷贝、函数、装饰器
  12. pyhton之路---面向对象
  13. git log --pretty=format:&quot; &quot;
  14. 超哥教你发布CRM
  15. Python之路(第三十篇) 网络编程:socket、tcp/ip协议
  16. CEF3编译添加mp4支持(对应CefSharp63.0.3),chromium63(3239),附release下载
  17. 熟悉DAO模式的用法
  18. HNOI2019滚粗记
  19. js前台取用后台传递过来的map集合方式
  20. Error when clicking other button after displaying Popup window(转)

热门文章

  1. Linux下Nginx+PHP 简单安装配置
  2. 32位程序调用Oracle11gR2数据库libclntsh.so失败
  3. 博客终于开通了happy
  4. Office OpenXML-Excel(一)
  5. 纯CSS美化的checkbox 和 radio
  6. 为什么不能在scrollview中直接添加一个image,然后使animation.begin()??
  7. 【机房系统知识小结点系列】之遍历窗体中的控件,判断Text是否为空?
  8. 我是如何开发一个连锁企业的信息系统的,NO.1
  9. 《think in python》学习-10
  10. asp.net生成缩略图、文字图片水印