detect_changepoint: Detect change in temporal trend

Description Usage Arguments Author(s) See Also

View source: R/detect-changepoint.R

Description

This function looks for the 'optimal' number of recent days to exclude from the temporal trend fitting in asmodee. The procedure selects the value of k which maximises the sum if i) the number of non-outliers in training set (before the last k points) ii) the number of outliers in the last k points. Note that for each value of k investigated, model selection is performed as described in ?asmodee.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
detect_changepoint(
  data,
  models,
  date_index,
  alpha = 0.05,
  max_k = 7,
  method = trendeval::evaluate_resampling,
  include_warnings = FALSE,
  ...
)

Arguments

data

A data.frame or a tibble containing the response and explanatory variables used in the models.

models

A list of trending_model() objects, generated by lm_model, glm_model, glm_nb_model, brms_model and similar functions (see ?trending::trending_model()) for details.

date_index

The name of a variable corresponding to time, quoted or not.

alpha

The alpha threshold to be used for the prediction interval calculation; defaults to 0.05, i.e. 95% prediction intervals are calculated.

max_k

An integer indicating the maximum number of recent data points to be excluded from the trend fitting procedure. By default, ASMODEE will look for a changepoint within this recent time period, after which data no longer fit the previous trend. Larger values will require more computation from the method. Only used if fixed_k is NULL.

method

A function used to evaluate model fit. Current choices are evaluate_aic (default) and evaluate_resampling. evaluate_aic uses Akaike's Information Criterion instead, which is faster but possibly less good a selecting models with the best predictive power. evaluate_resampling uses cross-validation and, by default, RMSE to assess model fit.

include_warnings

Include results in output that triggered warnings but not errors. Defaults to FALSE.

...

Further arguments passed to method.

Author(s)

Thibaut Jombart

See Also

asmodee


reconhub/epichange documentation built on April 8, 2021, 3:45 a.m.