## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(collapse = TRUE, comment = "#>",
                      fig.width = 7, fig.height = 4.2)

## ----setup, message = FALSE---------------------------------------------------
library(shewhartr)
library(dplyr)

## -----------------------------------------------------------------------------
baseline <- bottle_fill[1:60, ]
new_obs  <- bottle_fill[61:100, ]

## -----------------------------------------------------------------------------
calib <- calibrate(
  baseline,
  value         = ml,
  index         = observation,
  chart         = "i_mr",
  trim_outliers = TRUE
)
calib

## -----------------------------------------------------------------------------
calib$phase
calib$n          # potentially less than nrow(baseline) if trimming dropped points
broom::tidy(calib)

## -----------------------------------------------------------------------------
alarms <- monitor(new_obs, calib)
alarms$phase
alarms$violations

## ----eval = FALSE-------------------------------------------------------------
# autoplot(alarms)

## -----------------------------------------------------------------------------
calib_no_trim <- calibrate(baseline, value = ml,
                           chart = "i_mr",
                           trim_outliers = FALSE)
calib_no_trim$sigma_hat
calib$sigma_hat       # potentially smaller after trimming

