rats: ~rats: Rational Time Series

View source: R/classes_rats.R

ratsR Documentation

~rats: Rational Time Series

Description

rats is the creator for a nimble S3 class of regular time series. rats are similar to ts or zooreg classes, but these classes have quirks related to quarterly periods and other econometric analytic traditions, while rats is more oriented toward engineering and computer science applications and implements the logics of these disciplines.

Features:

  • fractional frequency or period is perfectly supported

  • time intervals are defined as half-open intervals [A, B)

  • robust and non-destructive subsetting/extraction of series using the time coordinates with functions such as window.rats, 'window<-.rats', at

  • robust and non-destructive manipulation, expansion, and combination of series with functions such as c.rats and 'window<-.rats'

  • practical tools to explore('print.rats', 'str.rats') and plot ('plot.rats') rats

Usage

rats(
  data,
  start = 0,
  end,
  duration,
  frequency = 1,
  period,
  windowed = list(size = NULL, increment = NULL, flex = NULL, table = NULL),
  timeUnit = "cycle",
  unit = NULL
)

Arguments

data

vector. A vector of any type representing the data of the series

start

numeric. The beginning of the series in time, in cycle units.

end

numeric. The end of the series in time, in cycle units.

duration

numeric. Duration of the series in cycle units.

frequency

numeric. Either frequency of period must be present to specify the sampling rate of the signal. Frequency is espressed in number of observations per cycle. While period is the duration of each observation in fractions of cycle units. The period is equal to 1/frequency.

period

numeric.

windowed

list of three elements winSec, incSec, flex, describing eventual windowing procedures used to create the series.

timeUnit

character. A descriptor of the frequency cycle unit. Used only in print functions.

unit

character. A descriptor of the unit of measurement of the series values. Used only in print functions.

Details

In the ~rats class, time intervals are defined as half-open intervals with start and end and window methods including the start value but not the end value This is also referred to as [A, B) or "inclusive start, exclusive end". See: Dijkstra, E.W. (1982). Why numbering should start at zero

Thus, given a series starting at 0, with 5000 samples of information at 1000 samples/second you only have samples for time 0, 1, 2, ... until 4999 so this would be represented as 00:00 - 00:04 time(1) == 0 == 00:00 time(N) == 4999 == 00:04-1*period

In another example, rats(start=0, end=10, f=1) and rats(start=10, end=20, f=1) do not overlap.

The class works by storing the y values as a vector, and the x, or "time" values as an attribute, together with other relevant metadata

Value

a rats time series, which is a vector of any type with

Examples




this old strategy to generate x values was prone to bugs
whith this strategy you should have the guarantee o having exactly 1 x value
for each y one, no floating point errors, and other seq() quirks.
The first value is always going to be == start, and the following ones are
increments of 1 period.
This approach is also 10x times faster!

kleinbub/rIP documentation built on Dec. 21, 2024, 9:15 a.m.