find_change_point: Find the change point in count data. This is a...

View source: R/cp_functions.R

find_change_pointR Documentation

Find the change point in count data. This is a backwards-compatible wrapper function to find the changepoint, which calls other methods.

Description

Find the change point in count data. This is a backwards-compatible wrapper function to find the changepoint, which calls other methods.

Usage

find_change_point(
  data,
  var_name = "n_miss_visits",
  method,
  eval_criteria = "AIC",
  return_miss_only = FALSE,
  week_period = FALSE,
  specify_cp = NULL,
  auto_reg = FALSE
)

Arguments

data

A dataset of visit counts, output by prep_cp_data

var_name

The name of the count variable to find the change-point for

method

The method used to find changepoint. Options include "lm", "lm_quad", "lm_cube", "quad", "cube", "exp", "spline", "pettitt", "cusum", "MSE", "RMSE", "MAE", "MSLE", "RMSLE"

eval_criteria

The evaluation criteria used to find change points, if using a linear regression method

return_miss_only

Logical argument to only return the tibbles of miss visit counts

week_period

Logical to incorporate a "day of the week" effect into the linear mode. Note this is only sensible for one-day period aggregation

specify_cp

Set a specific change point you want to use instead of searching for optimal change point. Enter a postive integer value repersenting the days before the index on which you you want to specify the change point. (e.g. 100 would be 100 days before the index)

auto_reg

Logical that determines whether expected counts use a time-series framework that incorporates autoregression. Will automatically fit periodicity, automatically setting week_period to TRUE. Only relevant for cusum and pettitt methods

Value

A list containing tibbles of information about missed visits. These tibbles change depending on the method used, but all contain miss predictions and a plot

Examples


cp_result_original <- final_time_map %>%
prep_cp_data(event_name = "any_ssd", start_day = 1, by_days = 1) %>%
find_change_point(var_name="n_miss_visits", method="lm_cube")


aarmiller/delaySim documentation built on Jan. 2, 2023, 11:23 p.m.