suppressPackageStartupMessages(library(dplyr))
suppressPackageStartupMessages(library(ggplot2))
df_tbl <- ts_to_tbl(AirPassengers) %>% select(-index)
tst <- ts_time_event_analysis_tbl(df_tbl, date_col, value, .direction = "both",
.horizon = 6)
glimpse(tst)
tst %>%
ggplot(aes(x = x, y = mean_event_change)) +
geom_line() +
geom_line(aes(y = event_change_ci_high), color = "blue", linetype = "dashed") +
geom_line(aes(y = event_change_ci_low), color = "blue", linetype = "dashed") +
geom_vline(xintercept = 7, color = "red", linetype = "dashed") +
theme_minimal() +
labs(
title = "'AirPassengers' Event Analysis at 5% Increase",
subtitle = "Vertical Red line is normalized event epoch - Direction: Both",
x = "",
y = "Mean Event Change"
)
Run the code above in your browser using DataLab