find_cp_cusum | R Documentation |
Identify changepoint using CUSUM method, and find expected SSD visits/calculate misses by fitting a linear model before the changepoint
find_cp_cusum( data, var_name = "n_miss_visits", return_miss_only = FALSE, week_period = FALSE, specify_cp = NULL, auto_reg = FALSE )
data |
A dataframe output by prep_cp_data |
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 |
A list containing miss information, changepoint information, predictions, the model itself, and a plot of the middle finger curve and model.
cp_result_cusum <- final_time_map %>% filter(days_since_dx >= -180) %>% prep_cp_data(event_name = "any_ssd", start_day = 1, by_days = 1) %>% find_cp_cusum(var_name = "n_miss_visits", return_miss_only = FALSE, week_period=TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.