Title: | Probability of detection for grab sample selection |
---|---|
Description: | The goal of grabsampling package is to enable probability of detection calculation for grab samples selection by using two different methods such as systematic or random based on two-state Markov chain in bulk production process. |
Authors: | Mayooran Thevaraja [aut, cre], Kondaswamy Govindaraju [aut], Mark Bebbington [aut] |
Maintainer: | Mayooran Thevaraja <[email protected]> |
License: | GPL (>= 2) |
Version: | 0.0.1 |
Built: | 2024-10-26 03:39:59 UTC |
Source: | https://github.com/mayooran1987/grabsampling |
This package provides the probability of detection calculation for grab samples selection by various method of samplings such as systematic or random and also it is useful to generate the comparison curves. Moreover, this package calculates the probability of acceptance calculations based on suitable microbiological distributions such as Poisson gamma or Lognormal or Poisson lognormal and also provides a comparison based on OC curves with different sampling schemes. Most of the researchers have studied the uncorrelated case, but in this study, we have a high spatial correlation between contamination of primary increments. For this package development, we used default standard deviation as 0.8 and also spatial correlation not affected for composite mean for the probability of acceptance calculation. A future version will be included deeply study about variability effects in grab sample selection.
Mayooran Thevaraja, Kondaswamy Govindaraju, Mark Bebbington
Bhat, U., & Lal, R. (1988). Number of successes in Markov trials. Advances in Applied Probability, 20(3), 677-680.
Jongenburger, I., Besten, H.M., & Zwietering, M.H. (2015). Statistical aspects of food safety sampling. Annual review of food science and technology, 6, 479-503.
Mussida, A., Vose, D. & Butler, F. Efficiency of the sampling plan for Cronobacter spp. assuming a Poisson lognormal distribution of the bacteria in powder infant formula and the implications of assuming a fixed within and between-lot variability, Food Control, Elsevier, 2013 , 33 , 174-185.
Van Schothorst, M., Zwietering, M., Ross, T., Buchanan, R. & Cole, M., Relating microbiological criteria to food safety objectives and performance objectives Food Control , 2009 , 20 , 967-979.
AOQL_grab_A
provides the AOQ curve and calculates AOQL value based on limiting fraction of contaminated increments.
AOQL_grab_A(c, r, t, d, N, method, plim)
AOQL_grab_A(c, r, t, d, N, method, plim)
c |
acceptance number |
r |
nurber of primary increments in a grab sample or grab sample size |
t |
number of grab samples |
d |
serial correlation of contamination between the primary increments |
N |
length of the production |
method |
what sampling method we have applied such as |
plim |
the upper limit for graphing the fraction nonconforming or proportion of contaminated increments |
Since is the probability of non-detection,
is the limiting fraction of contaminated increments and the outgoing contaminated proportion of primary increments is given by
as the product
.
The quantity
is defined as the maximum proportion of outgoing contaminated primary increments and is given by
AOQ curve and AOQL value based on on limiting fraction
c <- 0 r <- 25 t <- 30 d <- 0.99 N <- 1e9 method <- 'systematic' plim <- 0.30 AOQL_grab_A(c, r, t, d, N, method, plim)
c <- 0 r <- 25 t <- 30 d <- 0.99 N <- 1e9 method <- 'systematic' plim <- 0.30 AOQL_grab_A(c, r, t, d, N, method, plim)
AOQL_grab_B
provides the AOQ curve and calculates AOQL value based on average microbial counts.
AOQL_grab_B(c, r, t, distribution,llim, K, m, sd)
AOQL_grab_B(c, r, t, distribution,llim, K, m, sd)
c |
acceptance number |
r |
number of primary increments in a grab sample or grab sample size |
t |
number of grab samples |
distribution |
what suitable microbiological distribution we have used such as |
llim |
the upper limit for graphing the arithmetic mean of cell count |
K |
dispersion parameter of the Poisson gamma distribution (default value 0.25) |
m |
microbiological limit with default value zero, generally expressed as number of microorganisms in specific sample weight |
sd |
standard deviation of the lognormal and Poisson-lognormal distributions on the log10 scale (default value 0.8) |
Since is the probability of acceptance,
is the arithmetic mean of cell count and the outgoing contaminated arithmetic mean of cell count of primary increments is given by
as the product
.
The quantity
is defined as the maximum proportion of outgoing contaminated primary increments and is given by
AOQ curve and AOQL value based on average microbial counts
c <- 0 r <- 25 t <- 30 distribution <- 'Poisson lognormal' llim <- 0.20 AOQL_grab_B(c, r, t, distribution, llim)
c <- 0 r <- 25 t <- 30 distribution <- 'Poisson lognormal' llim <- 0.20 AOQL_grab_B(c, r, t, distribution, llim)
This function allows comparison of different sampling schemes, which can be systematic and random sampling of primary increments or grab sampling of blocks of primary increments. A graphical display of the probability of detection or probability of non detection
versus fraction nonconforming
for up to four selected schemes will be produced.
compare_plans(d, N, plim, type, c1, r1, t1, method1, c2, r2, t2, method2, c3, r3, t3, method3, c4, r4, t4, method4,linetype)
compare_plans(d, N, plim, type, c1, r1, t1, method1, c2, r2, t2, method2, c3, r3, t3, method3, c4, r4, t4, method4,linetype)
d |
serial correlation of contamination between the primary increments |
N |
length of the production |
plim |
the upper limit for graphing the fraction nonconforming or proportion of contaminated increments |
type |
what type of graph we want to produce such as |
c1 , c2 , c3 , c4
|
acceptance numbers |
r1 , r2 , r3 , r4
|
number of primary increments in a grab sample or grab sample size |
t1 , t2 , t3 , t4
|
number of grab samples |
method1 , method2 , method3 , method4
|
what sampling method we have applied such as |
linetype |
if we want to get a different type of line for each sampling scheme, set it to FALSE otherwise graph will be produced with the same type of line (default TRUE) |
Probability of detection or non detection vs limiting fraction curves
c1 <- 0 c2 <- 0 c3 <- 0 c4 <- 0 r1 <- 1 r2 <- 10 r3 <- 30 r4 <- 75 t1 <- 750 t2 <- 75 t3 <- 25 t4 <- 10 d <- 0.99 N <- 1e9 method1 <- method2 <- method3 <- method4 <- 'systematic' plim <- 0.10 compare_plans(d, N, plim, type ='D', c1, r1, t1, method1, c2, r2, t2, method2) compare_plans(d, N, plim, type ='D', c1, r1, t1, method1, c2, r2, t2, method2, c3, r3, t3, method3) compare_plans(d, N, plim, type ='D', c1, r1, t1, method1, c2, r2, t2, method2, c3, r3, t3, method3, c4, r4, t4, method4) compare_plans(d, N, plim, type ='ND', c1, r1, t1, method1, c2, r2, t2, method2, c3, r3, t3, method3, c4, r4, t4, method4)
c1 <- 0 c2 <- 0 c3 <- 0 c4 <- 0 r1 <- 1 r2 <- 10 r3 <- 30 r4 <- 75 t1 <- 750 t2 <- 75 t3 <- 25 t4 <- 10 d <- 0.99 N <- 1e9 method1 <- method2 <- method3 <- method4 <- 'systematic' plim <- 0.10 compare_plans(d, N, plim, type ='D', c1, r1, t1, method1, c2, r2, t2, method2) compare_plans(d, N, plim, type ='D', c1, r1, t1, method1, c2, r2, t2, method2, c3, r3, t3, method3) compare_plans(d, N, plim, type ='D', c1, r1, t1, method1, c2, r2, t2, method2, c3, r3, t3, method3, c4, r4, t4, method4) compare_plans(d, N, plim, type ='ND', c1, r1, t1, method1, c2, r2, t2, method2, c3, r3, t3, method3, c4, r4, t4, method4)
This function produces overlaid Operating Characteristic (OC) curves for any three systematic/random sampling schemes for specified parameters.
compare_plans_oc(c1, c2, c3, r1, t1, r2, t2, r3, t3, distribution, K, m, sd)
compare_plans_oc(c1, c2, c3, r1, t1, r2, t2, r3, t3, distribution, K, m, sd)
c1 , c2 , c3
|
acceptance numbers |
r1 , r2 , r3
|
number of primary increments in a grab sample or grab sample size |
t1 , t2 , t3
|
number of grab samples |
distribution |
what distribution we have used such as |
K |
dispersion parameter of the Poisson gamma distribution (default value 0.25) |
m |
microbiological limit with default value zero, generally expressed as number of microorganisms in specific sample weight |
sd |
standard deviation of the lognormal and Poisson-lognormal distributions on the log10 scale (default value 0.8) |
overlaid OC curves
c1 <- 0 c2 <- 0 c3 <- 0 r1 <- 25 r2 <- 50 r3 <- 75 t1 <- 10 t2 <- 10 t3 <- 10 distribution <- 'Poisson lognormal' compare_plans_oc(c1, c2, c3, r1, t1, r2, t2, r3, t3, distribution)
c1 <- 0 c2 <- 0 c3 <- 0 r1 <- 25 r2 <- 50 r3 <- 75 t1 <- 10 t2 <- 10 t3 <- 10 distribution <- 'Poisson lognormal' compare_plans_oc(c1, c2, c3, r1, t1, r2, t2, r3, t3, distribution)
This function produces overlaid Operating Characteristic (OC) curves for any three systematic/random sampling schemes for specified parameters with different standard deviation vlues.
compare_plans_oc_sd(c1, c2, c3, r1, t1, r2, t2, r3, t3, sd1, sd2, sd3, distribution, K, m)
compare_plans_oc_sd(c1, c2, c3, r1, t1, r2, t2, r3, t3, sd1, sd2, sd3, distribution, K, m)
c1 , c2 , c3
|
acceptance numbers |
r1 , r2 , r3
|
number of primary increments in a grab sample or grab sample size |
t1 , t2 , t3
|
number of grab samples |
sd1 , sd2 , sd3
|
standard deviations of the lognormal and Poisson-lognormal distributions on the log10 scale |
distribution |
what distribution we have used such as |
K |
dispersion parameter of the Poisson gamma distribution (default value 0.25) |
m |
microbiological limit with default value zero, generally expressed as number of microorganisms in specific sample weight |
overlaid OC curves
c1 <- 0 c2 <- 0 c3 <- 0 r1 <- 25 r2 <- 25 r3 <- 25 t1 <- 30 t2 <- 30 t3 <- 30 sd1 <- 0.2 sd2 <- 0.4 sd3 <- 0.8 distribution <- 'Poisson lognormal' compare_plans_oc_sd(c1, c2, c3, r1, t1, r2, t2, r3, t3, sd1, sd2, sd3, distribution)
c1 <- 0 c2 <- 0 c3 <- 0 r1 <- 25 r2 <- 25 r3 <- 25 t1 <- 30 t2 <- 30 t3 <- 30 sd1 <- 0.2 sd2 <- 0.4 sd3 <- 0.8 distribution <- 'Poisson lognormal' compare_plans_oc_sd(c1, c2, c3, r1, t1, r2, t2, r3, t3, sd1, sd2, sd3, distribution)
This function calculates the resulting serial correlation between grab samples each having r
primary increments with original serial correlation d
.
correlation_grab(r, p, d)
correlation_grab(r, p, d)
r |
number of primary increments in a grab sample or grab sample size |
p |
limiting fraction or proportion of contaminated increments |
d |
serial correlation of contamination between the primary increments |
The serial correlation between blocks (grab samples) is given by as
where is the probability of detection in any of the block (grab sample) which is calculated by using prob_detect_single_grab.
Serial correlation between grab samples
r <- 25 p <- 0.005 d <- 0.99 correlation_grab(r, p, d)
r <- 25 p <- 0.005 d <- 0.99 correlation_grab(r, p, d)
oc_plan
provides the Operating Characteristic (OC) curve for known microbiological distribution such as lognormal. The probability of acceptance is plotted against mean log10 concentration.
oc_plan(c, r, t, distribution, K, m, sd)
oc_plan(c, r, t, distribution, K, m, sd)
c |
acceptance number |
r |
number of primary increments in a grab sample or grab sample size |
t |
number of grab samples |
distribution |
what suitable distribution we have used such as |
K |
dispersion parameter of the Poisson gamma distribution (default value 0.25) |
m |
microbiological limit with default value zero, generally expressed as number of microorganisms in specific sample weight |
sd |
standard deviation of the lognormal and Poisson-lognormal distributions on the log10 scale (default value 0.8) |
Based on the food safety literature, mean concentration is given by .
Operating Characteristic (OC) curve
c <- 0 r <- 25 t <- 30 distribution <- 'Poisson lognormal' oc_plan(c, r, t, distribution)
c <- 0 r <- 25 t <- 30 distribution <- 'Poisson lognormal' oc_plan(c, r, t, distribution)
This function calculates the overall probability of acceptance for given microbiological distribution such as lognormal.
prob_accept(c, r, t, mu, distribution, K, m, sd)
prob_accept(c, r, t, mu, distribution, K, m, sd)
c |
acceptance number |
r |
number of primary increments in a grab sample or grab sample size |
t |
number of grab samples |
mu |
location parameter (mean log) of the Lognormal and Poisson-lognormal distributions on the log10 scale |
distribution |
what suitable microbiological distribution we have used such as |
K |
dispersion parameter of the Poisson gamma distribution (default value 0.25) |
m |
microbiological limit with default value zero, generally expressed as number of microorganisms in specific sample weight |
sd |
standard deviation of the lognormal and Poisson-lognormal distributions on the log10 scale (default value 0.8) |
Based on the food safety literature, for given values of c
, r
and t
, the probability of detection in a primary increment is given by, and acceptance probability in
t
selected sample is given by .
If Y be the sum of correlated and identically distributed lognormal random variables X, then the approximate distribution of Y is lognormal
distribution with mean , standard deviation
(see Mehta et al (2006)) where
and
for all
.
The parameters and
of the grab sample unit Y is given by,
(see Mussida et al (2013)). For this package development, we have used fixed value with default value 0.8.
Probability of acceptance
Mussida, A., Vose, D. & Butler, F. Efficiency of the sampling plan for Cronobacter spp. assuming a Poisson lognormal distribution of the bacteria in powder infant formula and the implications of assuming a fixed within and between-lot variability, Food Control, Elsevier, 2013 , 33 , 174-185.
Mehta, N.B, Molisch, A.F, Wu, J, & Zhang, J., 'Approximating the Sum of Correlated Lognormal or, Lognormal-Rice Random Variables,' 2006 IEEE International Conference on Communications, Istanbul, 2006, pp. 1605-1610.
c <- 0 r <- 25 t <- 30 mu <- -3 distribution <- 'Poisson lognormal' prob_accept(c, r, t, mu, distribution)
c <- 0 r <- 25 t <- 30 mu <- -3 distribution <- 'Poisson lognormal' prob_accept(c, r, t, mu, distribution)
This function calculates the probability of exactly l
contaminated samples out of t
selected grab samples for given gram sample size r
and serial correlation d
at the process contamination level p
for a production length of N
.
prob_contaminant(l, r, t, d, p, N, method)
prob_contaminant(l, r, t, d, p, N, method)
l |
number of contaminated in |
r |
number of primary increments in a grab sample or grab sample size |
t |
number of grab samples |
d |
serial correlation of contamination between the primary increments |
p |
limiting fraction or proportion of contaminated increments |
N |
length of the production |
method |
what sampling method we have applied such as |
Let be the number of contaminated samples and
where
or
depending on the presence or absence of contamination, then
formula given in Bhat and Lal (1988), also we can use following recurrence relation formula,
which is given in Vellaisamy and Sankar (2001). Both methods will be produced the same results. For this package development, we directly applied formula which is from Bhat and Lal (1988).
Probability of contaminated
Bhat, U., & Lal, R. (1988). Number of successes in Markov trials. Advances in Applied Probability, 20(3), 677-680.
Vellaisamy, P., Sankar, S., (2001). Sequential and systematic sampling plans for the Markov-dependent production process. Naval Research Logistics 48, 451-467.
prob_detect_single_grab, correlation_grab
l <- 1 r <- 25 t <- 30 d <- 0.99 p <- 0.005 N <- 1e9 method <- 'systematic' prob_contaminant(l, r, t, d, p, N, method)
l <- 1 r <- 25 t <- 30 d <- 0.99 p <- 0.005 N <- 1e9 method <- 'systematic' prob_contaminant(l, r, t, d, p, N, method)
This function gives the detection probability for t
grab samples and given acceptance number under systematic or random sampling methods. This function is also used to calculate the detection probability for primary increments selection by setting the number of primary increments as one.
prob_detect(c, r, t, d, p, N, method)
prob_detect(c, r, t, d, p, N, method)
c |
acceptance number |
r |
number of primary increments in a grab sample or grab sample size |
t |
number of grab samples |
d |
serial correlation of contamination between the primary increments |
p |
limiting fraction or proportion of contaminated increments |
N |
length of the production |
method |
what sampling method we have applied such as |
The detection probability of entire selected grab samples is given by,
Probability of detection in all seleceted grab samples
c <- 1 r <- 25 t <- 30 d <- 0.99 p <- 0.005 N <- 1e9 method <- 'systematic' prob_detect(c, r, t, d, p, N, method)
c <- 1 r <- 25 t <- 30 d <- 0.99 p <- 0.005 N <- 1e9 method <- 'systematic' prob_detect(c, r, t, d, p, N, method)
This function calculates the probability of detection in a single grab sample comprising of r
primary increments for given serial correlation d
.
prob_detect_single_grab(r, p, d)
prob_detect_single_grab(r, p, d)
r |
number of primary increments in a grab sample or grab sample size |
p |
limiting fraction or proportion of contaminated increments |
d |
serial correlation of contamination between the primary increments |
The probability of detection in any of the grab sample is given by as
Probability of detection in a grab sample
r <- 25 p <- 0.005 d <- 0.99 prob_detect_single_grab(r, p, d)
r <- 25 p <- 0.005 d <- 0.99 prob_detect_single_grab(r, p, d)