The function irts is used to create irregular time-series objects.

as.irts coerces an object to an irregularly spaced time-series. is.irts tests whether an object is an irregularly spaced time series.

irts(time, value)
as.irts(object)
is.irts(object)

Arguments

time

a numeric vector or a vector of class "POSIXct" representing the time-stamps of the irregular time-series object. The elements of the numeric vector are construed as the (signed) number of seconds since the beginning of 1970, see POSIXct.

value

a numeric vector or matrix representing the values of the irregular time-series object.

object

an R object to be coerced to an irregular time-series object or an R object to be tested whether it is an irregular time-series object.

Details

The function irts is used to create irregular time-series objects. These are scalar or vector valued time series indexed by a time-stamp of class "POSIXct". Unlike objects of class "ts", they can be used to represent irregularly spaced time-series.

Value

A list of class "irts" with the following elements:

time

a vector of class "POSIXct".

value

a numeric vector or matrix.

Author

A. Trapletti

Examples

n <- 10
t <- cumsum(rexp(n, rate = 0.1))
v <- rnorm(n)
x <- irts(t, v)
x
#> 1970-01-01 00:00:11 GMT -1.406
#> 1970-01-01 00:00:15 GMT -0.2153
#> 1970-01-01 00:00:46 GMT -0.5027
#> 1970-01-01 00:00:58 GMT 1.684
#> 1970-01-01 00:00:59 GMT -1.725
#> 1970-01-01 00:01:02 GMT -0.2526
#> 1970-01-01 00:01:05 GMT -1.605
#> 1970-01-01 00:01:05 GMT 1.153
#> 1970-01-01 00:01:06 GMT -1.266
#> 1970-01-01 00:01:18 GMT -0.2501

as.irts(cbind(t, v))
#> 1970-01-01 00:00:11 GMT -1.406
#> 1970-01-01 00:00:15 GMT -0.2153
#> 1970-01-01 00:00:46 GMT -0.5027
#> 1970-01-01 00:00:58 GMT 1.684
#> 1970-01-01 00:00:59 GMT -1.725
#> 1970-01-01 00:01:02 GMT -0.2526
#> 1970-01-01 00:01:05 GMT -1.605
#> 1970-01-01 00:01:05 GMT 1.153
#> 1970-01-01 00:01:06 GMT -1.266
#> 1970-01-01 00:01:18 GMT -0.2501

is.irts(x)
#> [1] TRUE

# Multivariate
u <- rnorm(n)
irts(t, cbind(u, v))
#> 1970-01-01 00:00:11 GMT -0.539 -1.406
#> 1970-01-01 00:00:15 GMT -0.6112 -0.2153
#> 1970-01-01 00:00:46 GMT 0.8078 -0.5027
#> 1970-01-01 00:00:58 GMT 1.358 1.684
#> 1970-01-01 00:00:59 GMT 1.001 -1.725
#> 1970-01-01 00:01:02 GMT -1.259 -0.2526
#> 1970-01-01 00:01:05 GMT -1.395 -1.605
#> 1970-01-01 00:01:05 GMT 0.3268 1.153
#> 1970-01-01 00:01:06 GMT -0.5663 -1.266
#> 1970-01-01 00:01:18 GMT -0.04009 -0.2501