## ----include = FALSE----------------------------------------------------------
has_data <- requireNamespace("shewhartr", quietly = TRUE)
knitr::opts_chunk$set(collapse = TRUE, comment = "#>", fig.width = 7, fig.height = 4.5,
                      eval = has_data)

## ----setup--------------------------------------------------------------------
library(edetect)

## ----data---------------------------------------------------------------------
oven <- shewhartr::temperature_drift
head(oven, 3)

## ----linear-------------------------------------------------------------------
linear <- edetect_regression(temp_c ~ minute, phase1 = oven[1:100, ], phase2 = oven[101:200, ],
                             arl = 370, direction = "both")
edetect_alarm(linear)

## ----periodic-----------------------------------------------------------------
periodic <- edetect_regression(
  temp_c ~ minute + sin(2 * pi * minute / 50) + cos(2 * pi * minute / 50),
  phase1 = oven[1:100, ], phase2 = oven[101:200, ], arl = 370, direction = "both")
edetect_alarm(periodic)
autoplot(periodic)

## ----periodic-report----------------------------------------------------------
edetect_report(periodic)

