Statistical Process Control (SPC) Introduction

Part I

Ke Zhang

2025-11-24

Introduction to SPC

  • Definition: Statistical Process Control (SPC) is a method using statistical techniques to monitor, control, and improve processes by analyzing variation in data over time.
  • Purpose: Helps detect process changes, reduce variation, improve quality, and ensure processes are stable and predictable.
  • Benefits: Reduces waste, improves efficiency, enhances product quality, and supports data-driven decision-making.

History of SPC

  • 1920s: Pioneered by Walter A. Shewhart at Bell Laboratories. Developed the first control charts to distinguish between common and special cause variation.
  • 1930s-1940s: W. Edwards Deming promoted SPC; applied during WWII by the US military for quality control in manufacturing.
  • Post-WWII: Deming introduced SPC to Japan, contributing to their quality revolution (e.g., Toyota Production System).
  • 1980s-1990s: Integrated into Six Sigma methodology by Motorola and GE.
  • Modern Era: Evolved with software, real-time data, and integration with IoT and AI for predictive analytics.

Development of SPC

  • From Manual to Digital: Started with paper charts; now uses software for real-time monitoring (e.g., Minitab, JMP).

  • Integration with Quality Systems: Became core to ISO 9001, Six Sigma, Lean Manufacturing.

  • Advanced Techniques: Beyond Shewhart charts, includes CUSUM and EWMA for small shifts.

  • Industry Adoption: Widely used in manufacturing, healthcare, services; expanded to non-manufacturing processes.

  • Current Trends: AI-driven SPC, predictive maintenance, cloud-based analytics for global teams.

Foundation to Implement SPC

  • Understand Variation: Differentiate common (inherent) vs. special (assignable) causes.
  • Management Commitment: Leadership support for resources, training, and culture change.
  • Training: Educate teams on basics, chart interpretation, and response to signals.
  • Data Collection: Reliable, accurate data from key process points; use automated systems if possible.
  • Process Selection: Start with critical processes; map them to identify variables.
  • Baseline Establishment: Collect initial data to set control limits.
  • Continuous Improvement: Review, act on signals, and refine.

Common vs Specaial Cause

Common vs Special Cause Variation

SPC Theory: Key Concepts

  • Sigma (σ): Standard deviation; measures process variation. 3σ limits capture 99.7% of common cause variation.
  • Control Limits: Calculated from process data (UCL = mean + 3σ, LCL = mean - 3σ); indicate stability.
  • Specification Limits: Customer-defined (USL, LSL); for acceptability, not control.
  • Process Capability: Cp = (USL - LSL)/6σ; Cpk adjusts for centering. >1.33 is good.
  • Stable Process: Only common cause variation; predictable within limits.

Control vs Spec Limits

SPC Chart Types

  • Variable Charts: For continuous data.

    • X-bar & R: Average and range.

    • X-bar & S: Average and std dev.

    • Individuals & Moving Range: For single measurements.

  • Attribute Charts: For discrete data.

    • p-chart: Proportion defective.

    • np-chart: Number defective.

    • c-chart: Count of defects.

    • u-chart: Defects per unit.

  • Other: EWMA, CUSUM for small shifts.

Example SPC Chart

SPC Rules and Out-of-Control Signals

  • Western Electric Rules (basic set):

    • 1 point beyond 3σ limits.

    • 2 out of 3 points beyond 2σ.

    • 4 out of 5 points beyond 1σ.

    • 8 consecutive points on one side of center.

  • Nelson Rules (expanded, 8 rules): Includes trends, runs, etc.

  • Use to detect non-random patterns indicating special causes.

Western Electric Rules

Potential Violation Reasons

  • Points Beyond Limits: Sudden shift in process mean (e.g., tool breakage, material change).

  • Runs/Trending: Gradual shift (e.g., tool wear, temperature drift).

  • Too Many Near Center: Overcontrol or data manipulation.

  • Cycles: Periodic factors (e.g., operator shifts, machine cycles).

  • Stratification: Mixed processes or incorrect subgrouping.

  • Investigate root causes using 5 Whys or fishbone diagram.

Shewhart SPC Constraints

  • Assumes Normality: Sensitive to non-normal data; may give false signals.

  • Detects Large Shifts Well: Poor for small shifts (<1.5σ).

  • Autocorrelation: Assumes independent data; fails with correlated processes.

  • Short Runs: Needs 20-30 points for reliable limits; not ideal for low-volume.

  • Over-Reliance on Rules: Too many rules increase false alarms (Type I error).

  • Alternatives Needed: For small shifts or non-normal, use CUSUM/EWMA.

