data(aHDL)
hdl0<-t(matrix(aHDL$hdl,4,406))
# \donttest{
# The code that follows reproduces the computations and figures in
# Rosenbaum (2025b), including the plots of power and the plots of
# phi-functions.
gammas<-(10:110)/10
plot(gammas,c(0,rep(1,length(gammas)-1)),type="n",
cex.axis=.7,xlim=c(min(gammas)-.5,max(gammas)+.2),
ylab="Power",xlab=expression(Gamma),las=1,
cex.lab=.8,main="I=406",cex.main=.8)
legend(0,.85,c("Wilcoxon","Quade","U868","U878","U888","Mixed"),
col=c("gray","gray","black","black","black","black"),
lty=c(2,1,3,2,4,1),lwd=c(2,2,2,1,1,1),cex=.6,bty="n")
lines(gammas,estPower(hdl0,gammas,ssratio=1,phi="wilc")$power,
col="gray",lty=2,lwd=2)
lines(gammas,estPower(hdl0,gammas,ssratio=1,phi="quade")$power,
col="gray",lty=1,lwd=2)
lines(gammas,estPower(hdl0,gammas,ssratio=1,phi="u868")$power,
col="black",lty=3,lwd=2)
lines(gammas,estPower(hdl0,gammas,ssratio=1,phi="u878")$power,
col="black",lty=2,lwd=1)
lines(gammas,estPower(hdl0,gammas,ssratio=1,phi="u888")$power,
col="black",lty=4,lwd=1)
lines(gammas,estPower(hdl0,gammas,ssratio=1,phi="mixed")$power,
col="black",lty=1,lwd=1)
gammas<-(10:110)/10
ssratio<-1000/406
plot(gammas,c(0,rep(1,length(gammas)-1)),type="n",
cex.axis=.7,xlim=c(min(gammas)-.5,max(gammas)+.2),
ylab="Power",xlab=expression(Gamma),las=1,
cex.lab=.8,main="I=1000",cex.main=.8)
legend(0,.85,c("Wilcoxon","Quade","U868","U878","U888","Mixed"),
col=c("gray","gray","black","black","black","black"),
lty=c(2,1,3,2,4,1),lwd=c(2,2,2,1,1,1),cex=.6,bty="n")
lines(gammas,estPower(hdl0,gammas,ssratio=ssratio,phi="wilc")$power,
col="gray",lty=2,lwd=2)
lines(gammas,estPower(hdl0,gammas,ssratio=ssratio,phi="quade")$power,
col="gray",lty=1,lwd=2)
lines(gammas,estPower(hdl0,gammas,ssratio=ssratio,phi="u868")$power,
col="black",lty=3,lwd=2)
lines(gammas,estPower(hdl0,gammas,ssratio=ssratio,phi="u878")$power,
col="black",lty=2,lwd=1)
lines(gammas,estPower(hdl0,gammas,ssratio=ssratio,phi="u888")$power,
col="black",lty=4,lwd=1)
lines(gammas,estPower(hdl0,gammas,ssratio=ssratio,phi="mixed")$power,
col="black",lty=1,lwd=1)
plotPhi<-
function (phi = "u868")
{
m<-NULL
if (is.null(m)) {
stopifnot(is.element(phi, c("u868", "u878", "u888", "u858",
"quade", "wilc","mixed")))
}
multrnksU <- function(pk, m1 = 2, m2 = 2, m = 2) {
n <- length(pk)
q <- rep(0, n)
q <- rep(0, n)
for (l in m1:m2) {
q <- q + (l * choose(m, l) * (pk^(l - 1)) * ((1 -
pk)^(m - l)))
}
q
}
mixed<-function(pk){
q<-multrnksU(pk, m1 = 19, m2 = 20, m = 20)+
multrnksU(pk, m1 = 19, m2 = 19, m = 20)
q/max(q)
}
u868 <- function(pk) {
q<-multrnksU(pk, m1 = 6, m2 = 8, m = 8)
q/max(q)
}
u878 <- function(pk) {
q<-multrnksU(pk, m1 = 7, m2 = 8, m = 8)
q/max(q)
}
u888 <- function(pk) {
q<-multrnksU(pk, m1 = 8, m2 = 8, m = 8)
q/max(q)
}
u858 <- function(pk) {
q<-multrnksU(pk, m1 = 5, m2 = 8, m = 8)
q/max(q)
}
quade <- function(pk) {
pk/max(pk)
}
wilc <- function(pk) {
rep(1, length(pk))
}
if (is.null(m)) {
if (phi == "mixed")
phifunc <- mixed
if (phi == "u868")
phifunc <- u868
else if (phi == "u878")
phifunc <- u878
else if (phi == "quade")
phifunc <- quade
else if (phi == "wilc")
phifunc <- wilc
else if (phi == "u888")
phifunc <- u888
else if (phi == "u858")
phifunc <- u858
}
u<-(0:300)/300
phifunc(u)
}
u<-(0:300)/300
plot(u,u,type="n",ylab=expression(varphi(v[i])),las=1,
cex.axis=.6,xlab=expression(v[i]),cex.lab=.7,
ylim=c(0,1.1),xlim=c(0,1),cex.main=.7)
legend(0,.90,c("Wilcoxon","Quade","U868","U878"),
col=c("gray","gray","black","black"),
lty=c(2,1,3,2),lwd=c(2,2,2,1),cex=.5,bty="n")
lines(u,plotPhi(phi="wilc"),
col="gray",lty=2,lwd=2)
lines(u,plotPhi(phi="quade"),
col="gray",lty=1,lwd=2)
lines(u,plotPhi(phi="u868"),
col="black",lty=3,lwd=2)
lines(u,plotPhi(phi="u878"),
col="black",lty=2,lwd=1)
u<-(0:300)/300
plot(u,u,type="n",ylab=expression(varphi(v[i])),las=1,
cex.axis=.6,xlab=expression(v[i]),cex.lab=.7,
ylim=c(0,1.1),xlim=c(.5,1),cex.main=.7)
legend(.5,.95,c("U888","Mixed"),
col=c("black","black"),
lty=c(4,1),lwd=c(1,1),cex=.5,bty="n")
lines(u,plotPhi(phi="u888"),
col="black",lty=4,lwd=1)
lines(u,plotPhi(phi="mixed"),
col="black",lty=1,lwd=1)
# Larger sample sizes for the appendix
gammas<-(10:110)/10
ssratio<-2000/406
plot(gammas,c(0,rep(1,length(gammas)-1)),type="n",
cex.axis=.7,xlim=c(min(gammas)-.5,max(gammas)+.2),
ylab="Power",xlab=expression(Gamma),las=1,
cex.lab=.8,main="I=2000",cex.main=.8)
legend(0,.85,c("Wilcoxon","Quade","U868","U878","U888","Mixed"),
col=c("gray","gray","black","black","black","black"),
lty=c(2,1,3,2,4,1),lwd=c(2,2,2,1,1,1),cex=.6,bty="n")
lines(gammas,estPower(hdl0,gammas,ssratio=ssratio,phi="wilc")$power,
col="gray",lty=2,lwd=2)
lines(gammas,estPower(hdl0,gammas,ssratio=ssratio,phi="quade")$power,
col="gray",lty=1,lwd=2)
lines(gammas,estPower(hdl0,gammas,ssratio=ssratio,phi="u868")$power,
col="black",lty=3,lwd=2)
lines(gammas,estPower(hdl0,gammas,ssratio=ssratio,phi="u878")$power,
col="black",lty=2,lwd=1)
lines(gammas,estPower(hdl0,gammas,ssratio=ssratio,phi="u888")$power,
col="black",lty=4,lwd=1)
lines(gammas,estPower(hdl0,gammas,ssratio=ssratio,phi="mixed")$power,
col="black",lty=1,lwd=1)
gammas<-(10:110)/10
ssratio<-5000/406
plot(gammas,c(0,rep(1,length(gammas)-1)),type="n",
cex.axis=.7,xlim=c(min(gammas)-.5,max(gammas)+.2),
ylab="Power",xlab=expression(Gamma),las=1,
cex.lab=.8,main="I=5000",cex.main=.8)
legend(0,.85,c("Wilcoxon","Quade","U868","U878","U888","Mixed"),
col=c("gray","gray","black","black","black","black"),
lty=c(2,1,3,2,4,1),lwd=c(2,2,2,1,1,1),cex=.6,bty="n")
lines(gammas,estPower(hdl0,gammas,ssratio=ssratio,phi="wilc")$power,
col="gray",lty=2,lwd=2)
lines(gammas,estPower(hdl0,gammas,ssratio=ssratio,phi="quade")$power,
col="gray",lty=1,lwd=2)
lines(gammas,estPower(hdl0,gammas,ssratio=ssratio,phi="u868")$power,
col="black",lty=3,lwd=2)
lines(gammas,estPower(hdl0,gammas,ssratio=ssratio,phi="u878")$power,
col="black",lty=2,lwd=1)
lines(gammas,estPower(hdl0,gammas,ssratio=ssratio,phi="u888")$power,
col="black",lty=4,lwd=1)
lines(gammas,estPower(hdl0,gammas,ssratio=ssratio,phi="mixed")$power,
col="black",lty=1,lwd=1)
rm(u,gammas,ssratio,plotPhi)
# }
Run the code above in your browser using DataLab