n {msamp} | R Documentation |
Calculate the sample size necessary to detect contamination above target level
Description
The n() function calculates the sample size,n, necessary to detect contamination above a target level, G, in a product lot, where the probability of a single sample unit being above the target level is calculated by the msamp function p(). The total cost, cost_tot, associated with sample size is also output.
Usage
n(
C,
w,
G,
Sens,
D = c("homogeneous", "heterogeneous", "localized"),
r = NULL,
f = NULL,
prob_det = 0.9,
samp_dollar,
lot_dollar
)
Arguments
C |
suspected lot contamination (CFU/g) |
w |
weight of single sample unit (g) |
G |
target value to detect (CFU/g) |
Sens |
sensitivity of the analytical test (%) |
D |
distribution of the bacteria in the product lot: "homogeneous", "heterogeneous", or "localized" |
r |
for the heterogeneous case only, the degree of heterogeneity. r > 0 |
f |
for the localized case, r is further specified. 0 < f < 1 |
prob_det |
desired probability of detecting bacterial contamination above the target level in the product lot. Set to 0.9 by default |
samp_dollar |
cost per sample unit in $ |
lot_dollar |
fixed cost (if any) of sampling the lot in $ |
Details
Refer to vignette for details.
Value
A list containing:
n: The sample size
p: The probability of a single sample unit being contaminated above the target level
cost_tot: The total cost associated with sampling of n samples
Examples
#A sample of 25 grams (w=25) is collected and analyzed using an analytical
#test with sensitivity of 90% (Sens=.9), to detect at least 5 CFU's/g (G=5).
#The suspected or postulated level of contamination in the lot is 4 CFU's/g (C=4).
#The desired probability of picking at least one sample unit contaminated above the target
#level is 0.9 (prob_det=0.9), the cost of a single sampling unit is $100 (samp_dollar=100),
#and the fixed cost for sampling the entire lot is $200 (lot_dollar=200).
#homogeneous case
n(C=4,w=25,G=5,Sens=.9,D="homogeneous",r=NULL,f=NULL,prob_det=0.9,samp_dollar=100,lot_dollar=200)
# n=376, total cost=$37,722
#heterogeneous case
n(C=4,w=25,G=5,Sens=.9,D="heterogeneous",r=10,f=NULL,prob_det=0.9,samp_dollar=100,lot_dollar=200)
# n=12, total cost=$1,319
#localized case
n(C=4,w=25,G=5,Sens=.9,D="localized",r=NULL,f=.3,prob_det=0.9,samp_dollar=100,lot_dollar=200)
# n=1,254 , total cost=$125,541