Learn R Programming

AccSamplingDesign (version 0.0.4)

plot.VarPlan: Plot the OC Curve for Variable Sampling Plans

Description

Plots the Operating Characteristic (OC) curve for an object of class VarPlan. Supports plotting against either the proportion of nonconforming items or the corresponding process mean levels, depending on availability.

Usage

# S3 method for VarPlan
plot(x, pd = NULL, by = c("pd", "mean"), ...)

Value

A plot showing the OC curve for the given variable sampling plan, either by nonconforming proportion or mean level.

Arguments

x

An object of class VarPlan representing a variable acceptance sampling plan.

pd

Optional numeric vector of proportions of nonconforming items to evaluate. If NULL (default), a suitable range is generated automatically.

by

Character string indicating which x-axis to use for plotting. Either "pd" for proportion nonconforming (default) or "mean" for process mean levels. If "mean" is selected but the plan lacks specification limits, an error is raised.

...

Additional graphical parameters passed to plot().

Author

Ha Truong

Details

This plotting method visualizes the probability of acceptance (P(accept)) against the desired metric, based on the parameters of a variable sampling plan.

If by = "pd", the x-axis represents the proportion of nonconforming items. If by = "mean" and the plan defines limit_type and spec_limit, the function estimates corresponding process means using muEst and plots the OC curve by those mean values.

Reference lines for the Producer's Risk Quality (PRQ) and Consumer's Risk Quality (CRQ), along with their respective acceptance probabilities, are shown when plotting by proportion.

See Also

optVarPlan, accProb, muEst, OCdata, plot.OCdata

Examples

Run this code
# Variable sampling plan with specification limits
plan <- optVarPlan(
  PRQ = 0.025, CRQ = 0.1,
  alpha = 0.05, beta = 0.1,
  distribution = "normal",
  USL = 3, sigma = 0.1
)

# Plot by proportion nonconforming
plot(plan, by = "pd")

# Plot by estimated mean level (requires spec_limit and limit_type)
plot(plan, by = "mean")

# Custom pd vector
plot(plan, pd = seq(0.01, 0.15, by = 0.001))

Run the code above in your browser using DataLab