[Experimental]

find_epoch() returns the different epochs/periodicities present in a tsibble object along with a best match epoch based on a predefined threshold.

find_epoch(data, threshold = 0.9)

Arguments

data

A tsibble object with a Date or POSIXt vector as index.

threshold

(optional) a number, from 0 to 1, indicating the minimum proportion that an epoch must have to be considered valid. threshold = 1 means that the regularity of the time series must be strict (i.e., have just 1 periodicity) (default: 0.9).

Value

A list object with the following elements:

  • best_match: A number indicating the epoch/periodicity above the threshold with greater prevalence in seconds. If none is find, best_match value will be equal as as.numeric(NA).

  • prevalence: a tibble listing the unique epochs/periodicities found in data along with its proportions.

Details

In the rare cases that a tsibble object have periodicities with the same prevalence above the threshold, best_match will return just one of those values.

See also

Other utility functions: aggregate_index(), raw_data(), read_acttrust(), write_acttrust()

Examples

data <- dplyr::tibble(
    index = c(
        as.POSIXct(seq(60, 5400, by = 60), origin = lubridate::origin),
        as.POSIXct(seq(5430, 5490, by = 30), origin = lubridate::origin),
        as.POSIXct(seq(5505, 5520, by = 15), origin = lubridate::origin),
        as.POSIXct(seq(5530, 5540, by = 10), origin = lubridate::origin),
        as.POSIXct(seq(5545, 5555, by = 5), origin = lubridate::origin)
        ),
    x = seq_along(timestamp)
    )
data <- tsibble::tsibble(data, index = index)

find_epoch(data, 0.8)
#> $best_match
#> [1] 60
#> 
#> $prevalence
#> # A tibble: 5 × 2
#>   epoch proportion
#>   <dbl>      <dbl>
#> 1    60     0.899 
#> 2    30     0.0303
#> 3     5     0.0303
#> 4    15     0.0202
#> 5    10     0.0202
#>