\donttest{
if (!requireNamespace("ggplot2", quietly = TRUE)) utils::install.packages(
  "ggplot2", repos = "https://cloud.r-project.org", quiet = TRUE
)

set.seed(1)
n <- 600
x <- rep(0, n + 1)
for (i in 1:300) {
  x[i + 1] <- 0.8 * x[i] + rnorm(1, 0, 2)
}
for (i in 301:n) {
  x[i + 1] <- 0.1 * x[i] + rnorm(1, 0, 2)
}
result <- fastcpd.ts(
  x[1 + seq_len(n)],
  "arima",
  c(1, 0, 0),
  include.mean = FALSE,
  trim = 0,
  beta = (1 + 1 + 1) * log(n) / 2 * 3
)
summary(result)
plot(result)
}
