R/cidmcp.R

cidmcp <-
function(x,alpha=.05,g=NULL,dp=NULL,CI.FWE=FALSE){
#
#  Perform Cliff's method for all pairs of J independent groups.
#  The familywise type I error probability is controlled via
#  Hochberg's method.
#
#  The data are assumed to be stored in $x$ in list mode or in a
#  matrix with J columns, columns corresponding to groups.
#
#  It is assumed all groups are independent.
#
#  Missing values are automatically removed.
#
#   g=NULL, x is assumed to be a matrix or have list mode
#   if g is specified, it is assumed that column g of x is
#   a factor variable and that the dependent variable of interest is in column
#   dp of x, which can be a matrix or data frame.
#
if(!is.null(g)){
if(is.null(dp))stop("Specify a value for dp, the column containing the data")
x=fac2list(x[,dp],x[,g])
}
if(is.data.frame(x))x=as.matrix(x)
if(is.matrix(x))x<-listm(x)
if(!is.list(x))stop("Data must be stored in a matrix or in list mode.")
J<-length(x)
CC<-(J^2-J)/2
test<-matrix(NA,CC,7)
c.sum=matrix(NA,CC,5)
for(j in 1:J){
xx<-!is.na(x[[j]])
val<-x[[j]]
x[[j]]<-val[xx]  # Remove missing values
}
dimnames(test)<-list(NULL,c("Group","Group","p.hat","p.ci.lower",
"p.ci.uppper","p-value","p.crit"))
dvec<-alpha/c(1:CC)
dimnames(c.sum)<-list(NULL,c("Group","Group","P(X<Y)","P(X=Y)","P(X>Y)"))
jcom<-0
n=matl(lapply(x,length))
for (j in 1:J){
for (k in 1:J){
if (j < k){
temp<-cidv2(x[[j]],x[[k]],alpha,plotit=FALSE)
jcom<-jcom+1
test[jcom,1]<-j
test[jcom,2]<-k
c.sum[jcom,1]<-j
c.sum[jcom,2]<-k
c.sum[jcom,3:5]=cid(x[[j]],x[[k]])$summary.dvals
test[jcom,3]<-temp$p.hat
test[jcom,4]<-temp$p.ci[1]
test[jcom,5]<-temp$p.ci[2]
test[jcom,6]<-temp$p.value
}}}
temp2<-order(0-test[,6])
test[temp2,7]=dvec
if(CI.FWE){
jcom<-0
for (j in 1:J){
for (k in 1:J){
if (j < k){
jcom<-jcom+1
temp<-cidv2(x[[j]],x[[k]],alpha=test[jcom,7],plotit=FALSE)
test[jcom,4]<-temp$p.ci[1]
test[jcom,5]<-temp$p.ci[2]
}}}}
list(n=n,test=test,summary.dvals=c.sum)
}
musto101/wilcox_R documentation built on May 23, 2019, 10:52 a.m.