R/pcThreshold.R

Defines functions pcThreshold

Documented in pcThreshold

#' Choosing PC's
#'
#' To determine/choose the Principal component Threshold
#' pcThreshold() Determines principle components to use in model based on set threshold
#'
#' @param  PC numeric : principal components generated by "prcomp".
#' @param  threshold numeric: the chosen  amount or proportion of variance explained by the  number of  principle components to remain in the model.
#' @return PC_T matrix: The  chosen number of principal components agreeing with the threshold.
#' @export
pcThreshold <- function(PC, threshold = 0.014)
{
  summaryPCA = summary(PC)

  pcano = min(which(summaryPCA$importance[2,] < threshold))

  PC_T = PC$x[,1:pcano]
  return(PC_T)
}
JohnHadish/DJ.GLM.GWAS documentation built on April 5, 2020, 9:05 p.m.