R/preliminary_normality_checker.R

Defines functions preliminary_normality_checker

Documented in preliminary_normality_checker

#' A mixed approach to do a preliminary normality test
#'
#' This fucntion tests the incoming dataset with 3 different normality tests;
#' Anderson-Darling, Shapiro-Wilk, Kolmogorov-Smirnov and returns an integer
#' which is the number of confirmation of normality out of three performed tests.
#' @param  col The dataset that its normality needs to be checked.
#' @param alpha The significance level for rejecting or keeping the null hypothesis.
#' @keywords titanfall
#' @export
#' @examples
#' preliminary_normality_checke(dataset, alpha = 0.1)
#' 
preliminary_normality_checker <- function(col, alpha = 0.05){
  shapiro.p <- as.double(shapiro.test(col)[2])
  # standardizing the data for KS test
  temp.col <- (col-mean(col))/sd(col)
  ks.p <- as.double(ks.test(temp.col, "pnorm")[2])
  # load a package for anderson-darling test
  library(nortest)
  ad.p <- ad.test(col)[[2]]
  # a logical vector
  init.status <- c(shapiro.p >= alpha, ks.p >= alpha, ad.p >= alpha)
  init.number.of.true <- sum(init.status)
  return(init.number.of.true)
}
1mp3rium/titanfall documentation built on Dec. 16, 2017, 2:44 a.m.