FAQ/Rpvs - CBU statistics Wiki

Upload page content

You can upload content for the page named below. If you change the page name, you can also upload content for another page. If the page name is empty, we derive the page name from the file name.

File to load page content from
Page name
Comment
In thi sntence, what word is mad fro the mising letters?

location: FAQ / Rpvs

R syntax for computing adjusted p-values

In addition to the code below see also the padjust function in R of form

p.adjust(p, method = p.adjust.methods, n = length(p))

for example

p <- c(0.01,0.04)
p.adjust(p,method="fdr",n=2)

which adjusts a set of p-values for a variety of methods including Bonferroni, Hochberg and Holm.

[ JUST CUT AND PASTE AT THE R PROMPT AFTER ADJUSTING INPUTS AS REQUIRED]

Sidak and Holm

This is a stepwise approach which produces the two cutoffs using the Sidak and Holm tests respectively. Only p-values equal or below the cutoff value are statistically significant at alpha=alp when adjusted for the number of p-values entered.

Input p-values in p and Type I error as alp.

p <- c(0.1,0.2,0.002)

alp <- 0.05

pos <- rank(p)
ps <- sort(p)
ncomp <- length(ps)

dsidak <- 1 - ((1 - ps)**(ncomp-pos+1))

j.alpha <- rep(alp,length(p))
diff <- dsidak - j.alpha
neg.diff <- diff[diff < 0]
pos.diff <- neg.diff[length(neg.diff)]
index <- diff == pos.diff
p.cutoff <- ps[index]
print(p.cutoff)
p.sig <- p[p <= p.cutoff]

holm <- (ncomp - pos + 1)*ps

j.alpha <- rep(alp,length(p))
diff <- holm - j.alpha
neg.diff <- diff[diff < 0]
pos.diff <- neg.diff[length(neg.diff)]
index <- diff == pos.diff
p.cutoff <- ps[index]
print(p.cutoff)
p.sig <- p[p <= p.cutoff]  

Ryan and Einot-Gabriel

Input p-values in p, Type I error as alp and the two differenced groups in g1 and g2. The adjusted p-values are outputted using the ryan and einot-gabriel methods respectively.

p <- c(0.1,0.2,0.002)

alp <- 0.05

g1 <- c(1,1,2)
g2 <- c(2,3,3)

ncomp <- length(p)

step <- abs(g2-g1)+1
ryan <- p*(ncomp/step)
eingab <- 1 - ( (1 - p)**(ncomp/step) )
unit <- rep(1,length(p))

for (i in 1:length(p)) {
if (ryan[i] > unit[i]) ryan[i] = unit[i]
if (eingab[i] > unit[i]) eingab[i] = unit[i]
 }
print(ryan)
print(eingab)