Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

tis

Time Indexed Series


Description

The function tis is used to create time-indexed series objects.

as.tis and is.tis coerce an object to a time-indexed series and test whether an object is a time-indexed series.

Usage

tis(data, start = 1, tif = NULL, frequency = NULL, end = NULL)
as.tis(x, ...)
## S3 method for class 'ts'
as.tis(x, ...)
## S3 method for class 'tis'
as.tis(x, ...)
## S3 method for class 'zoo'
as.tis(x, ...)
## Default S3 method:
as.tis(x, ...)
is.tis(x)

Arguments

data

a numeric vector or matrix of the observed time-series values.

start

the time of the first observation. This can be a ti object, or anything that ti(start, tif = tif, freq = frequency), can turn into a ti object.

...

other args to be passed to the method called by the generic function. as.tis.default passes x and ... to the constructor function tis.

tif

a ti Frequency, given as either a numerical code or a string. tif() with no arguments returns a list of the allowable numerical codes and names.

frequency

As an alternative to supplying a tif, some tifs can alternatively be specified by their frequency, such as 1 (annual), 2 (semiannual), 4 (quarterly), 6 (bimonthly), 12 (monthly), 24 (semimonthly), 26 (biweekly), 36 (tenday), 52 (weekly), 262 (business) and 365 (daily). Many frequencies have multiple tifs associated with them. For example, all of the tifs (wsunday, wmonday, ..., wsaturday) have frequency 52. In this case, specifying freq gets you the default weekly tif wmonday.

end

the time of the last observation, specified in the same way as start.

x

object to be tested (is.tis) or converted into a tis object. As described in the details below, as.tis can deal with several different kinds of x.

Details

The function tis is used to create tis objects, which are vectors or matrices with class of "tis" and a start attribute that is a ti (time index) object. Time-indexed series are a form of time series that is more flexible than the standard ts time series. While observations for a ts object are supposed to have been sampled at equispaced points in time, the observation times for a tis object are the times given by successive increments of the more flexible time index contained in the series start attribute. There is a close correspondence between Fame time series and tis objects, in that all of the Fame frequencies have corresponding tif codes.

tis objects operate much like vanilla R ts objects. Most of the methods implemented for ts objects have tis variants as well. Evaluate methods(class = "tis") to see a list of them.

One way or another, tis needs to figure out how to create a start attribute. If start is supplied, the function ti is called with it, tif and frequency as arguments. The same process is repeated for end if it was supplied. If only one of start and end was supplied, the other is inferred from it and the number of observations in data. If both start and end are supplied, the function rep is used to make data the length implied by end - start + 1.

as.tis is a generic function with specialized methods for other kinds of time series, including zoo series from zoo. The fallback default method calls tis(x, ...).

Value

tis and as.tis return time-indexed series. is.tis returns TRUE or FALSE.

Note

If the index of a zoo series is a ti, the coercion as.tis.zoo does is trivial. For other kinds of zoo series, the function inferTi tries to figure out a time index that matches the times of the index of the zoo series. This may fail, as there are infinitely more possible kinds of zoo indexes than the finite number of time index frequencies.

See Also

Compare with ts. See ti for details on time indexes. cbind.tis combines several time indexed series into a multivariate tis, while mergeSeries merges series, and convert and aggregate convert series from one frequency to another. start.tis and end.tis return ti objects, while ti.tis returns a vector ti. There is a print method print.tis and several plotting methods, including lines.tis and points.tis. The window.tis method is also sufficiently different from the ts one to deserve its own documentation.

Examples

tis(1:48, start = c(2000, 1), freq = 12)
tis(1:48, start = ti(20000101, tif = "monthly"))    ## same result
tis(0, start = c(2000,1), end = c(2000,52), tif = "weekly")

tis

Time Indexes and Time Indexed Series

v1.38
Unlimited
Authors
Jeff Hallman <jeffhallman@gmail.com>
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.