diurnalAdj: Dirunal adjustment for durations

View source: R/diurnalAdj.R

diurnalAdjR Documentation

Dirunal adjustment for durations

Description

Performs a diurnal adjustment of the durations, i.e. removes a daily seasonal component. Four different methods of diurnal adjustment are available, namely "cubicSpline", "supsmu" (Friedman's SuperSmoother), "smoothSpline" (smoothed version of the cubic spline), or "FFF" (Flexible Fourier Form).

Usage

diurnalAdj(dur, method = "cubicSpline", nodes = c(seq(600, 1105, 60), 1105),
aggregation = "all", span = "cv", spar = 0, Q = 4, returnSplineFnc = FALSE)

Arguments

dur

a data.frame containing the columns durations, containing durations, and time, containing the time stamps.

method

the method used. One of "cubicSpline", "supsmu", "smoothSpline", or "FFF".

nodes

only for method = "cubicSpline" or method = "smoothSpline". A vector of nodes to use for the spline function, in the unit minutes after midnight. The first and last element of the vector must be the start and end of the trading day. The nodes given are actually the limits of intervalls, of wich the midpoints will be set as the nodes using the means of the intervals.

aggregation

what type of aggregation to use. Either "weekdays", "all", or "none". If for example "weekdays" is chosen, all Mondays will have the same daily seasonal component, and so on.

span

argument passed to supsmu if method = "supsmu" were chosen. Affects the smoothness of the curve, see supsmu.

spar

argument passed to smooth.spline if method = "smooth.spline" were chosen. Affects the smoothness of the curve, see smooth.spline.

Q

number of trigonometric function pairs for method = "FFF".

returnSplineFnc

if TRUE instead or returning the adjusted durations a list of spline objects will be returned, containing the coefficents of the spline function. Only available for method = "cubicSpline".

Value

If returnSplineFnc is FALSE (default): the input data.frame dur with an added column of the diurnally adjusted durations called 'adjDur'.

Otherwise, a list of spline objects containing the coefficents of the spline function.

Author(s)

Markus Belfrage

Examples

diurnalAdj(durData, aggregation = "none", method = "supsmu")

## Not run: 

head(durData)
f <- diurnalAdj(durData, aggregation = "weekdays", method = "FFF", Q = 3)
head(f)

f <- diurnalAdj(durData, aggregation = "all", returnSplineFnc = TRUE)
f

## End(Not run)

ACDm documentation built on May 29, 2024, 12:04 p.m.