Learn R Programming

ham (version 1.2.0)

control: Statistics for Shewhart control charts

Description

Calculate statistics that can be used to produce X-bar charts, p-charts, and u-charts. This includes producing means for center lines, 3-sigma upper and lower control limits. Users can also calculate values before and after an intervention to see if a change in the control process happened. Values are returned in a data frame.

Usage

control(
  x,
  y = NULL,
  time,
  data,
  type = "x",
  subset = NULL,
  n.equal = TRUE,
  intervention = NULL
)

Value

data frame of control chart statistics for X-bar charts, p-charts, and u-charts. Includes means, standard deviations, and 3-sigma upper and lower control limit values.

Arguments

x

character outcome variable in X bar charts or numerator variable name for u-charts or p-charts (when p-chart data is aggregated).

y

character variable name for u-charts or p-charts (when p-chart data is aggregated). When y is present, it becomes the denominator for a rate calculated as x/y. Default is NULL.

time

time variable name.

data

name of data frame object.

type

indicate what type of control chart is needed. Options for the X-bar, p-, and u-charts should be listed as 'x', 'p', and 'u'. Default is the 'x' chart.

subset

an expression defining a subset of the observations to use in the grouping. The default is NULL, thereby using all observations. Specify, for example, data$hospital == "NY" or c(1:100,200:300) respectively to use just those observations.

n.equal

whether there are or we assume equal subgroup (sample) sizes. If n.equal=TRUE, control limits are calculated using the overall mean n value. If n.equal=FALSE, control limits are based on each subgroup's sample size. Default is TRUE.

intervention

a single numeric value for the time when an intervention begins (e.g., intervention=25; intervention begins on the 25th day). Separate means and control limits are calculated pre- and post-intervention. Default is NULL.

References

Ryan, T. (2011). Statistical Methods for Quality Improvement, Third Edition. New Jersey: John Wiley & Sons, Inc. ISBN: 978-0-470-59074-4.

Examples

Run this code
## Hospital LOS and readmissions ##
# X-bar chart statistics
spc_x <- control(x="los", time="month", data=hosprog, type="x", n.equal=TRUE)
print(spc_x) # get data frame output

# X-bar chart statistics not assuming equal sample sizes, subsetting for females
spc_x <- control(x="los", time="month", data=hosprog, type="x", n.equal=FALSE,
  subset=hosprog$female==1)
print(spc_x) # get data frame output

# p-chart statistics, using only the numerator (i.e., y=NULL). Specify unequal sample sizes
spc_p <- control(x="rdm30", time="month", data=hosprog, type="p", n.equal=FALSE)
print(spc_p) # get data frame output

# u-chart for infection rates with an intervention at the 22nd month
spc_u <- control(x="HAI", y="PatientDays", time="Month", data=infections,
type="u", n.equal=FALSE, intervention=22)
print(spc_u) # get data frame output

Run the code above in your browser using DataLab