Find change points efficiently in ARIMA(\(p\), \(d\), \(q\)) models
Source:R/fastcpd_wrappers.R
fastcpd_arima.Rd
fastcpd_arima()
and fastcpd.arima()
are
wrapper functions of fastcpd()
to find change points in
ARIMA(\(p\), \(d\), \(q\)) models.
The function is similar to fastcpd()
except that the data is by default a one-column matrix or univariate vector
and thus a formula is not required here.
Arguments
- data
A numeric vector, a matrix, a data frame or a time series object.
- order
A vector of length three specifying the order of the ARIMA model.
- ...
Other arguments passed to
fastcpd()
, for example,segment_count
. One special argument can be passed here isinclude.mean
, which is a logical value indicating whether the mean should be included in the model. The default value isTRUE
.
Value
A fastcpd object.
Examples
# \donttest{
set.seed(1)
n <- 271
w <- rnorm(n + 1, 0, 3)
dx <- rep(0, n + 1)
x <- rep(0, n + 1)
for (i in 1:180) {
dx[i + 1] <- 0.8 * dx[i] + w[i + 1] - 0.5 * w[i]
x[i + 1] <- x[i] + dx[i + 1]
}
for (i in 181:n) {
dx[i + 1] <- -0.6 * dx[i] + w[i + 1] + 0.3 * w[i]
x[i + 1] <- x[i] + dx[i + 1]
}
result <- fastcpd.arima(
diff(x[1 + seq_len(n)]),
c(1, 0, 1),
segment_count = 3,
include.mean = FALSE
)
summary(result)
#>
#> Call:
#> fastcpd.arima(data = diff(x[1 + seq_len(n)]), order = c(1, 0,
#> 1), segment_count = 3, include.mean = FALSE)
#>
#> Change points:
#> 178
#>
#> Cost values:
#> 435.4238 227.0583
plot(result)
# }