Non-Shewhart SPC: CUSUM and EWMA

  • CUSUM (Cumulative Sum): Accumulates deviations from target; sensitive to small, sustained shifts.

    • Formula: C_i^+ = max(0, x_i - (μ_0 + K) + C_{i-1}^+)

    • Good for detecting shifts of 0.5-1σ.

  • EWMA (Exponentially Weighted Moving Average): Weights recent data more; λ (0.05-0.3) controls sensitivity.

    • Formula: z_i = λ x_i + (1-λ) z_{i-1}

    • Better for non-normal data and small shifts.

  • Use when Shewhart fails to detect subtle changes.

CUSUM Chart Example

EWMA Chart Example

Interactive SPC Example

Explore a simple X-bar control chart with adjustable parameters.

#| '!! shinylive warning !!': |
#|   shinylive does not work in self-contained HTML documents.
#|   Please set `embed-resources: false` in your metadata.
#| standalone: true
#| viewerHeight: 800
library(shiny)
library(qcc)

ui <- fluidPage(
  titlePanel("Interactive SPC Control Chart"),
  sidebarLayout(
    sidebarPanel(
      selectInput("chart_type", "Chart Type:", choices = c("X-bar", "cusum")),
      sliderInput("n", "Sample Size (n):", min = 2, max = 10, value = 5),
      sliderInput("mean", "Process Mean:", min = 0, max = 100, value = 50),
      sliderInput("sd", "Process SD:", min = 1, max = 10, value = 5),
      sliderInput("samples", "Number of Subgroups:", min = 10, max = 50, value = 20),
      numericInput("usl", "Upper Spec Limit (USL):", value = 60),
      numericInput("lsl", "Lower Spec Limit (LSL):", value = 40),
      actionButton("generate", "Generate Data")
    ),
    mainPanel(
      plotOutput("controlChart",height="350px"),
      plotOutput("capabilityChart",height="350px"),
      verbatimTextOutput("violations")
    )
  )
)

server <- function(input, output, session) {
  data <- reactiveVal()
  
  observeEvent(input$generate, {
    set.seed(NULL)  # optional: remove if you want reproducibility
    base_data <- matrix(rnorm(input$samples * input$n, input$mean, input$sd), 
                        nrow = input$samples)
    
    shift_start <- round(input$samples * 1/5)
    base_data[shift_start:input$samples, ] <- base_data[shift_start:input$samples, ] + 0.5 * input$sd
    
    # Add an obvious outlier in the last subgroup
    base_data[input$samples, 1] <- base_data[input$samples, 1] + 3 * input$sd
    
    data(base_data)
  })
  
  # Reactive qcc object for X-bar (shared when possible)
  qcc_xbar <- reactive({
    req(data())
    qcc(data(), type = "xbar", plot = FALSE)
  })
  
  output$controlChart <- renderPlot({
    req(data())
    
    if (input$chart_type == "X-bar") {
      q <- qcc(data(), type = "xbar")
      plot(q, title = "X-bar Chart (with Western Electric rules)")
    } else if (input$chart_type == "cusum") {
      q <- cusum(data(), decision.interval = 5, se.shift = 1)
      plot(q, title = "CUSUM Chart")
    }
  })
  
  output$violations <- renderPrint({
    req(data())
    
    if (input$chart_type == "X-bar") {
      q <- qcc(data(), type = "xbar", plot = FALSE)
      cat("Western Electric / Nelson Rules Violations:\n")
      print(shewhart.rules(q))
    } else if (input$chart_type == "cusum") {
      q <- cusum(data(), decision.interval = 5, se.shift = 1, plot = FALSE)
      cat("CUSUM Violations (points beyond decision interval):\n")
      print(q$violations)
    }
  })
  
  output$capabilityChart <- renderPlot({
    req(data())
    # Correct way: assign q first, then use it
    q <- qcc(data(), type = "xbar", nsigmas = 3, plot = FALSE)
    process.capability(q, spec.limits = c(input$lsl, input$usl))
  })
}

shinyApp(ui, server)

Best Practices for Beginner

  • Start Simple: Begin with basic charts (p chart or X-bar/R) on one process.

  • Hands-On Training: Use simulations or real data exercises.

  • Interpret Correctly: Focus on patterns, not just points out of limits.

  • Act on Signals: Investigate special causes promptly; document actions.

  • Avoid Tampering: Don’t adjust stable processes (increases variation).

  • Regular Reviews: Update limits as process improves.

  • Software Tools: Learn Minitab, Excel add-ins, or R/Python for charts.

  • Common Pitfalls: Confusing control/spec limits, ignoring autocorrelation.

Resources

  • Books: “Introduction to Statistical Quality Control” by Douglas Montgomery.

  • Online Courses: ASQ SPC Certification, AIAG SPC Certification

  • Software: Minitab, JMP, SPC for Excel, R (qcc package), Python (scipy, statsmodels).

  • Standards: ISO 7870 (Control Charts), AIAG Manuals for automotive.

  • Websites: ASQ.org, SixSigmaStudyGuide.com, SPCforexcel.com.