FUNCTION to compute the probability of finding no testpositives in a sample of a certain size.
For a population of size
nPopulation with a given design prevalence
the function computes the probability of finding no testpositives
in a sample of size
nSample if an imperfect test is used (given sensitivity
and specificity). This probability corresponds to the alpha-error
(=error of the first kind) of the overall test with null hypothesis:
prevalence = design prevalence. A modified hypergeometric formula
is used; see Cameron, Baldock, 1998.
computePValue(nPopulation, nSample, nDiseased, sensitivity, specificity = 1)
Integer. Population size.
Integer. Size of sample.
Integer. Number of diseased elements in the population according to the design prevalence.
Numeric between 0 and 1. Sensitivity (= probability of a testpositive result, given the tested individual is diseased) of the test (e.g., diagnostic test or herd test).
Numeric between 0 and 1. Specificity (= probability of a testnegative result, given the tested individual is not diseased) of the test (e.g., diagnostic test or herd test). The default value is 1.
The return value is a numeric between 0 and 1. It is the probability of finding no testpositives (not diseased!) in the sample.
Ian Kopacka <firstname.lastname@example.org>
A.R. Cameron and F.C. Baldock, "A new probablility formula to substantiate freedom from disease", Prev. Vet. Med. 34 (1998), pp. 1-17.
alphaError <- computePValue(nPopulation = 3000, nSample = 1387, nDiseased = 6, sensitivity = 0.85, specificity = 1)