n<-20 #or try sample(1:20,1)
Y<-matrix(runif(3*n),ncol=3)
ipd<-ipd.mat(Y)
cls<-sample(1:2,n,replace = TRUE) #or try cls<-rep(1:2,c(10,10))
ct<-nnct(ipd,cls)
W<-Wmat(ipd)
Qv<-Qvec(W)$q
Rv<-Rval(W)
varN<-var.nnct(ct,Qv,Rv)
covN<-cov.nnct(ct,varN,Qv,Rv)
varT<-var.seg.coeff(ct,covN)
Zseg.coeff(Y,cls)
Zseg.coeff.ct(ct,varT)
Zseg.coeff(Y,cls,method="max")
Zseg.coeff(Y,cls,alt="g")
Zseg.coeff.ct(ct,varT,alt="g")
#cls as a factor
na<-floor(n/2); nb<-n-na
fcls<-rep(c("a","b"),c(na,nb))
ct<-nnct(ipd,fcls)
Zseg.coeff.ct(ct,varT)
#############
n<-40
Y<-matrix(runif(3*n),ncol=3)
cls<-sample(1:4,n,replace = TRUE) #or try cls<-rep(1:2,c(10,10))
ipd<-ipd.mat(Y)
ct<-nnct(ipd,cls)
W<-Wmat(ipd)
Qv<-Qvec(W)$q
Rv<-Rval(W)
varN<-var.nnct(ct,Qv,Rv)
covN<-cov.nnct(ct,varN,Qv,Rv)
varT<-var.seg.coeff(ct,covN)
Zseg.coeff(Y,cls)
Zseg.coeff.ct(ct,varT)
Zseg.coeff(Y,cls,alt="g")
Zseg.coeff.ct(ct,varT,alt="g")
Run the code above in your browser using DataLab