# \donttest{
set.seed(1)
n <- 200
w <- rnorm(n + 3, 0, 3)
x <- rep(0, n + 3)
for (i in 1:150) {
x[i + 3] <- 0.1 * x[i + 2] - 0.3 * x[i + 1] + 0.1 * x[i] +
0.1 * w[i + 2] + 0.5 * w[i + 1] + w[i + 3]
}
for (i in 151:n) {
x[i + 3] <- 0.3 * x[i + 2] + 0.1 * x[i + 1] - 0.3 * x[i] -
0.6 * w[i + 2] - 0.1 * w[i + 1] + w[i + 3]
}
result <- suppressWarnings(
fastcpd.arma(
data = x[3 + seq_len(n)],
order = c(3, 2),
segment_count = 3,
lower = c(rep(-1, 3 + 2), 1e-10),
upper = c(rep(1, 3 + 2), Inf),
line_search = c(1, 0.1, 1e-2),
beta = "BIC",
cost_adjustment = "BIC",
trim = 0.025
)
)
summary(result)
plot(result)
# }
Run the code above in your browser using DataLab