qcc                   package:qcc                   R Documentation

_Q_u_a_l_i_t_y _C_o_n_t_r_o_l _C_h_a_r_t_s

_D_e_s_c_r_i_p_t_i_o_n:

     Create an object of class `qcc' to perform statistical quality
     control. This object may then be used to plot Shewhart charts,
     Cusum and EWMA plotting, drawing OC curves, computes capability
     indices, and more.

_U_s_a_g_e:

     qcc(data, type, sizes, center, std.dev, limits, target, 
         data.name, labels, newdata, newsizes, newlabels, 
         nsigmas = 3, confidence.level, rules = shewhart.rules, 
         plot = TRUE, ...)

     ## S3 method for class 'qcc':
     print(x, ...)

     ## S3 method for class 'qcc':
     summary(object, ...)

     ## S3 method for class 'qcc':
     plot(x, add.stats = TRUE, chart.all = TRUE, 
          label.limits = c("LCL ", "UCL"), title, xlab, ylab, ylim, 
          axes.las = 0, restore.par = TRUE, ...)

_A_r_g_u_m_e_n_t_s:

    data: a data frame, a matrix or a vector containing observed data
          for the variable to chart. Each row of a data frame or a
          matrix, and each value of a vector, refers to a sample or
          ``rationale group''.

    type: a character string specifying the group statistics to
          compute:

                          Statistic charted   Chart description
            '"xbar"'      mean                means of a continuous process variable
            '"S"'         standard deviation  standard deviations of a continuous variable
            '"R"'         range               ranges of a continuous process variable
            '"xbar.one"'  mean                one-at-time data of a continuous process variable
            '"p"'         proportion          proportion of nonconforming units
            '"np"'        count               number of nonconforming units
            '"c"'         count               nonconformities per unit
            '"u"'         count               average nonconformities per unit

   sizes: a value or a vector of values specifying the sample sizes
          associated with each group. For continuous data provided as
          data frame or matrix the sample sizes are obtained counting
          the non-'NA' elements of each row. For '"p"', '"np"' and
          '"u"' charts the argument 'sizes' is required.

  center: a value specifying the center of group statistics.

 std.dev: a value or a vector of values specifying the within-group
          standard deviation(s) of the process.

  limits: a two-values vector specifying control limits.

  target: a value specifying the ``target'' value of the process.

data.name: a string specifying the name of the variable which appears
          on the plots. If not provided is taken from the object given
          as data.

  labels: a character vector of labels for each group.

 newdata: a data frame, matrix or vector, as for the 'data' argument,
          providing further data to plot but not included in the
          computations.

newsizes: a vector as for the 'sizes' argument providing further data
          sizes to plot but not included in the computations.

newlabels: a character vector of labels for each new group defined in
          the argument 'newdata'.

 nsigmas: a numeric value specifying th number of sigmas to use for
          computing control limits. It is ignored when the
          'confidence.level' argument is  provided.

confidence.level: a numeric value between 0 and 1 specifying the
          confidence level of the computed probability limits.

   rules: a function of rules to apply to the chart. By default, the
          'shewhart.rules' function is used.

    plot: logical. If 'TRUE' a Shewhart chart is plotted.

add.stats: a logical value indicating whether statistics and other
          information should be printed at the bottom of the chart.

chart.all: a logical value indicating whether both statistics for
          'data' and for 'newdata' (if given) should be plotted.

label.limits: a character vector specifying the labels for control
          limits.

   title: a string giving the label for the main title.

    xlab: a string giving the label for the x-axis.

    ylab: a string giving the label for the y-axis.

    ylim: a numeric vector specifying the limits for the y-axis.

axes.las: numeric in {0,1,2,3} specifying the style of axis labels. See
          'help(par)'.

restore.par: a logical value indicating whether the previous 'par'
          settings must be restored. If you need to add points, lines,
          etc. to a control chart set this to 'FALSE'.

  object: an object of class `qcc'.

       x: an object of class `qcc'.

     ...: additional arguments to be passed to the plotting function.

_V_a_l_u_e:

     Returns an object of class `qcc'

_A_u_t_h_o_r(_s):

     Luca Scrucca luca@stat.unipg.it

_R_e_f_e_r_e_n_c_e_s:

     Montgomery, D.C. (2000) _Introduction to Statistical Quality
     Control_, 4th ed. New York: John Wiley & Sons. 
      Wetherill, G.B. and Brown, D.W. (1991) _Statistical Process
     Control_. New York: Chapman & Hall.

