data(aHDL)
y<-t(matrix(aHDL$hdl,4,406))
# This is the simplest example of a general property. The
# example simply illustrates, but does not fully exploit
# the property. In this case, use of the stratified
# Wilcoxon statistic is a mistake, because Quade's
# statistic correctly reports insensitivity to a bias
# of gamma=4.5, but the stratified Wilcoxon statistic
# is sensitive at gamma=3.5. The adaptive procedure
# that does both tests and corrects for multiple testing
# is insensitive to gamma=4.4; so, it is almost as good
# as knowing what you cannot know, namely that Quade's
# statistic is the better choice in this one example.
# The price paid for testing twice is very small;
# see Berk and Jones (1978) and Rosenbaum (2012, 2022).
wgtRank(y,phi="wilc",gamma=3.5)
wgtRank(y,phi="quade",gamma=3.5)
wgtRank(y,phi="wilc",gamma=4.5)
wgtRank(y,phi="quade",gamma=4.5)
wgtRanktt(y,phi1="wilc",phi2="quade",gamma=4.4)
# Sensitivity to gamma=3.5 is very different from
# sensitivity to gamma=4.4; see documentation for amplify.
amplify(3.5,8)
amplify(4.4,8)
# In this example, u878 exhibits greater insensitivity to bias
# than u868. However, adaptive inference using both is almost
# as good as the better statistic, yet it strongly controls the
# family-wise error rate despite testing twice;
# see Rosenbaum (2012,2022).
wgtRank(y,phi="u868",gamma=6) # New U-statistic weights (8,6,8)
wgtRank(y,phi="u878",gamma=6) # New U-statistic weights (8,7,8)
wgtRanktt(y,phi1="u868",phi2="u878",gamma=5.9)
# A user defined weight function, brown, analogous to Brown (1981).
brown<-function(v){((v>=.333)+(v>=.667))/2}
# In this example, the joint test rejects based on u878
wgtRanktt(y,phi1="u878",phifunc2=brown,gamma=5.8)
# \donttest{
# The following example reproduces Table 1 in Rosenbaum (2025b).
hdl0<-y
gammas<-c(1:6,6.25,6.5,6.75,6.875,7)
o<-matrix(NA,length(gammas),7)
rownames(o)<-gammas
colnames(o)<-c("Wilcoxon","Quade","U868","U878","U888","Mixed","U878aMixed")
for (i in 1:length(gammas)){
o[i,1]<-wgtRank(hdl0,phi="wilc",gamma=gammas[i])$pval
o[i,2]<-wgtRank(hdl0,phi="quade",gamma=gammas[i])$pval
o[i,3]<-wgtRank(hdl0,phi="u868",gamma=gammas[i])$pval
o[i,4]<-wgtRank(hdl0,phi="u878",gamma=gammas[i])$pval
o[i,5]<-wgtRank(hdl0,phi="u888",gamma=gammas[i])$pval
o[i,6]<-wgtRank(hdl0,phi="mixed",gamma=gammas[i])$pval
o[i,7]<-wgtRanktt(hdl0,phi1="u878",phi2="mixed",gamma=gammas[i])$jointP
}
round(o,3)
# }
Run the code above in your browser using DataLab