detect_changepoint: Compute aggregate change point(s) on ts-level data

View source: R/detect_changepoint.R

detect_changepointR Documentation

Compute aggregate change point(s) on ts-level data

Description

Aggregate group-level counts to detect significant change point(s) in counts.

Usage

detect_changepoint(
  group_timeseries_data,
  group_id,
  num_cpts = 1,
  include_data = FALSE,
  include_model = FALSE
)

Arguments

group_timeseries_data

contains time-series data for each ts over the same period of time. Requires the following columns:

  • date: the date by which activity was recorded.

  • ts_id: a unique identifier for the ts.

  • count: number of units of activity for the corresponding date/ts.

group_id

unique identifier for the group

num_cpts

maximum number of change points to detect

include_data

whether to include data in response

include_model

whether to include change point model in response

Examples

num_dates <- 90
num_timeseries <- 30
test_data <- merge(paste0("ts_", 1:num_timeseries),
      seq(Sys.Date(), Sys.Date() + (num_dates - 1), by = 1),
      colnames = c("foo", "bar"))
start_date <- Sys.Date() + floor(num_dates / 2)
test_data$count <- sapply(1:(num_dates*num_timeseries),
                          function(x) { rnorm(1, 50, 20) })
test_data <- setNames(test_data, c("ts_id", "date", "count"))
detect_changepoint(
  test_data, "test_analysis", include_data = FALSE, include_model = FALSE)

roboton/chwork documentation built on June 21, 2022, 6:18 a.m.