Package 'grabsampling'

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

Help Index


Probability of detection for grab sample selection

Description

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.

Author(s)

Mayooran Thevaraja, Kondaswamy Govindaraju, Mark Bebbington

References

  • 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.


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 'systematic' or 'random' selection methods

plim

the upper limit for graphing the fraction nonconforming or proportion of contaminated increments

Details

Since PNDP_{ND} is the probability of non-detection, pp is the limiting fraction of contaminated increments and the outgoing contaminated proportion of primary increments is given by AOQAOQ as the product pPNDpP_{ND}. The quantity AOQLAOQL is defined as the maximum proportion of outgoing contaminated primary increments and is given by

AOQL=max0p1pPNDAOQL ={\max_{0\leq p\leq 1}}{pP_{ND}}

Value

AOQ curve and AOQL value based on on limiting fraction

See Also

prob_detect

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 'Poisson gamma' or 'Lognormal'or 'Poisson lognormal'

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 PaP_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 AOQAOQ as the product λPa\lambda P_a. The quantity AOQLAOQL is defined as the maximum proportion of outgoing contaminated primary increments and is given by

AOQL=maxλ0λPaAOQL ={\max_{\lambda \geq 0}}{\lambda P_a}

Value

AOQ curve and AOQL value based on average microbial counts

See Also

prob_accept

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 PDP_D or probability of non detection PNDP_{ND} versus fraction nonconforming pp 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,linetype)

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 D or ND. compare_plans produces a graphical display of PDP_D or PNDP_{ND} versus pp depending on the D or ND of type

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 'systematic' or 'random' selection methods

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)

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 'Poisson gamma' or 'Lognormal'or 'Poisson lognormal'

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

prob_accept

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)

Comparison based on OC curve with different standard deviations

Description

This function produces overlaid Operating Characteristic (OC) curves for any three systematic/random sampling schemes for specified parameters with different standard deviation vlues.

Usage

compare_plans_oc_sd(c1, c2, c3, r1, t1, r2, t2, r3, t3, sd1, sd2, sd3, distribution, K, m)

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

sd1, sd2, sd3

standard deviations of the lognormal and Poisson-lognormal distributions on the log10 scale

distribution

what distribution we have used such as 'Poisson gamma' or 'Lognormal'or 'Poisson lognormal'

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

Value

overlaid OC curves

See Also

prob_accept

Examples

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)

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 dgd_g as

dg=[dp(1p(1d))r1]/pdd_g = [dp(1-p(1-d))^{r-1}]/p_d

where pdp_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

prob_detect_single_grab

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 'Poisson gamma' or 'Lognormal' or 'Poisson lognormal'

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 λ=10μ+log(10)σ2/2\lambda = 10^{\mu+log(10)\sigma^2/2}.

Value

Operating Characteristic (OC) curve

See Also

prob_accept

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 'Poisson gamma' or 'Lognormal'or 'Poisson lognormal'

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, pd=P(X>m)=1Pdistribution(Xmμ,σ)p_d=P(X > m)=1-P_{distribution}(X \le m|\mu ,\sigma) and acceptance probability in t selected sample is given by Pa=Pbinomial(Xct,pd)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 μy\mu_y, standard deviation σy\sigma_y (see Mehta et al (2006)) where E(Y)=mE(X)E(Y)=mE(X) and V(Y)=mV(X)+cov(Xi,Xj)V(Y)=mV(X)+cov(X_i,X_j) for all ij=1ri \ne j =1 \cdots r.

The parameters μy\mu_y and σy\sigma_y of the grab sample unit Y is given by,

μy=log10(E[Y])σy2/2loge(10)\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 σy\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 t selected samples

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 'systematic' or 'random' selection methods

Details

Let StS_t be the number of contaminated samples and St=XtS_t=\sum X_t where Xt=1X_t=1 or 00 depending on the presence or absence of contamination, then P(St=l)P(S_t=l) formula given in Bhat and Lal (1988), also we can use following recurrence relation formula,

P(St=l)=P(Xt=1;St1=l1)+P(Xt=0;St1=l)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 'systematic' or 'random' selection methods

Details

The detection probability of entire selected grab samples is given by,

PD=1[P(St=0)+P(St=1)++P(St=c)]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

prob_contaminant

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 pdp_d as

pd=1(1p)(1p(1d))r1p_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)