Skip to content

Instantly share code, notes, and snippets.

@chris-prener
Last active October 12, 2018 14:56
Show Gist options
  • Save chris-prener/ed226f96a70382ca96ab319dae2d7c2c to your computer and use it in GitHub Desktop.
Save chris-prener/ed226f96a70382ca96ab319dae2d7c2c to your computer and use it in GitHub Desktop.
Two-tailed probability under t distribution
#' 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 a one sample t test
#'
#' @param t A given t score
#' @param n The sample size associated with t
#'
#' @return A probability value
#'
probt <- function(t, n){
# calculate the degrees of freedom given n
df <- n-1
# 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