_S_e_e _A_l_s_o:

     'shewhart.rules', 'cusum', 'ewma', 'process.capability',
     'qcc.groups'

_E_x_a_m_p_l_e_s:

     data(pistonrings)
     attach(pistonrings)
     diameter <- qcc.groups(diameter, sample)

     qcc(diameter[1:25,], type="xbar")
     qcc(diameter[1:25,], type="xbar", newdata=diameter[26:40,])
     q <- qcc(diameter[1:25,], type="xbar", newdata=diameter[26:40,], plot=FALSE)
     plot(q, chart.all=FALSE)
     qcc(diameter[1:25,], type="xbar", newdata=diameter[26:40,], nsigmas=2)
     qcc(diameter[1:25,], type="xbar", newdata=diameter[26:40,], confidence.level=0.99)

     qcc(diameter[1:25,], type="R")
     qcc(diameter[1:25,], type="R", newdata=diameter[26:40,])

     qcc(diameter[1:25,], type="S")
     qcc(diameter[1:25,], type="S", newdata=diameter[26:40,])

     # variable control limits

     out <- c(9, 10, 30, 35, 45, 64, 65, 74, 75, 85, 99, 100)
     diameter <- qcc.groups(pistonrings$diameter[-out], sample[-out])

     qcc(diameter[1:25,], type="xbar")
     qcc(diameter[1:25,], type="R")
     qcc(diameter[1:25,], type="S")
     qcc(diameter[1:25,], type="xbar", newdata=diameter[26:40,])
     qcc(diameter[1:25,], type="R", newdata=diameter[26:40,])
     qcc(diameter[1:25,], type="S", newdata=diameter[26:40,])

     detach(pistonrings)

     ##
     ##  Attribute data 
     ##

     data(orangejuice)
     attach(orangejuice)
     qcc(D[trial], sizes=size[trial], type="p")

     # remove out-of-control points (see help(orangejuice) for the reasons)
     inc <- setdiff(which(trial), c(15,23))
     q1 <- qcc(D[inc], sizes=size[inc], type="p")
     qcc(D[inc], sizes=size[inc], type="p", newdata=D[!trial], newsizes=size[!trial]) 
     detach(orangejuice)

     data(orangejuice2)
     attach(orangejuice2)
     names(D) <- sample
     qcc(D[trial], sizes=size[trial], type="p")
     q2 <- qcc(D[trial], sizes=size[trial], type="p", newdata=D[!trial], newsizes=size[!trial])
     detach(orangejuice2)

     # put on the same graph the two orange juice samples
     oldpar <- par(no.readonly = TRUE)
     par(mfrow=c(1,2), mar=c(5,5,3,0))
     plot(q1, title="First samples", ylim=c(0,0.5), add.stats=FALSE, restore.par=FALSE)
     par("mar"=c(5,0,3,3), yaxt="n")
     plot(q2, title="Second sample", add.stats=FALSE, ylim=c(0,0.5))
     par(oldpar)

     data(circuit)
     attach(circuit)
     qcc(x[trial], sizes=size[trial], type="c")
     # remove out-of-control points (see help(circuit) for the reasons)
     inc <- setdiff(which(trial), c(6,20))
     qcc(x[inc], sizes=size[inc], type="c", labels=inc)
     qcc(x[inc], sizes=size[inc], type="c", labels=inc, 
         newdata=x[!trial], newsizes=size[!trial], newlabels=which(!trial))
     qcc(x[inc], sizes=size[inc], type="u", labels=inc, 
         newdata=x[!trial], newsizes=size[!trial], newlabels=which(!trial))
     detach(circuit)

     data(pcmanufact)
     attach(pcmanufact)
     qcc(x, sizes=size, type="u")
     detach(pcmanufact)

     data(dyedcloth)
     attach(dyedcloth)
     qcc(x, sizes=size, type="u")
     # standardized control chart
     q <- qcc(x, sizes=size, type="u", plot=FALSE)
     z <- (q$statistics - q$center)/sqrt(q$center/q$size)
     plot(z,  type="o", ylim=range(z,3,-3), pch=16)
     abline(h=0, lty=2)
     abline(h=c(-3,3), lty=2)
     detach(dyedcloth)

     # viscosity data (Montgomery, pag. 242)
     x <- c(33.75, 33.05, 34, 33.81, 33.46, 34.02, 33.68, 33.27, 33.49, 33.20,
            33.62, 33.00, 33.54, 33.12, 33.84)
     qcc(x, type="xbar.one")

