Description Usage Arguments Details Value Author(s) Examples

View source: R/computeAposterioriError.R

For a sampling scheme designed to substantiate freedom from disease the function computes the a-posteriori alpha-error, i.e., the actual alpha-error based on the drawn sample.

1 2 | ```
computeAposterioriError(alphaErrorVector, nPopulation,
nDiseased, method = "default")
``` |

`alphaErrorVector` |
Numeric vector. Alpha-error (between 0 and 1) of each herd in the sample. |

`nPopulation` |
Integer. Population size, i.e., total numer of herds in the population. |

`nDiseased` |
Integer. Number of diseased herds in the population according to the design prevalence. |

`method` |
Character string. "exact" for exact error, "approx" for approximation (recommended for nDiseased > 7). |

The exact evaluation of the alpha-error is computationally complex, due
to combinatirical issues. In order to increase effectivity parts of the code
were implemented in C. Still, for `nDiseased`

> 7 the computation may take
very long and it is generally not recommended to use the exact calculation. Rather
the approximation should be used for `nDiseased`

> 7.

The return value is the a-posteriori alpha-error based on the sample at hand (numeric scalar).

Ian Kopacka <ian.kopacka@ages.at>

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | ```
## Freedom from disease using limited sampling with sampleSizeLtd = 7.
## Data: sheep holdings in state "Steiermark".
######################################################################
data(sheepData)
popVec <- sheepData$nSheep[sheepData$state == 6]
N1 <- length(popVec)
sampleSizeLtd <- 7
intraHerdPrev <- 0.13
designPrev <- 0.002
nDiseased <- round(designPrev*N1)
## Draw the sample:
n1 <- 1560
samplePop <- sample(x = popVec, size = n1, replace = FALSE, prob = NULL)
## Compute alpha-errors for the sample:
alphaList <- computeAlphaLimitedSampling(stockSizeVector = samplePop,
sampleSizeLtd = sampleSizeLtd,
intraHerdPrevalence = intraHerdPrev,
diagSensitivity = 0.9, diagSpecificity = 1)
alphaDataFrame <- merge(x = data.frame(size = samplePop),
y = alphaList$alphaDataFrame, by = "size", all.x = TRUE, all.y = FALSE)
## Compute the a-posteriori alpha-error:
alphaAPostApprox <- computeAposterioriError(alphaErrorVector =
alphaDataFrame$alpha, nPopulation = N1, nDiseased = nDiseased,
method = "approx")
alphaAPostExact <- computeAposterioriError(alphaErrorVector =
alphaDataFrame$alpha, nPopulation = N1, nDiseased = nDiseased,
method = "exact")
``` |

FFD documentation built on May 19, 2017, 6:35 p.m.

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs in the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.