Learn R Programming

fastcpd (version 0.16.0)

fastcpd_mean: Find change points efficiently in mean change models

Description

fastcpd_mean() and fastcpd.mean() are wrapper functions of fastcpd() to find the mean 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_mean(data, ...)

fastcpd.mean(data, ...)

Value

A fastcpd object.

Arguments

data

A matrix, a data frame or a vector.

...

Other arguments passed to fastcpd(), for example, segment_count.

See Also

fastcpd()

Examples

Run this code
if (requireNamespace("mvtnorm", quietly = TRUE)) {
  set.seed(1)
  p <- 3
  data <- rbind(
    mvtnorm::rmvnorm(3e+5, mean = rep(0, p), sigma = diag(100, p)),
    mvtnorm::rmvnorm(4e+5, mean = rep(50, p), sigma = diag(100, p)),
    mvtnorm::rmvnorm(3e+5, mean = rep(2, p), sigma = diag(100, p))
  )
  result_time <- system.time(
    result <- fastcpd.mean(data, r.progress = FALSE, cp_only = TRUE)
  )
  print(result_time)
  summary(result)
}

Run the code above in your browser using DataLab