Diff for "FAQ/FDR" - CBU statistics Wiki
location: Diff for "FAQ/FDR"
Differences between revisions 4 and 5
Revision 4 as of 2006-12-11 23:44:25
Size: 1083
Comment:
Revision 5 as of 2006-12-12 08:26:42
Size: 1104
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
== R Code to Perform the Benjamini and Hochberg FDR procedure == === R Code to Perform the Benjamini and Hochberg FDR procedure ===
Line 19: Line 19:
}}}
Line 20: Line 21:
R Output > pvalue<-c(0.021,0.001,0.017,0.041,0.005,0.036,0.042,0.023,0.07,0.1) === R Output ===
Line 22: Line 23:
{{{
> pvalue<-c(0.021,0.001,0.017,0.041,0.005,0.036,0.042,0.023,0.07,0.1)
Line 36: Line 39:
Line 40: Line 44:

R Code to Perform the Benjamini and Hochberg FDR procedure

[Insert P values in any order]

pvalue <- c(0.021,0.001,0.017,0.041,0.005,0.036,0.042,0.023,0.07,0.1) 
sorted.pvalue<-sort(pvalue) 
sorted.pvalue 
j.alpha <- (1:10)*(.05/10) 
diff <- sorted.pvalue-j.alpha 
neg.diff <- diff[diff<0] 
pos.diff <- neg.diff[length(neg.diff)] 
index <- diff==pos.diff 
p.cutoff <-sorted.pvalue[index] 
p.cutoff 
p.sig <- pvalue[pvalue <= p.cutoff] 
p.sig

R Output

> pvalue<-c(0.021,0.001,0.017,0.041,0.005,0.036,0.042,0.023,0.07,0.1) 
> sorted.pvalue <- sort(pvalue) 
> sorted.pvalue

[sorted P values in ascending order]
[1] 0.001 0.005 0.017 0.021 0.023 0.036 0.041 0.042 0.070 0.100 

> j.alpha <- (1:10) * (0.05/10) 
> diff <- sorted.pvalue - j.alpha 
> neg.diff <- diff[diff < 0] 
> pos.diff <- neg.diff[length(neg.diff)] 
> index <- diff == pos.diff 
> p.cutoff <- sorted.pvalue[index] 
> p.cutoff 
[1] 0.023 

> p.sig <- pvalue[pvalue <= p.cutoff] > p.sig

[significant p values by B-H method]: 
[1] 0.021 0.001 0.017 0.005 0.023

None: FAQ/FDR (last edited 2015-03-11 11:55:06 by PeterWatson)