# computePValueRiskGroups: FUNCTION to compute the probability of finding no... In FFD: Freedom from Disease

## Description

For a population that is stratified into risk groups the function computes the probability of finding no testpositives in a sample of given size using an imperfect diagnostic test. For each of the risk groups the population size `nPopulationVec`, the sample size `nSampleVec` and the relative infection risk `nRelRiskVec` must be specified. The discussed probability corresponds to the alpha-error (=error of the first kind) of the overall test with null hypothesis: prevalence = design prevalence.

## Usage

 ```1 2 3``` ```computePValueRiskGroups(nPopulationVec, nSampleVec, nRelRiskVec, nDiseased, sensitivity, specificity = 1) ```

## Arguments

 `nPopulationVec` Integer vector. Population sizes of the risk groups. `nSampleVec` Integer vector. Sample sizes of the risk groups. `nRelRiskVec` Numeric vector. (Relative) infection risks of the risk groups. `nDiseased` Integer. Number of diseased elements in the population according to the design prevalence. `sensitivity` 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). `specificity` 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.

## Value

The return value is a numeric between 0 and 1. It is the probability of finding no testpositives (not diseased!) in the sample.

## Author(s)

Ian Kopacka <[email protected]>

## References

A.R. Cameron and F.C. Baldock, "A new probablility formula to substantiate freedom from disease", Prev. Vet. Med. 34 (1998), pp. 1-17.

P.A.J.Martin, A.R. Cameron, M. Greiner, "Demonstrating freedom from disease using multiple complex data sources. : A new methodology based on scenario trees", Prev. Vet. Med. 79 (2007), pp. 71 - 97.

Calls `computePValue`
 ```1 2 3 4 5 6 7 8``` ```nPopulationVec <- c(500,700) nSampleVec <- c(300,200) nRelRiskVec <- c(1,1) nDiseased <- round(sum(nPopulationVec)*0.01) sensitivity <- 0.9 specificity <- 1 alphaError <- computePValue(sum(nPopulationVec), sum(nSampleVec), nDiseased, sensitivity, specificity) ```