Last active
October 12, 2018 14:56
-
-
Save chris-prener/ed226f96a70382ca96ab319dae2d7c2c to your computer and use it in GitHub Desktop.
Two-tailed probability under t distribution
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' 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