R/ks.SGB.R

Defines functions ks.SGB

Documented in ks.SGB

ks.SGB <-
function(u,shape1,shape2,scale, alpha=0.05){
   if (is.vector(scale) & length(scale)!=1) stop(" scale should be a scalar or of the same dimension as u")
   else if (is.matrix(scale)) {
      if (max(abs(dim(u) - dim(scale))) > 0)
   stop(" scale should be 1 or of the same dimension as u")}
   DNAME <- deparse(substitute(u))
   z <- (u/scale)^shape1
   z <- z/rowSums(z) 
  names(z) <- names(u)

  D <- dim(u)[2]
  N <- dim(u)[1]
  Ptot <- sum(shape2)
  
  tks <- data.frame(statistic=rep(NA,D),p.value=rep(NA,D))
  
  for (i in 1:D){
   ksi = ks.test(z[,i],pbeta,shape2[i],Ptot-shape2[i])[1:2]      # Kolmogorov-Smirnov
   tks[i,] <- ksi[1:2]
  }
  row.names(tks) <- names(u)
  tks <- tks[order(tks[["p.value"]]),]
  tks[["cutoff"]] <- alpha*(1:D)/D
  
  RVAL <- list(method="One-sample Kolmogorov-Smirnov test",Compositions=DNAME, tests=tks)
  class(RVAL) <- "testSGB"
  return(RVAL)
}

Try the SGB package in your browser

Any scripts or data that you put into this service are public.

SGB documentation built on March 26, 2020, 8:02 p.m.