R/compare_mixing_3.R
compare_mixing_3.Rd
This function provides a graphical display to compare mixing plans based on the cumulative distribution of expected total CFUs in the mixing process using different mixing parameters, such as type of distribution and number of primary samples.
compare_mixing_3(mu, sigma, alpha_in, k, l, r, distribution, n_sim)
the average number of CFUs (\(\mu\)) in the mixed sample, which is in a logarithmic scale if we use a Lognormal / Poisson lognormal distribution
the standard deviation of the colony-forming units in the mixed sample on the logarithmic scale (default value 0.8)
concentration parameter at the initial stage
number of small portions / primary samples
number of revolutions / stages
the rate of the concentration parameter changes at each mixing stage
what suitable distribution type we have employed for simulation such as "Poisson-Type A"
or "Poisson-Type B"
or "Lognormal-Type A"
or "Lognormal-Type B"
or "Poisson lognormal-Type A"
or "Poisson lognormal-Type B"
number of simulations
Graphical comparison between different mixing schemes.
Let \(N'\) be the number of CFUs in the mixed sample, which is produced by the mixing of \(k\) primary samples and \(N' = \sum N_i\) and let \(N_i\) be the number of CFUs in the \(i^{th}\) primary sample; where \(i = 1,2,....k\).For this package development, we have employed the notations 'Type-A' and 'Type-B' to indicate the type of distributions, which are applied in the previous literature as 'fair' and 'beta', respectively; see Nauta (2005).Following Nauta (2005), the contribution weight of contamination by each primary sample can be defined by the random variable \(w_i\), which is possible to be followed by either uniform distribution with parameter \(1/k\) or the joint distribution of \(w_1,w_2,\cdots w_k\) follows a Dirichlet distribution with concentration parameter \(\alpha\). From the previous literature, a Dirichlet distribution can be formulated by beta or gamma algorithms, which have revealed the same results; see Nauta (2005).This function is developed based on the beta algorithm and the following steps formulate it. $$w_i = x_i {\prod_{j=1}^{i-1}{1-x_j}}~~~~ \forall i = 2,3,\cdots k,~~~~~ w_1=x_1$$;where \(x_i\) follows \(Beta (\alpha,\alpha(k-i))\) and also \(\sum w_i\) must be equal to one.
Case 1 (Poisson-Type A): \(N_i\) follows \(Poisson(\mu/k)\)
Case 2 (Poisson-Type B): \(N_i\) follows \(Poisson(\mu w_i)\)
Case 3 (Lognormal-Type A): \(N_i\) follows \(Binomial(M_i,1/k)\); where \(M_i\) follows \(Lognormal(\mu, \sigma)\)
Case 4 (Lognormal-Type B): \(N_i\) follows \(Binomial(M_i,w_i)\); where \(M_i\) follows \(Lognormal(\mu, \sigma)\)
Case 5 (Poisson lognormal-Type A): \(N_i\) follows \(Binomial(M_i,1/k)\); where \(M_i\)
follows \(Poisson lognormal (\mu, \sigma)\)
Case 6 (Poisson lognormal-Type B): \(N_i\) follows \(Binomial(M_i,w_i)\); where \(M_i\)
follows \(Poisson lognormal(\mu, \sigma)\)
The powder-mixing process can be defined as breaking clusters stage-by-stage. Usually, it occurs systematically in the standard powder mixtures. For this package development, we assume that mixing parameters also systematically change with a fixed rate at each stage of the mixing. The mixing parameter can be defined as revolutions instead of the mixing stage in general. Due to the lack of theoretical results for the dependent random variable sum's distribution, we have chosen simulation techniques for this modelling.
Let \(l\) be the number of stages or revolutions of the mixture, and we also assumed a fixed concentration parameter value at the initial phase of the mixing process. Based on the literature in this area, the concentration parameter can be assumed to increase at every stage of the mixing, which is possible to do systematically.
Therefore, this function exhibits the graphical display with different quantities of primary sample mixing as a large unit.
Nauta, M.J., 2005. Microbiological risk assessment models for partitioning and mixing during food handling. International Journal of Food Microbiology 100, 311-322.
mu <- 100
sigma <- 0.8
alpha_in <- 0.01
k <- c(10,30,60)
r <- 0.01
distribution <- c("Poisson lognormal-Type B","Poisson lognormal-Type B","Poisson lognormal-Type B")
n_sim <- 2000
plot1 <- compare_mixing_3(mu, sigma, alpha_in, k , l = 200,r, distribution,n_sim) +
ggplot2::theme(legend.text = ggplot2::element_text(size = 7.5),
legend.title = ggplot2::element_text(size = 7.5),
legend.key.size = ggplot2::unit(4, 'mm'))
plot2 <- compare_mixing_3(mu, sigma, alpha_in, k , l = 500, r, distribution, n_sim) +
ggplot2::theme(legend.title = ggplot2::element_text(size = 7.5),
legend.key.size = ggplot2::unit(4, 'mm'))
plot3 <- compare_mixing_3(mu, sigma, alpha_in, k, l = 5000,r , distribution,n_sim) +
ggplot2::theme(legend.text = ggplot2::element_text(size = 7.5),
legend.title = ggplot2::element_text(size = 7.5),
legend.key.size = ggplot2::unit(4, 'mm'))
plot4 <- compare_mixing_3(mu, sigma , alpha_in , k , l = 25000, r , distribution ,n_sim) +
ggplot2::theme(legend.text = ggplot2::element_text(size = 7.5),
legend.title = ggplot2::element_text(size = 7.5),
legend.key.size = ggplot2::unit(4, 'mm'))
gridExtra::grid.arrange(plot1, plot2, plot3, plot4, ncol = 2, nrow = 2)