R/stepmcp.R

stepmcp <-
function(x,tr=.2,alpha=.05){
#
# Step-down MCP method based on trimmed means
#
# x is assumed to have list mode, or a matrix or data with J columns
#   J=number of groups.
#
if(is.matrix(x) || is.data.frame(x))x=listm(x)
J=length(x)
if(J<3)stop('For two groups only, use yuen')
if(J>5)stop('Currently limited to at most five groups')
com=modgen(J)
jp1=J+1
mout=matrix(NA,nrow=length(com),ncol=3,
dimnames=list(NULL,c('Groups','p-value','p.crit')))
mout[,3]=alpha
jm2=J-2
com=com[jp1:length(com)]
mout=mout[jp1:nrow(mout),]
for(i in 1:length(com)){
nmod=length(com[[i]])-1
temp=c(nmod:0)
mout[i,1]=sum(com[[i]]*10^temp)
temp=t1way(x[com[[i]]],tr=tr)$p.value
pnum=length(com[[i]])
pe=1-(1-alpha)^(pnum/J)
if(length(com[[i]])<=jm2)mout[i,3]=pe
mout[i,2]=t1way(x[com[[i]]],tr=tr)$p.value
}
mout
}
musto101/wilcox_R documentation built on May 23, 2019, 10:52 a.m.