periodicity {xts}R Documentation

Approximate Series Periodicity

Description

Estimate the periodicity of a time-series-like object by calculating the median time between observations in days.

Usage

periodicity(x, ...)

Arguments

x

A time-series-like object.

...

Unused.

Details

A simple wrapper to quickly estimate the periodicity of a given data. Returning an object of type periodicity.

This calculates the median time difference between observations as a difftime object, the numerical difference, the units of measurement, and the derived scale of the data as a string.

The time index currently must be of either a 'Date' or 'POSIXct' class, or or coercible to one of them.

The 'scale' component of the result is an estimate of the periodicity of the data in common terms - e.g. 7 day daily data is best described as 'weekly', and would be returned as such.

Value

A 'periodicity' object with the following elements:

Possible scale values are: ‘minute’, ‘hourly’, ‘daily’, ‘weekly’, ‘monthly’, ‘quarterly’, and ‘yearly’.

Note

This function only attempts to be a good estimate for the underlying periodicity. If the series is too short, or has highly irregular periodicity, the return values will not be accurate. That said, it is quite robust and used internally within xts.

Author(s)

Jeffrey A. Ryan

See Also

difftime()

Examples


zoo.ts <- zoo(rnorm(231),as.Date(13514:13744,origin="1970-01-01"))
periodicity(zoo.ts)


[Package xts version 0.14.0 Index]