Type: | Package |
Title: | Probability of Detection for Grab Sample Selection |
Version: | 1.0.0 |
URL: | https://github.com/Mayooran1987/grabsampling |
BugReports: | https://github.com/Mayooran1987/grabsampling/issues |
Description: | Functions for obtaining the probability of detection, for grab samples selection by using two different methods such as systematic or random based on two-state Markov chain model. For detection probability calculation, we used results from Bhat, U. and Lal, R. (1988) <doi:10.2307/1427041>. |
License: | GPL-2 | GPL-3 [expanded from: GPL (≥ 2)] |
Encoding: | UTF-8 |
LazyData: | true |
Imports: | extraDistr, ggplot2, ggthemes, plyr, reshape2, stats |
Suggests: | testthat |
RoxygenNote: | 7.0.2 |
Depends: | R (≥ 3.2) |
Maintainer: | Mayooran Thevaraja <mayooran@eng.jfn.ac.lk> |
Language: | en-US |
NeedsCompilation: | no |
Packaged: | 2020-02-26 18:55:11 UTC; hp |
Author: | Mayooran Thevaraja [aut, cre], Kondaswamy Govindaraju [aut], Mark Bebbington [aut] |
Repository: | CRAN |
Date/Publication: | 2020-03-04 17:10:02 UTC |
Construction of AOQ curve and calculate AOQL value based on limiting fraction
Description
AOQL_grab_A
provides the AOQ curve and calculates AOQL value based on limiting fraction of contaminated increments.
Usage
AOQL_grab_A(c, r, t, d, N, method, plim)
Arguments
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 |
Details
Since P_{ND}
is the probability of non-detection, p
is the limiting fraction of contaminated increments and the outgoing contaminated proportion of primary increments is given by AOQ
as the product pP_{ND}
.
The quantity AOQL
is defined as the maximum proportion of outgoing contaminated primary increments and is given by
AOQL ={\max_{0\leq p\leq 1}}{pP_{ND}}
Value
AOQ curve and AOQL value based on on limiting fraction
See Also
Examples
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)
Construction of AOQ curve and calculate AOQL value based on average microbial counts
Description
AOQL_grab_B
provides the AOQ curve and calculates AOQL value based on average microbial counts.
Usage
AOQL_grab_B(c, r, t, distribution,llim, K, m, sd)
Arguments
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) |
Details
Since P_a
is the probability of acceptance, \lambda
is the arithmetic mean of cell count and the outgoing contaminated arithmetic mean of cell count of primary increments is given by AOQ
as the product \lambda P_a
.
The quantity AOQL
is defined as the maximum proportion of outgoing contaminated primary increments and is given by
AOQL ={\max_{\lambda \geq 0}}{\lambda P_a}
Value
AOQ curve and AOQL value based on average microbial counts
See Also
Examples
c <- 0
r <- 25
t <- 30
distribution <- 'Poisson lognormal'
llim <- 0.20
AOQL_grab_B(c, r, t, distribution, llim)
Probability of detection or non detection versus fraction nonconforming curve
Description
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 P_D
or probability of non detection P_{ND}
versus fraction nonconforming p
for up to four selected schemes will be produced.
Usage
compare_plans(d, N, plim, type, c1, r1, t1, method1, c2, r2, t2, method2,
c3, r3, t3, method3, c4, r4, t4, method4)
Arguments
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 |
Value
Probability of detection or non detection vs limiting fraction curves
Examples
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)
Comparison based on OC curve
Description
This function produces overlaid Operating Characteristic (OC) curves for any three systematic/random sampling schemes for specified parameters.
Usage
compare_plans_oc(c1, c2, c3, r1, t1, r2, t2, r3, t3, distribution, K, m, sd)
Arguments
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) |
Value
overlaid OC curves
See Also
Examples
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)
Serial correlation between grab samples
Description
This function calculates the resulting serial correlation between grab samples each having r
primary increments with original serial correlation d
.
Usage
correlation_grab(r, p, d)
Arguments
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 |
Details
The serial correlation between blocks (grab samples) is given by d_g
as
d_g = [dp(1-p(1-d))^{r-1}]/p_d
where p_d
is the probability of detection in any of the block (grab sample) which is calculated by using prob_detect_single_grab.
Value
Serial correlation between grab samples
See Also
Examples
r <- 25
p <- 0.005
d <- 0.99
correlation_grab(r, p, d)
Construction of Operating Characteristic (OC) curve
Description
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.
Usage
oc_plan(c, r, t, distribution, K, m, sd)
Arguments
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) |
Details
Based on the food safety literature, mean concentration is given by \lambda = 10^{\mu+log(10)\sigma^2/2}
.
Value
Operating Characteristic (OC) curve
See Also
Examples
c <- 0
r <- 25
t <- 30
distribution <- 'Poisson lognormal'
oc_plan(c, r, t, distribution)
Probability of acceptance for grab sampling scheme
Description
This function calculates the overall probability of acceptance for given microbiological distribution such as lognormal.
Usage
prob_accept(c, r, t, mu, distribution, K, m, sd)
Arguments
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) |
Details
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, p_d=P(X > m)=1-P_{distribution}(X \le m|\mu ,\sigma)
and acceptance probability in t
selected sample is given by P_a=P_{binomial}(X \le c|t,p_d)
.
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 \mu_y
, standard deviation \sigma_y
(see Mehta et al (2006)) where E(Y)=mE(X)
and V(Y)=mV(X)+cov(X_i,X_j)
for all i \ne j =1 \cdots r
.
The parameters \mu_y
and \sigma_y
of the grab sample unit Y is given by,
\mu_y =\log_{10}{(E[Y])} - {{\sigma_y}^2}/2 \log_e(10)
(see Mussida et al (2013)). For this package development, we have used fixed \sigma_y
value with default value 0.8.
Value
Probability of acceptance
References
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.
Examples
c <- 0
r <- 25
t <- 30
mu <- -3
distribution <- 'Poisson lognormal'
prob_accept(c, r, t, mu, distribution)
Probability of contaminated sample
Description
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
.
Usage
prob_contaminant(l, r, t, d, p, N, method)
Arguments
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 |
Details
Let S_t
be the number of contaminated samples and S_t=\sum X_t
where X_t=1
or 0
depending on the presence or absence of contamination, then P(S_t=l)
formula given in Bhat and Lal (1988), also we can use following recurrence relation formula,
P(S_t=l)=P(X_t=1;S_{t-1}=l-1) + P(X_t=0;S_{t-1}=l)
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).
Value
Probability of contaminated
References
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.
See Also
prob_detect_single_grab, correlation_grab
Examples
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)
Probability of detection under the grab sampling method
Description
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.
Usage
prob_detect(c, r, t, d, p, N, method)
Arguments
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 |
Details
The detection probability of entire selected grab samples is given by,
P_D=1-[P(S_t=0)+P(S_t=1)+\cdots +P(S_t=c)]
Value
Probability of detection in all seleceted grab samples
See Also
Examples
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)
Probability of detection in a single grab sample
Description
This function calculates the probability of detection in a single grab sample comprising of r
primary increments for given serial correlation d
.
Usage
prob_detect_single_grab(r, p, d)
Arguments
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 |
Details
The probability of detection in any of the grab sample is given by p_d
as
p_d = 1-(1-p)(1-p(1-d))^{r-1}
Value
Probability of detection in a grab sample
Examples
r <- 25
p <- 0.005
d <- 0.99
prob_detect_single_grab(r, p, d)