Learn R Programming

AccSamplingDesign (version 0.0.4)

OCdata: Generate OC Curve Data

Description

Computes and returns an object of class "OCdata", which contains the Operating Characteristic (OC) curve data. This includes the proportion of nonconforming items and the corresponding probability of acceptance, along with plan-related metadata. This function supports both optimal plan objects (e.g. found from "optPlan()" method) and custom plan parameter inputs.

Accessor functions paccept(), pd(), and process_means() provide safe access to components of the OCdata object.

Usage

OCdata(plan = NULL, pd = NULL,
       distribution = c("binomial", "poisson", "normal", "beta"),
       n = NULL, c = NULL, k = NULL,
       USL = NULL, LSL = NULL, sigma = NULL, theta = NULL,
       PRQ = NULL, CRQ = NULL, alpha = NULL, beta = NULL,
       sigma_type = c("known", "unknown"),
       theta_type = c("known", "unknown"))

Value

For OCdata: an object of class "OCdata" (a list) with components:

pdNumeric vector of proportions of nonconforming items (defective).
pacceptNumeric vector of probabilities of acceptance at each level of nonconformance.
process_meansNumeric vector of estimated mean values (only for variable plans with specification limits).
distDistribution type ("binomial", "poisson", "normal", or "beta").
nSample size used in the plan.
kAcceptability constant (if applicable).
cAcceptance number (if applicable).

Arguments

plan

An optional acceptance plan object of class AttrPlan or VarPlan. If supplied, this overrides other individual parameter inputs.

pd

An optional vector of proportions of nonconforming items. If NULL, the function generates a default sequence based on CRQ.

distribution

Distribution type used for the plan. Options are "binomial", "poisson", "normal", or "beta". Required if plan is not provided.

n

Sample size.

c

Acceptance number (for Attributes Sampling).

k

Acceptability constant (for Variables Sampling).

USL

Upper Specification Limit (used for variable sampling plans). Only one of USL or LSL should be provided.

LSL

Lower Specification Limit (used for variable sampling plans). Only one of USL or LSL should be provided.

sigma

Standard Deviation for Normal distribution.

theta

Precision parameter for Beta distribution.

PRQ

Producer's Risk Quality level - optional.

CRQ

Consumer's Risk Quality level - optional.

alpha

Producer’s risk - optional.

beta

Consumer’s risk - optional.

sigma_type

Whether sigma is "known" or "unknown".

theta_type

Whether theta is "known" or "unknown".

Author

Ha Truong

Details

The function evaluates the Operating Characteristic (OC) curve by computing the probability of acceptance across a range of proportions of nonconforming items (pd). This can be either directly specified or derived based on the plan inputs.

If a plan object is supplied, it overrides the other input parameters and uses stored plan details. If no plan is provided, a new one will be constructed from the inputs.

For:

  • Binomial or Poisson distribution: n and c must be provided.

  • Normal or Beta distribution: n (or m) and k are required. Either USL or LSL must be specified to compute process mean values using muEst.

The resulting OC curve data includes acceptance probabilities at various quality levels and, for variable plans, optionally maps these probabilities to corresponding mean levels.

Examples

Run this code
# Example 1: Variables Sampling (Normal distribution)
plan <- optVarPlan(
  PRQ = 0.025,
  CRQ = 0.1,
  alpha = 0.05,
  beta = 0.1,
  distribution = "normal"
)

# Generate OC data from optimal plan
oc_data <- OCdata(plan, pd = seq(0, 0.15, by = 0.001))

# Plot the OC curve
plot(oc_data)

# Example 2: Attributes Sampling
# Generate OC data from custom plan
oc_data2 <- OCdata(n = 132, c = 5, distribution = "binomial", 
                   pd = seq(0, 0.15, by = 0.001))

# Plot the OC curve
plot(oc_data2)

Run the code above in your browser using DataLab