R/significance_functions.R

#' @title A Dog Function
#'
#' @description This function allows you to express your love for the superior furry animal.
#' @param agree Do you agree dogs are the best pet? Defaults to TRUE.
#' @keywords dogs
#' @export
#' @examples
#' dogs_over_cats()

dogs_over_cats <- function(agree=TRUE){
  if(agree==TRUE){
    print("Woof woof!")
  }
  else {
    print("Try again.")
  }
}


#' @title calculate p-value for the AUC statistics
#'
#' @description Calcualte p-value for the AUC statistics corresponding to null hypothesis AUC == 0
#' @param predictions predicted values
#' @param labels true values
#' @keywords p values, statisticall signifficance, auc
#' @export
#' @examples
#' p_val_auc(c(0.3, 0.4, 0.6, 0.7), c(0, 0, 1, 1))

p_val_auc <- function(predictions, labels){
  # assert_values_only(labels, c(0,1))
  # if all the predictions are same, just return p-value of 1 directly
  # if (all_the_same(predictions)){
  #   return(1)
  # }
  wilcox <- wilcox.test(predictions ~ labels, alternative='less')
  wilcox$p.value
}
dinga92/neuromancr documentation built on June 18, 2019, 12:33 a.m.