Skip to content

Instantly share code, notes, and snippets.

@chris-prener
Created October 12, 2018 19:02
Show Gist options
  • Save chris-prener/31832be0d94cd8f4b72e04b3bc37f76c to your computer and use it in GitHub Desktop.
Save chris-prener/31832be0d94cd8f4b72e04b3bc37f76c to your computer and use it in GitHub Desktop.
#' Two-tailed Probabilities Under the t Distribution
#'
#' @description This function calculates the probability of observing a t score
#' at least as extreme as the given t value for any t test
#'
#' @param t A given t score
#' @param df The degrees of freedom associated with t
#'
#' @details Depending on the type of t test, degrees of freedom (v) is calculated
#' in a different manner. For one sample and dependent t tests, v is n-1.
#' For a two-sample t test, v is n-2.
#'
#' @return A probability value
#'
probt <- function(t, df){
# calculate the p value
out <- 2*pt(q = -abs(t), df = df)
# return output
return(out)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment