Package 'RcppUTS'

Title: Rcpp Bindings for Algorithms for Unevenly Spaced Time Series
Description: Algorithms and operators for unevenly-spaced time series are provided based on the 'UTS' library by Andreas Eckner.
Authors: Dirk Eddelbuettel
Maintainer: Dirk Eddelbuettel <[email protected]>
License: GPL (>= 2)
Version: 0.0.1
Built: 2024-11-04 04:03:28 UTC
Source: https://github.com/eddelbuettel/rcpputs

Help Index


Rcpp Bindings for Algorithms for Unevenly Spaced Time Series

Description

Algorithms and operators for unevenly-spaced time series are provided based on the 'UTS' library by Andreas Eckner.

Details

The DESCRIPTION file:

Package: RcppUTS
Type: Package
Title: Rcpp Bindings for Algorithms for Unevenly Spaced Time Series
Version: 0.0.1
Date: 2018-06-04
Author: Dirk Eddelbuettel
Maintainer: Dirk Eddelbuettel <[email protected]>
Description: Algorithms and operators for unevenly-spaced time series are provided based on the 'UTS' library by Andreas Eckner.
License: GPL (>= 2)
Imports: Rcpp (>= 0.12.17)
LinkingTo: Rcpp
Suggests: xts
RoxygenNote: 6.0.1
Repository: https://eddelbuettel.r-universe.dev
RemoteUrl: https://github.com/eddelbuettel/rcpputs
RemoteRef: HEAD
RemoteSha: 82485ad74f00b635ac10c6486d7d0e574b0d393a

Index of help topics:

EMAnext                 EMA functions for unevenly spaced time series
RcppUTS-package         Rcpp Bindings for Algorithms for Unevenly
                        Spaced Time Series
SMAnext                 SMA functions for unevenly spaced time series
rollingCentralMoment    Rolling operations functions for irregularly
                        spaced time series
utsExample              Irregularly spaced time series example

This section should provide a more detailed overview of how to use the package, including the most important functions.

Author(s)

Dirk Eddelbuettel

Maintainer: Dirk Eddelbuettel <[email protected]>

References

This optional section can contain literature or other references for background information.

See Also

Optional links to other man pages

Examples

## Optional simple examples of the most important functions
  ## Use \dontrun{} around code to be shown but not executed

EMA functions for unevenly spaced time series

Description

The UTS library by Andreas Eckner provides algorithms for unevenly spaced time-series data. This package brings a few of them to R. The functions describe here offer exponentially-decaying weighted moving average, or EMA, for short. Three variants are provides considering the last or next observation relative to time ‘t’, as well as linear interpolation between them.

Usage

EMAnext(times, values, tau)

EMAlast(times, values, tau)

EMAlinear(times, values, tau)

Arguments

times

A Datetime vector

values

A numeric vector

tau

A double with the decay factor

Value

A numeric vector with EMA-weighted values. package at the given position is available.

Author(s)

Dirk Eddelbuettel for the package, Andreas Eckner for the underlying code.

Examples

if (requireNamespace("xts", quietly=TRUE)) {
    suppressMessages(library(xts))
    times <- ISOdatetime(2010, 1, 2, 8, 30, 0) + c(0, 1.0, 1.2, 2.3, 2.9, 5.0)
    values <- seq(0, 10, by=2)
    plot(xts(values, order.by=times), type="b",
         main="Series and last/next/linear EMAs",
         major.ticks="auto", grid.ticks.on="auto")
    lines(xts(EMAlast(times,values, 1),  values, order.by=times),
          type="b", col="lightblue")
    lines(xts(EMAnext(times,values, 1),  values, order.by=times),
          type="b", col="darkblue")
    lines(xts(EMAlinear(times,values, 1),  values, order.by=times),
          type="b", col="mediumblue")
    addLegend("topleft", legend.names=c("series", "EMAlast", "EMAnext", "EMAlinear"),
              lty=rep(1,4), lwd=rep(1,4),
              col=c("black", "lightblue", "darkblue", "mediumblue"))
}

Rolling operations functions for irregularly spaced time series

Description

The UTS library by Andreas Eckner provides algorithms for unevenly spaced time-series data. This package brings a few of them to R. The functions describe here offer various rolling operators.

Usage

rollingCentralMoment(times, values, widthbefore, widthafter, moment)

rollingMax(times, values, widthbefore, widthafter)

rollingMean(times, values, widthbefore, widthafter)

rollingMedian(times, values, widthbefore, widthafter)

rollingMin(times, values, widthbefore, widthafter)

rollingNobs(times, values, widthbefore, widthafter)

rollingProduct(times, values, widthbefore, widthafter)

rollingSD(times, values, widthbefore, widthafter)

rollingSum(times, values, widthbefore, widthafter)

rollingSumStable(times, values, widthbefore, widthafter)

rollingVar(times, values, widthbefore, widthafter)

Arguments

times

A Datetime vector

values

A numeric vector

widthbefore

A double with the preceding observation width

widthafter

A double with the subsequent observation width

moment

A double with the requested moment.

Value

A numeric vector with the corresponding result.

Author(s)

Dirk Eddelbuettel for the package, Andreas Eckner for the underlying code.


SMA functions for unevenly spaced time series

Description

The UTS library by Andreas Eckner provides algorithms for unevenly spaced time-series data. This package brings a few of them to R. The functions describe here offer simple moving average, or SMA, for short. Three variants are provides considering the last or next observation relative to time ‘t’, as well as linear interpolation between them.

Usage

SMAnext(times, values, widthbefore, widthafter)

SMAlast(times, values, widthbefore, widthafter)

SMAlinear(times, values, widthbefore, widthafter)

Arguments

times

A Datetime vector

values

A numeric vector

widthbefore

A double with the preceding observation width

widthafter

gvA double with the subsequent observation width

Value

A numeric vector with SMA-weighted values. package at the given position is available.

Author(s)

Dirk Eddelbuettel for the package, Andreas Eckner for the underlying code.

Examples

if (requireNamespace("xts", quietly=TRUE)) {
    suppressMessages(library(xts))
    times <- ISOdatetime(2018, 6, 7, 8, 30, 0) + c(0, 1.0, 1.2, 2.3, 2.9, 5.0)
    values <- seq(0, 10, by=2)
    plot(xts(values, order.by=times), type="b",
         main="Series and last/next/linear SMAs",
         major.ticks="auto", grid.ticks.on="auto")
    lines(xts(SMAlast(times,values, 2.5, 1), values, order.by=times), 
         type="b", col="lightblue")
    lines(xts(SMAnext(times,values, 2.5, 1),  values, order.by=times),
         type="b", col="darkblue")
    lines(xts(SMAlinear(times,values, 2.5, 1),  values, order.by=times),
         type="b", col="mediumblue")
    addLegend("topleft", legend.names=c("series", "SMAlast", "SMAnext", "SMAlinear"),
              lty=rep(1,4), lwd=rep(1,4),
              col=c("black", "lightblue", "darkblue", "mediumblue"))
}

Irregularly spaced time series example

Description

The UTS library by Andreas Eckner provides algorithms for unevenly spaced time-series data. This package brings a few of them to R. This function shows the original example.

Usage

utsExample()

Value

Nothing

Author(s)

Dirk Eddelbuettel for the package, Andreas Eckner for the underlying code.

Examples

utsExample()