fastcpd_variance()
and fastcpd.variance()
are wrapper
functions of fastcpd()
to find the variance change. The
function is similar to fastcpd()
except that the data is by
default a matrix or data frame or a vector with each row / element as an
observation and thus a formula is not required here.
Arguments
- data
A matrix, a data frame or a vector.
- ...
Other arguments passed to
fastcpd()
, for example,segment_count
.
Value
A fastcpd object.
Examples
set.seed(1)
data <- c(rnorm(300, 0, 1), rnorm(400, 0, 10), rnorm(300, 0, 1))
system.time(result <- fastcpd.variance(data))
#> Warning: argument is not a function
#> user system elapsed
#> 0.003 0.000 0.003
summary(result)
#>
#> Call:
#> fastcpd.variance(data = data)
#>
#> Change points:
#> 300 700
#>
#> Cost values:
#> 1.341031 945.1872 30.94909
#>
#> Parameters:
#> segment 1 segment 2 segment 3
#> 1 0.9287098 111.3079 1.159284
plot(result)
if (requireNamespace("mvtnorm", quietly = TRUE)) {
set.seed(1)
p <- 3
data <- rbind(
mvtnorm::rmvnorm(
3e+5, rep(0, p), crossprod(matrix(runif(p^2) * 2 - 1, p))
),
mvtnorm::rmvnorm(
4e+5, rep(0, p), crossprod(matrix(runif(p^2) * 2 - 1, p))
),
mvtnorm::rmvnorm(
3e+5, rep(0, p), crossprod(matrix(runif(p^2) * 2 - 1, p))
)
)
result_time <- system.time(
result <- fastcpd.variance(data, r.progress = FALSE, cp_only = TRUE)
)
print(result_time)
summary(result)
}
#> Warning: argument is not a function
#> user system elapsed
#> 0.702 0.102 0.803
#>
#> Call:
#> fastcpd.variance(data = data, r.progress = FALSE, cp_only = TRUE)
#>
#> Change points:
#> 300002 700003