fastcpd_ma()
and fastcpd.ma()
are
wrapper functions of fastcpd()
to find change points in
MA(\(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 positive integer or a vector of length three with the first two elements being zeros specifying the order of the MA 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 <- 400
w <- rnorm(n + 4, 0, 0.1)
x <- rep(NA, n)
for (i in 1:200) {
x[i] <- w[i + 4] - 5 / 3 * w[i + 3] + 11 / 12 * w[i + 2] - 5 / 12 * w[i + 1] +
1 / 6 * w[i]
}
for (i in 201:n) {
x[i] <- w[i + 4] - 4 / 3 * w[i + 3] + 7 / 9 * w[i + 2] - 16 / 27 * w[i + 1] +
4 / 27 * w[i]
}
result <- suppressMessages(
fastcpd.ma(x, 4, include.mean = FALSE, trim = 0)
)
summary(result)
#>
#> Call:
#> fastcpd.ma(data = x, order = 4, include.mean = FALSE, trim = 0)
#>
#> Change points:
#> 200
#>
#> Cost values:
#> -185.4279 -174.3401
plot(result)
# }