Design optimal variable acceptance sampling plans based on specified parameters. Supports different distributions (binomial, poisson, normal, beta) and accommodates known or unknown standard deviation and process parameters.
optPlan(PRQ, CRQ, alpha = 0.05, beta = 0.10, USL = NULL, LSL = NULL,
distribution = c("binomial", "poisson", "normal", "beta"),
sigma_type = c("known", "unknown"),
theta_type = c("known", "unknown"),
sigma = NULL, theta = NULL)Returns a list or data frame with optimal sample size(s) and critical value(s) based on the specified parameters and distribution.
Selected distribution
Final sample size after rounding up to the next integer, for practical application.
Sample size (unrounded for Variables Acceptance Sampling).
Acceptability constant - For Variables Acceptance Sampling.
Acceptance number - For Attributes Acceptance Sampling.
Producer's risk quality level (e.g., acceptable quality level).
Consumer's risk quality level (e.g., rejectable quality level).
Producer's risk (Type I error), default is 0.05.
Consumer's risk (Type II error), default is 0.10.
Upper Specification Limit. Required for variable sampling plans.
Lower Specification Limit. Required for variable sampling plans.
Distribution type used in the plan. Can be "binomial", "poisson", "normal", or "beta".
Indicates if the standard deviation (sigma) is known or unknown.
Indicates if the process parameter (theta) is known or unknown.
Known standard deviation of the process, if applicable.
Precision (dispersion) parameter for the beta distribution.
If unknown, it can be estimated from historical data using functions such as betaff.
Ha Truong
This function designs optimal acceptance sampling plans by balancing producer's and consumer's risks under specified quality levels. It supports plans for attributes (binomial) and variables (normal or beta distributions), including cases with unknown standard deviation or distributional parameters.
For the "normal" model, the plan can be computed assuming the standard deviation
(sigma) is either known or estimated from data. Optimization for unknown sigma
is performed using the derivative-free Nelder-Mead method (Nelder and Mead, 1965) via
optim in base R.
For the "beta" model, the dispersion (precision) parameter theta determines
how concentrated the distribution is around the mean. Users must either:
provide a known value for theta, typically obtained from prior process studies or historical data; or
estimate it from sample data using a fitting function such as betaff in the VGAM package.
Optimization for Beta plans is performed using optim with the "L-BFGS-B" method
(Byrd et al., 1995) to handle bounds on sample size and acceptance numbers.
This approach ensures stable and efficient plan calculation while relying solely on base R functionality.
* ISO 2859-1:1999 - Sampling procedures for inspection by attributes
* ISO 3951-1:2013 - Sampling procedures for inspection by variables.
* Wilrich, PT. (2004). Single Sampling Plans for Inspection by Variables under a Variance Component Situation. In: Lenz, HJ., Wilrich, PT. (eds) Frontiers in Statistical Quality Control 7. Physica, Heidelberg.
* K. Govindaraju and R. Kissling (2015). Sampling plans for Beta-distributed compositional fractions.
* J. A. Nelder and R. Mead. A simplex method for function minimization. The Computer Journal, 7(4): 308–313, 1965. DOI 10.1093/comjnl/7.4.308.
* R. H. Byrd, P. Lu, J. Nocedal and C. Zhu. A limited memory algorithm for bound constrained optimization. SIAM Journal on Scientific Computing, 16(5): 1190–1208, 1995. DOI 10.1137/0916069.
# Example usage (normal distribution, known sigma):
optPlan(PRQ = 0.005, CRQ = 0.03, alpha = 0.05, beta = 0.10,
distribution = "normal", sigma_type = "known")
# Example usage (beta distribution, unknown theta):
optPlan(PRQ = 0.025, CRQ = 0.10, alpha = 0.05, beta = 0.10,
distribution = "beta", theta = 6.6e8,
theta_type = "unknown", LSL = 5.65e-6)
Run the code above in your browser using DataLab