function (t.obs,nvec=c(6,6,6),nsim=1000) { # This function simulates the p-value of an observed # Anderson-Darling K-sample standardized ADK statistic, # t.obs =(ADK-(k-1))/sigma, computed from samples # of sizes nvec (default c(6,6,6)). # t.obs is output by adk.test. # The p-value is based on nsim simulations. #--------------------------------------------------- N<-sum(nvec) k <- length(nvec) nvec2<-cumsum(nvec) nvec1<-c(0,nvec2[1:(k-1)])+1 out<- NULL x <-list() for(i in 1:nsim){ xx <- sample(1:N,replace=F) for(j in 1:k){ x[[j]]<-xx[nvec1[j]:nvec2[j]] } out[i]<-adk.test(x)$adk[1,1] } y<-mean(out>=t.obs) names(y)<-"p-value" y }