find_cp_pettitt: Identify changepoint using pettitt method, and find expected...

Description Usage Arguments Value Examples

View source: R/cp_functions.R

Description

Identify changepoint using pettitt method, and find expected SSD visits/calculate misses by fitting a linear model before the changepoint

Usage

1
2
3
4
5
6
7
8
find_cp_pettitt(
  data,
  var_name = "n_miss_visits",
  return_miss_only = FALSE,
  week_period = FALSE,
  specify_cp = NULL,
  auto_reg = FALSE
)

Arguments

data

A dataframe output by count_prior_events_truven

var_name

A character string of outcome for which to apply analysis

return_miss_only

Logical to only return miss information

week_period

Logical to incorporate a "day of the week" effect into the linear model. 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. If week_period is FALSE, will use a 7-day seasonality component. If week_period is TRUE, will use an additive indicator

Value

A list containing miss information, changepoint information, predictions, the model itself, and a plot of the middle finger curve and model.

Examples

1
2
3
4
cp_result_pettit <- final_time_map %>%
filter(days_since_dx >= -180) %>%
count_prior_events_truven(event_name = "any_ssd", start_day = 1, by_days = 1) %>%
find_cp_pettitt(var_name = "n_miss_visits", return_miss_only = FALSE, week_period=TRUE)

aarmiller/delayDX documentation built on July 11, 2021, 4:01 p.m.