chapter 10 统计检验
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));
}
---恢复内容结束---
chapter 10 统计检验的更多相关文章
- 零元学Expression Blend 4 - Chapter 10 用实例了解布局容器系列-「StackPanel」
原文:零元学Expression Blend 4 - Chapter 10 用实例了解布局容器系列-「StackPanel」 本系列将教大家以实做案例认识Blend 4 的布局容器,此章介绍的布局容器 ...
- Think Python - Chapter 10 - Lists
10.1 A list is a sequenceLike a string, a list is a sequence of values. In a string, the values are ...
- Thinking in Java from Chapter 10
From Thinking in Java 4th Edition 内部类 public class Parcel1 { class Contents { private int i = 11; pu ...
- 深入理解计算机系统_3e 第十章家庭作业 CS:APP3e chapter 10 homework
10.6 1.若成功打开"foo.txt": -->1.1若成功打开"baz.txt": 输出"4\n" -->1.2若未能成功 ...
- 《算法导论》 — Chapter 10 基本数据结构
序 在本章中,要讨论如何通过使用了指针的简单数据结构表示动态集合.有很多的复杂的数据结构可以用指针来构造,本章介绍几种基本数据结构,包括栈.队列.链表,以及有根树. GitHub 第十章 程序实现代码 ...
- Chapter 10 Random Variability
目录 10.1 Identification versus estimation 10.2 Estimation of causal effects 10.3 The myth of the supe ...
- Chapter 10 EF 6 Support
http://dev.mysql.com/doc/connector-net/en/connector-net-entityframework60.html
- C++ Primer 随笔 Chapter 10 关联容器
1.关联容器的类型:map(键-值对的集合,可理解为关联数组), set(单纯的键的集合), multimap(一个键对应多个值,键唯一), multiset(相同键可以是多个). 2.pair类型提 ...
- Chapter 10 模版方法模式
我们要完成在某一细节层次一致的一个过程或一系列步骤,但其个别步骤在更详细的层次上的实现可能不同时,我们通常考虑用模版模式来处理. 模版方法模式:定义一个操作中的算法的骨架,而将一些步骤延迟到子类中.模 ...
随机推荐
- MySQL 指定数据库字符集的 3 种方法。
方法 1.创建数据库时指定字符集. create database Studio character set utf8; 方法 2.创建表的时候针对列指定字符集. create table T( x ...
- 正式学习React(五) Reactjs 的 PropTypes 使用方法
propTypes 使用來規範元件Props的型別與必需狀態 var Test = React.createClass({ propTypes: { // required requiredFunc: ...
- 关于web的流程
1.先确定好样式,布局,风格 2.之后的页面只是加一些HTML标签而已.
- EasyUI选项卡tab页面处理示例
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding= ...
- 【设计模式】学习笔记13:组合模式(Composite)
本文出自 http://blog.csdn.net/shuangde800 认识组合模式 上一篇中,我们可以用迭代器来实现遍历一个集合(数组,ArrayList, Vector, HashTabl ...
- 滚动视差效果——background-attachment
滚动视差效果的实现原理是在同一个页面上将页面元素分为多层,例如可以分为背景.内容.贴图层,在滚动页面的时候让三者滚动的速度不一,从而在人的视觉上能够形成一种立体的近似效果.最近在做一个项目wiki的时 ...
- UVA 10131 Is Bigger Smarter?(DP)
Some people think that the bigger an elephant is, the smarter it is. To disprove this, you want to t ...
- 【ThinkPHP学习】ThinkPHP自己主动转义存储富文本编辑器内容导致读取出错
RT. ThinkPHP的conf文件里的Convention.php有一个配置选项 'DEFAULT_FILTER' => 'htmlspecialchars', // 默认參数过滤方法 用于 ...
- UVA 507 - Jill Rides Again 动态规划
Jill Rides Again Jill likes to ride her bicycle, but since the pretty city of Greenhills where sh ...
- C# 设计模式 - 单例模式 演示
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...