fin-turnpoints: Turning points of a time series

turnsR Documentation

Turning points of a time series

Description

Extracts and analyzes turning points of an univariate "timeSeries" object.

Usage

turns(x, ...)

turnsStats(x, doplot = TRUE)

Arguments

x

an univariate "timeSeries" object of financial indices or prices.

...

optional arguments passed to the function na.omit.

doplot

a logical flag, should the results be plotted? By default TRUE.

Details

The function turns determines the number and the positions of extrema (turning points, either peaks or pits) in a regular time series.

The function turnsStats calculates the quantity of information associated with the observations in this series, according to Kendall's information theory.

The functions are borrowed from the contributed R package pastecs and made ready for working together with univariate timeSeries objects. You need not to load the R package pastecs, the code parts we need here are builtin in the timeSeries package.

We have renamed the function turnpoints to turns to distinguish between the original function in the contributed R package pastecs and our Rmetrics function wrapper.

For further details please consult the help page from the contributed R package pastecs.

Value

for turns, an object of class timeSeries.

for turnsStats, an object of class turnpoints with the following entries:

data

The dataset to which the calculation is done.

n

The number of observations.

points

The value of the points in the series, after elimination of ex-aequos.

pos

The position of the points on the time scale in the series (including ex-aequos).

exaequos

Location of exaequos (1), or not (0).

nturns

Total number of turning points in the whole time series.

firstispeak

Is the first turning point a peak (TRUE), or not (FALSE).

peaks

Logical vector. Location of the peaks in the time series without ex-aequos.

pits

Logical vector. Location of the pits in the time series without ex-aequos.

tppos

Position of the turning points in the initial series (with ex-aequos).

proba

Probability to find a turning point at this location.

info

Quantity of information associated with this point.

Author(s)

Frederic Ibanez and Philippe Grosjean for code from the contributed R package pastecs and Rmetrics for the function wrapper.

References

Ibanez, F., 1982, Sur une nouvelle application de la theorie de l'information a la description des series chronologiques planctoniques. J. Exp. Mar. Biol. Ecol., 4, 619–632

Kendall, M.G., 1976, Time Series, 2nd ed. Charles Griffin and Co, London.

Examples

## Load Swiss Equities Series -  
   SPI.RET <- LPP2005REC[, "SPI"]
   head(SPI.RET)

## Cumulate and Smooth the Series -
   SPI <- smoothLowess(cumulated(SPI.RET), f=0.05)
   plot(SPI)
   
## Plot Turn Points Series - 
   SPI.SMOOTH <- SPI[, 2]
   tP <- turns(SPI.SMOOTH)
   plot(tP)
   
## Compute Statistics -
   turnsStats(SPI.SMOOTH)

timeSeries documentation built on Aug. 26, 2023, 5:08 p.m.