-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5a7f711
commit 7a50b5c
Showing
1 changed file
with
10 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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
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) | ||
} | ||
} |