fastcpd_ts {fastcpd} | R Documentation |
Find change points efficiently in time series data
Description
fastcpd_ts()
and fastcpd.ts()
are wrapper functions for
fastcpd()
to find change points in time series data. The function is
similar to fastcpd()
except that the data is a time series and the
family is one of "ar"
, "var"
, "arma"
, "arima"
or
"garch"
.
Usage
fastcpd_ts(data, family = NULL, order = c(0, 0, 0), ...)
fastcpd.ts(data, family = NULL, order = c(0, 0, 0), ...)
Arguments
data |
A numeric vector, a matrix, a data frame or a time series object. |
family |
A character string specifying the family of the time series.
The value should be one of |
order |
A positive integer or a vector of length less than four
specifying the order of the time series. Possible combinations with
|
... |
Other arguments passed to |
Value
A fastcpd object.
See Also
Examples
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 <- fastcpd.ts(
x,
"arma",
c(0, 4),
lower = c(-2, -2, -2, -2, 1e-10),
upper = c(2, 2, 2, 2, Inf),
line_search = c(1, 0.1, 1e-2),
trim = 0.05
)
summary(result)
plot(result)