R/ts2str.R

ts2str <-
function(xx,y,iv=c(1,2),nboot=400,SEED=TRUE){
#
# Compare strength of association of two predictors via the Theil-Sen
# estimator.
#
if(!is.matrix(xx))stop("x should be a matrix with 2 or more columns")
if(ncol(xx)<2)stop("x should be a matrix with 2 or more columns")
val1=NA
val2=NA
if(SEED)set.seed(2)
x=xx[,iv]
xy=elimna(cbind(x,y))
x=xy[,1:2]
y=xy[,3]
data1<-matrix(sample(length(y),size=length(y)*nboot,replace=TRUE),nrow=nboot)
data2<-matrix(sample(length(y),size=length(y)*nboot,replace=TRUE),nrow=nboot)
bvec1<-apply(data1,1,ts2str.sub,x[,1],y) #  2 by nboot matrix
bvec2<-apply(data2,1,ts2str.sub,x[,2],y) #  2 by nboot matrix
bvec=bvec1-bvec2
pv=akerdcdf(bvec,pts=0)
temp=corb(x[,1],x[,2],corfun=tau,SEED=FALSE)
padj=.05
if(temp$p.value<=.05)padj=.352*abs(temp$cor.est)+.049
pv=2*min(c(pv,1-pv))
list(p.value=pv,p.crit=padj)
}
musto101/wilcox_R documentation built on May 23, 2019, 10:52 a.m.