har_plot: Plot event detection on a time series

har_plotR Documentation

Plot event detection on a time series

Description

It accepts as harbinger, a time series, a data.frame of events, a parameter to mark the detected change points, a threshold for the y-axis and an index for the time series

Usage

har_plot(
  obj,
  serie,
  detection,
  event = NULL,
  mark.cp = TRUE,
  ylim = NULL,
  idx = NULL,
  pointsize = 0.5,
  colors = c("green", "blue", "red", "purple")
)

Arguments

obj

harbinger detector

serie

time series

detection

detection

event

events

mark.cp

show change points

ylim

limits for y-axis

idx

labels for x observations

pointsize

default point size

colors

default colors for event detection: green is TP, blue is FN, red is FP, purple means observations that are part of a sequence.

Value

A time series plot with marked events

Examples

library(daltoolbox)

#loading the example database
data(examples_anomalies)

#Using the simple time series
dataset <- examples_anomalies$simple
head(dataset)

# setting up time change point using GARCH
model <- hanr_arima()

# fitting the model
model <- fit(model, dataset$serie)

# making detections
detection <- detect(model, dataset$serie)

# filtering detected events
print(detection[(detection$event),])

# evaluating the detections
evaluation <- evaluate(har_eval_soft(), detection$event, dataset$event)
print(evaluation$confMatrix)

# ploting the results
grf <- har_plot(model, dataset$serie, detection, dataset$event)
plot(grf)

harbinger documentation built on June 22, 2024, 7:38 p.m.