R/CountEigenPA.R

Defines functions CountEigen.PA

Documented in CountEigen.PA

CountEigen.PA <- function (PA, percentiles = NULL) {
  # # Counts the number of observed eigenvalues that exceed the given percentiles.
  # #
  # # Arg:
  # #  PA: an object of class PA
  # #  percentiles: The percentiles that ought to be plotted, defaults to those in the object
  # #
  # # Ret:
  # #  greaterEigenValues: named numeric vector indicating the number of eigenvalues that are greater than the
  # #  eigenvalues distribution percentiles under independence
 
  ################################################################################
  # # Check object's class
  ################################################################################
  isPA <- Check.PA(PA)
  if (!isPA) {
    stop("PA must be of class PA")
  } 
  
  if (!is.null(percentiles)) {
    PA <- quantile.PA(PA, percentiles = percentiles)
  } 

  greaterEigenValues        <- PA$observed[, "eigenValues"] > PA$percentiles[, "eigenValues"]
  greaterEigenValues        <- by(greaterEigenValues, PA$percentile[, "typeEigenValues"], sum)
  greaterEigenValues        <- as.numeric(greaterEigenValues)
  names(greaterEigenValues) <- paste("p", names(table(PA$percentile[, "typeEigenValues"])), sep = "")
 
  return(greaterEigenValues)
}

Try the pcaPA package in your browser

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

pcaPA documentation built on May 29, 2017, 6:53 p.m.