geom_regime.Rd
A geom to fit a regime shifts to a time series
geom_regime(
data = NULL,
mapping = NULL,
stat = "REGIME",
geom = "vline",
position = "identity",
inherit.aes = TRUE,
na.rm = FALSE,
color = "red",
show.legend = NA
)
If regime shifts exists, then xintercept line(s) is returned. Otherwise output is NULL
.
library(ggplot2)
#Generate series
m <- 0.1
x <- 1:30
y <- m*x + rnorm(30, sd = 0.35)
data <- data.frame(x = x,
y = y)
#Plot series with trend
ggplot(data = data) +
geom_line(aes(x = x, y = y)) +
geom_regime()
#> Error in geom_regime(): Problem while computing stat.
#> ℹ Error occurred in the 2nd layer.
#> Caused by error in `compute_layer()`:
#> ! `stat_regime()` requires the following missing aesthetics: x and y.