Skip to content

Commit

Permalink
Update p.R
Browse files Browse the repository at this point in the history
  • Loading branch information
Matias-Lopez-13 authored Jun 20, 2024
1 parent 5a7f711 commit 7a50b5c
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions R/p.R
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
##' Find a p-value given opposing and supporting information
##'
##' @param num_support An integer representing the number of pieces of information in favor of the hypothesis. Must be less than or equal to the total.
##' @param total_info An integer representing the total number of pieces of information observed
##' @param obs_support An integer representing the number of observations in favor of the working hypothesis. Must be less than or equal to the total.
##' @param total_obs An integer representing the total number of observations
##' @export
find_p <- function(num_support,total_info){
## Test to make sure that num_support is less than or equal to total_info
stopifnot("Number of pieces of supporting info must be less than or equal to the total number of observations"=num_support<=total_info)
num_oppose <- num_support+1
stopifnot("Number of pieces of supporting info must be greater than or equal to half of the total number of observations"=num_support >= (total_info/2))
find_p <- function(obs_support,total_obs){
## Test to make sure that obs_support is less than or equal to total_obs
stopifnot("The number of observations in favor of the working hypothesis must be less than or equal to the total number of observations"=obs_support<=total_obs)
obs_oppose <- obs_support+1
stopifnot("Observations are already compatible with the null. The number of observations in favor of the working hypothesis must be greater than or equal to half of the total number of observations"=obs_support >= (total_obs/2))
## We assume odds=1 here
thep <- dFNCHypergeo(x=num_support, m1 = num_support, m2 = num_oppose,
n = total_info, odds = 1)
thep <- dFNCHypergeo(x=obs_support, m1 = obs_support, m2 = obs_oppose,
n = total_obs, odds = 1)
return(thep)
}
}

0 comments on commit 7a50b5c

Please sign in to comment.