The AccSamplingDesign package provides tools to create and evaluate acceptance sampling plans for both attribute and variable quality data. The focus is on controlling producer’s and consumer’s risk specifications while minimizing required sample sizes.
The package supports:
Install from CRAN:
Or from GitHub:
# Create an attribute plan with binomial assumption
plan_attr <- optPlan(
PRQ = 0.01, # Acceptable quality level (1%)
CRQ = 0.05, # Rejectable quality level (5%)
alpha = 0.02, # Producer's risk
beta = 0.15, # Consumer's risk
distribution = "binomial"
)
# Summary of the plan
summary(plan_attr)
#> Attributes Acceptance Sampling Plan:
#> Distribution: binomial
#> Sample Size (n): 144
#> Acceptance Number (c): 4
#> Producer's Risk (PR = 0.01534843 ) at PRQ = 0.01
#> Consumer's Risk (CR = 0.1487162 ) at CRQ = 0.05
# Probability of accepting 3% defective
accProb(plan_attr, 0.03)
#> [1] 0.5656415
# Plot the OC curve
plot(plan_attr)
# Create a variable plan assuming known sigma
plan_var <- optPlan(
PRQ = 0.025,
CRQ = 0.1,
alpha = 0.05,
beta = 0.10,
distribution = "normal",
sigma_type = "known"
)
# Summary
summary(plan_var)
#> Variables Acceptance Sampling Plan
#> Distribution: normal
#> Sample Size (n): 19
#> Acceptability Constant (k): 1.579
#> Population Standard Deviation: known
#> Producer's Risk (PR = 0.05 ) at PRQ = 0.025
#> Consumer's Risk (CR = 0.1 ) at CRQ = 0.1
# Plot OC curve
plot(plan_var)
# Create a variable plan assuming known sigma
plan_var2 <- optPlan(
PRQ = 0.025,
CRQ = 0.1,
alpha = 0.05,
beta = 0.10,
distribution = "normal",
sigma_type = "unknown"
)
# Summary
summary(plan_var2)
#> Variables Acceptance Sampling Plan
#> Distribution: normal
#> Sample Size (n): 43
#> Acceptability Constant (k): 1.586
#> Population Standard Deviation: unknown
#> Producer's Risk (PR = 0.05 ) at PRQ = 0.025
#> Consumer's Risk (CR = 0.1 ) at CRQ = 0.1
# Create a variable plan using Beta distribution
plan_beta <- optPlan(
PRQ = 0.05,
CRQ = 0.2,
alpha = 0.05,
beta = 0.10,
distribution = "beta",
theta = 44000000,
theta_type = "known",
LSL = 0.00001 # Lower Specification Limit
)
# Summary
summary(plan_beta)
#> Variables Acceptance Sampling Plan
#> Distribution: beta
#> Sample Size (n): 14
#> Acceptability Constant (k): 1.186
#> Population Precision Parameter (theta): known
#> Producer's Risk (PR = 0.04999589 ) at PRQ = 0.05
#> Consumer's Risk (CR = 0.09947491 ) at CRQ = 0.2
#> Lower Specification Limit (LSL): 1e-05
# Plot OC curve
plot(plan_beta)
# Create a variable plan using Beta distribution
plan_beta2 <- optPlan(
PRQ = 0.05,
CRQ = 0.2,
alpha = 0.05,
beta = 0.10,
distribution = "beta",
theta = 44000000,
theta_type = "unknown",
LSL = 0.00001
)
# Summary
summary(plan_beta2)
#> Variables Acceptance Sampling Plan
#> Distribution: beta
#> Sample Size (n): 31
#> Acceptability Constant (k): 1.186
#> Population Precision Parameter (theta): unknown
#> Producer's Risk (PR = 0.04735398 ) at PRQ = 0.05
#> Consumer's Risk (CR = 0.09598793 ) at CRQ = 0.2
#> Lower Specification Limit (LSL): 1e-05
# Define range of defect rates
pd <- seq(0, 0.15, by = 0.001)
# Generate OC data from optimal plan
oc_opt <- OCdata(plan = plan_attr, pd = pd)
# Compare with manual plans
mplan1 <- manualPlan(n = plan_attr$n, c = plan_attr$c - 1, distribution = "binomial")
oc_alt1 <- OCdata(plan = mplan1, pd = pd)
# Plot comparison
plot(pd, oc_opt$paccept, type = "l", col = "blue", lwd = 2,
xlab = "Proportion Defective", ylab = "Probability of Acceptance",
main = "OC Curves Comparison for Attributes Sampling Plan")
lines(pd, oc_alt1$paccept, col = "red", lwd = 2, lty = 2)
legend("topright", legend = c("Optimal Plan", "Manual Plan c - 1"),
col = c("blue", "red"), lty = c(1, 2), lwd = 2)
This vignette provides a quick start for using the AccSamplingDesign package. For a full discussion of the statistical foundations, models, and optimization methods used, please refer to the foundation sources such as:
Schilling, E.G., & Neubauer, D.V. (2017). Acceptance Sampling in Quality Control (3rd ed.). CRC Press.
Wilrich, P.T. (2004). Single Sampling Plans for Inspection by Variables under a Variance Component Situation. In Frontiers in Statistical Quality Control 7.
Govindaraju, K., & Kissling, R. (2015). Sampling plans for Beta-distributed compositional fractions. Quality Engineering, 27(1), 1–13.