This function marks a drift in the input vector.

  reference = list(),
  apriori = Apriori("air pressure", units = "cmH2O"),
  plot = FALSE,
  verbose = FALSE,
  title = NULL,
  alpha = 0.01

# S4 method for numeric
detect_drift(x, timestamps, reference, apriori, plot, verbose, title, alpha)



numeric vector of values


timestamp vector


a list of list(x, timestamps) pairs that are to be used as reference for drift detection. The more data is supplied here, the better the results.


Apriori class. Defaults to air pressure in cmH2O.


optional parameters, depending on signature:


prints diagnostic plots. Consult the dedicated section below for more information.


adds extra information as attributes to the result.


adds title to the plot


significance level at which to detect drift. Defaults to 0.01.


Logical vector with same length as x, specifying TRUE for drifting observations.


Diagnostic plots

Top plot shows the time differences (hours) between measurements. 12 hours is signified by the red horizontal line. Note that the y-scale is logarithmic.

The middle left plot is the original series (black) overlaying the reference (darkred). In case more than one reference is supplied, only their median is shown.

The bottom left plot is the difference between the original and the reference series (or their median in case more than 1 reference is supplied) and is best suited for drift detection. The vertical dotted line signifies the most likely drift start date. Subsequently, three colors are used based on the significance: red (p < 0.001), orange and green (p > 0.01).

The right 4 smaller plots are DFTF and Year plots for the original series x (top) and differences (bottom). They are mainly used for the visualization of the seasonality patterns. The DFTF plot is in days while the yearly plot is in months. Note that the DTFT and Year plots have the drift effect subtracted. In the Year plots this results to a more pronounced seasonal pattern, and in the DTFT plot this results in lower amplitude of low frequencies (high periods).


  • detect_drift,numeric-method: