turns | R Documentation |

Extracts and analyzes turning points of an univariate
`"timeSeries"`

object.

```
turns(x, ...)
turnsStats(x, doplot = TRUE)
```

`x` |
an univariate |

`...` |
optional arguments passed to the function |

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

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`

.

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

Frederic Ibanez and Philippe Grosjean for code from the contributed R
package `pastecs`

and Rmetrics for the function wrapper.

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.

```
## 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)
```

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.