Skip to contents

fastcpd_meanvariance, fastcpd.meanvariance, fastcpd_mv, fastcpd.mv are wrapper functions of fastcpd to find the meanvariance 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.

Usage

fastcpd_meanvariance(data, ...)

fastcpd.meanvariance(data, ...)

fastcpd_mv(data, ...)

fastcpd.mv(data, ...)

Arguments

data

A matrix, a data frame or a vector.

...

Other arguments passed to fastcpd, for example, segment_count.

Value

A class fastcpd object.

Examples

if (!requireNamespace("mvtnorm", quietly = TRUE)) utils::install.packages(
  "mvtnorm", repos = "https://cloud.r-project.org", quiet = TRUE
)

set.seed(1)
p <- 3
result <- fastcpd.mv(
  rbind(
    mvtnorm::rmvnorm(300, mean = rep(0, p), sigma = diag(1, p)),
    mvtnorm::rmvnorm(400, mean = rep(10, p), sigma = diag(1, p)),
    mvtnorm::rmvnorm(300, mean = rep(0, p), sigma = diag(50, p)),
    mvtnorm::rmvnorm(300, mean = rep(0, p), sigma = diag(1, p)),
    mvtnorm::rmvnorm(400, mean = rep(10, p), sigma = diag(1, p)),
    mvtnorm::rmvnorm(300, mean = rep(10, p), sigma = diag(50, p))
  )
)
summary(result)
#> 
#> Call:
#> fastcpd.mv(data = rbind(mvtnorm::rmvnorm(300, mean = rep(0, p), 
#>     sigma = diag(1, p)), mvtnorm::rmvnorm(400, mean = rep(10, 
#>     p), sigma = diag(1, p)), mvtnorm::rmvnorm(300, mean = rep(0, 
#>     p), sigma = diag(50, p)), mvtnorm::rmvnorm(300, mean = rep(0, 
#>     p), sigma = diag(1, p)), mvtnorm::rmvnorm(400, mean = rep(10, 
#>     p), sigma = diag(1, p)), mvtnorm::rmvnorm(300, mean = rep(10, 
#>     p), sigma = diag(50, p))))
#> 
#> Change points:
#> 300 700 1000 1300 1700 
#> 
#> Cost values:
#> 864.7912 1160.724 2619.447 885.7798 1084.092 2572.414