find_epoch: Find the epochs/periodicities in a 'tsibble'

View source: R/find_epoch.R

find_epochR Documentation

Find the epochs/periodicities in a tsibble

Description

[Experimental]

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

Usage

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).

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.

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.

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)

gipsousp/actverse documentation built on Oct. 6, 2023, 12:21 a.m.