Irregular Time Series

Irregular Time Series [R logo]

Help pages for package `its' version 1.1.5

*.its | Arithmetic Methods for Irregular Time-Series Objects
+.its | Arithmetic Methods for Irregular Time-Series Objects
-.its | Arithmetic Methods for Irregular Time-Series Objects
/.its | Arithmetic Methods for Irregular Time-Series Objects
accrueIts | Financial Functions for Irregular Time-Series Objects
alignedIts | Join Functions for Irregular Time-Series Objects
appendIts | Join Functions for Irregular Time-Series Objects
Arith,its,its-method | Arithmetic Methods for Irregular Time-Series Objects
Arith,its,numeric-method | Arithmetic Methods for Irregular Time-Series Objects
Arith,numeric,its-method | Arithmetic Methods for Irregular Time-Series Objects
Arith.its | Arithmetic Methods for Irregular Time-Series Objects
as.data.frame.its | Conversion for its objects
as.its | Irregularly Spaced Time-Series
as.list.its | Conversion for its objects
coerce,its,data.frame-method | Irregularly Spaced Time-Series
collapseIts | Join Functions for Irregular Time-Series Objects
core | Accessor, Assignment Functions for Irregular Time-Series Objects
core,its-method | Accessor, Assignment Functions for Irregular Time-Series Objects
core<-,its,matrix-method | Accessor, Assignment Functions for Irregular Time-Series Objects
cumsum | Cumulation, Differencing for Irregular Time-Series Objects
cumsum,its-method | Cumulation, Differencing for Irregular Time-Series Objects
dates | Accessor, Assignment Functions for Irregular Time-Series Objects
dates,its-method | Accessor, Assignment Functions for Irregular Time-Series Objects
dates<-,its,POSIXt-method | Accessor, Assignment Functions for Irregular Time-Series Objects
daysecondIts | Time Functions for Irregular Time-Series Objects
diff | Cumulation, Differencing for Irregular Time-Series Objects
diff,its-method | Cumulation, Differencing for Irregular Time-Series Objects
end | Summary Information for Irregular Time-Series Objects
end,its-method | Summary Information for Irregular Time-Series Objects
Extract | Extract or Replace Parts of an Object
extractIts | Range and Extract for Irregular Time-Series Objects
intersect | Join Functions for Irregular Time-Series Objects
intersect,its,its-method | Join Functions for Irregular Time-Series Objects
intersect,its,NULL-method | Join Functions for Irregular Time-Series Objects
intersect,NULL,its-method | Join Functions for Irregular Time-Series Objects
is.its | Irregularly Spaced Time-Series
its | Irregularly Spaced Time-Series
its-class | Irregularly Spaced Time-Series
its.format | Irregularly Spaced Time-Series
itsAccessor | Accessor, Assignment Functions for Irregular Time-Series Objects
itsArith | Arithmetic Methods for Irregular Time-Series Objects
itsConvert | Conversion for its objects
itsCumdif | Cumulation, Differencing for Irregular Time-Series Objects
itsDisp | Display Methods for Irregular Time-Series Objects
itsFile | File Operations for Irregular Time-Series Objects
itsFin | Financial Functions for Irregular Time-Series Objects
itsInfo | Summary Information for Irregular Time-Series Objects
itsInterp | Interpolation Functions for Irregular Time-Series Objects
itsJoin | Join Functions for Irregular Time-Series Objects
itsLags | Lag Functions for Irregular Time-Series Objects
itsSubset | Range and Extract for Irregular Time-Series Objects
itsTimes | Time Functions for Irregular Time-Series Objects
lagdistIts | Lag Functions for Irregular Time-Series Objects
lagIts | Lag Functions for Irregular Time-Series Objects
locf | Interpolation Functions for Irregular Time-Series Objects
names | Accessor, Assignment Functions for Irregular Time-Series Objects
names,its-method | Accessor, Assignment Functions for Irregular Time-Series Objects
names<-,its,character-method | Accessor, Assignment Functions for Irregular Time-Series Objects
newIts | Irregularly Spaced Time-Series
plot | Display Methods for Irregular Time-Series Objects
plot,its,missing-method | Display Methods for Irregular Time-Series Objects
priceIts | Download Historical Finance Data
print | Display Methods for Irregular Time-Series Objects
print,its-method | Display Methods for Irregular Time-Series Objects
rangeIts | Range and Extract for Irregular Time-Series Objects
readcsvIts | File Operations for Irregular Time-Series Objects
start | Summary Information for Irregular Time-Series Objects
start,its-method | Summary Information for Irregular Time-Series Objects
Subscript | Extract or Replace Parts of an Object
summary | Summary Information for Irregular Time-Series Objects
summary,its-method | Summary Information for Irregular Time-Series Objects
union | Join Functions for Irregular Time-Series Objects
union,its,its-method | Join Functions for Irregular Time-Series Objects
union,its,NULL-method | Join Functions for Irregular Time-Series Objects
union,NULL,its-method | Join Functions for Irregular Time-Series Objects
weekdayIts | Time Functions for Irregular Time-Series Objects
writecsvIts | File Operations for Irregular Time-Series Objects
x[i,j] | Range and Extract for Irregular Time-Series Objects
[ | Range and Extract for Irregular Time-Series Objects
[,its-method | Range and Extract for Irregular Time-Series Objects
[.POSIXct | Extract or Replace Parts of an Object
[<-,ANY,ANY,ANY,ANY-method | ~~ Methods for Function [<- in Package `its' ~~
[<-,its,ANY,ANY,its-method | ~~ Methods for Function [<- in Package `its' ~~
[<-,its,its-method | Range and Extract for Irregular Time-Series Objects
[<--methods | ~~ Methods for Function [<- in Package `its' ~~
^.its | Arithmetic Methods for Irregular Time-Series Objects


Extract or Replace Parts of an Object

Description

Operators acting on vectors, arrays and lists to extract or replace subsets.

Usage

x[i]
x[i, j, ... , drop = TRUE]

Arguments

x | vector of POSIXct dates.
i, j, ... | elements to extract or replace. i, j are numeric or character. Numeric values are coerced to integer as by as.integer. For [-indexing only: i, j, ... can be logical vectors, indicating elements/slices to select. Such vectors are recycled if necessary to match the corresponding extent. When indexing arrays, i can be a (single) matrix with as many columns as there are dimensions of x; the result is then a vector with elements corresponding to the sets of indices in each row of i. i, j, ... can also be negative integers, indicating elements/slices to leave out of the selection.
drop | For matrices, and arrays. If TRUE the result is coerced to the lowest possible dimension (see examples below). This only works for extracting elements, not for the replacement forms.

Details

These operators are generic. You can write methods to handle subsetting of specific classes of objects, see InternalMethods as well as [.data.frame and [.factor. The descriptions here apply only to the default methods.

The most important distinction between [, [[ and $ is that the [ can select more than one element whereas the other two select a single element. $ does not allow computed indices, whereas [[ does. x$name is equivalent to x[["name"]] if x is recursive (see is.recursive) and NULL otherwise.

The [[ operator requires all relevant subscripts to be supplied. With the [ operator an empty index (a comma separated blank) indicates that all entries in that dimension are selected.

If one of these expressions appears on the left side of an assignment then that part of x is set to the value of the right hand side of the assignment.

Indexing by factors is allowed and is equivalent to indexing by the numeric codes (see factor) and not by the character values which are printed (for which use [as.character(i)]).

When operating on a list, the [[ operator gives the specified element of the list while the [ operator returns a list with the specified element(s) in it.

As from R 1.7.0 [[ can be applied recursively to lists, so that if the single index i is a vector of length p, alist[[i]] is equivalent to alist[[i1]]...[[ip]] providing all but the final indexing results in a list.

The operators $ and $<- do not evaluate their second argument. It is translated to a string and that string is used to locate the correct component of the first argument.

When $<- is applied to a NULL x, it coerces x to list(). This is what happens with [[<- is y is of length greater than one: if y has length 1 or 0, x is coerced to a zero-length vector of the type of value,

As from R 1.9.0 both $ and [[ can be applied to environments. Only character arguments are allowed and no partial matching is done (this is in contrast to the behavior for lists). The semantics of these operations is basically that of get(i, env=x, inherits=FALSE). If no match is found then NULL is returned. The assignment versions, $<- and [[<-, can also be used. Again, only character arguments are allowed and no partial matching is done. The semantics in this case are those of assign(i, value, env=x, inherits=FALSE). Such an assignment will either create a new binding or change the existing binding in x.

NAs in indexing

When subscripting, a numerical, logical or character NA picks an unknown element and so returns NA in the corresponding element of a logical, integer, numeric, complex or character result, and NULL for a list.

When replacing (that is using subscripting on the lhs of an assignment) NA does not select any element to be replaced. As there is ambiguity as to whether an element of the rhs should be used or not (and R handled this inconsistently prior to R 2.0.0), this is only allowed if the rhs value is of length one (so the two interpretations would have the same outcome).

References

Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) The New S Language. Wadsworth & Brooks/Cole.

See Also

list, array, matrix.

[.data.frame and [.factor for the behaviour when applied to data.frame and factors.

Syntax for operator precedence, and the R Language reference manual about indexing details.

Examples

x <- 1:12; m <- matrix(1:6,nr=2); li <- list(pi=pi, e = exp(1))
x[10]                 # the tenth element of x
x <- x[-1]            # delete the 1st element of x
m[1,]                 # the first row of matrix m
m[1, , drop = FALSE]  # is a 1-row matrix
m[,c(TRUE,FALSE,TRUE)]# logical indexing
m[cbind(c(1,2,1),3:1)]# matrix index
m <- m[,-1]           # delete the first column of m
li[[1]]               # the first element of list li
y <- list(1,2,a=4,5)
y[c(3,4)]             # a list containing elements 3 and 4 of y
y$a                   # the element of y named a

## non-integer indices are truncated:
(i <- 3.999999999) # "4" is printed
(1:5)[i]  # 3

## recursive indexing into lists
z <- list( a=list( b=9, c='hello'), d=1:5)
unlist(z)
z[[c(1, 2)]]
z[[c(1, 2, 1)]]  # both "hello"
z[[c("a", "b")]] <- "new"
unlist(z)

## check $ and [[ for environments
e1 <- new.env()
e1$a <- 10
e1[["a"]]
e1[["b"]] <- 20
e1$b
ls(e1)
[Package its version 1.1.5 Index]


Accessor, Assignment Functions for Irregular Time-Series Objects

itsAccessor(its) R Documentation

Accessor Assignment Functions for Irregular Time-Series Objects

Description

Accessor & assignment functions for objects of class "its".

Usage

dates(x,...)
names(x)
core(x)
dates(x) <- value
names(x) <- value
core(x) <- value

Arguments

x | an object of class "its"
... | further arguments passed to or from other methods
value | value to be assigned into dates, names, or core

Details

dates an accessor function, to access the time-stamps of the object.

names an accessor function, to access the (column) names of the object.

core an accessor function, to access the numeric data of the object.

dates an assignment function to assign the time-stamps of the object.

names an assignment function to assign the (column) names of the object.

core an assignment function to assign the numeric data of the object.

Value

For dates,... a vector of class "POSIXct". For names a vector of mode "character". For core a matrix of mode"numeric". For dates<-, names<-, and core<- an object of class "its".

Author(s)

Giles Heywood

See Also

ts, POSIXct, itsFile, itsLags, itsJoin, itsTimes, itsSubset, itsFin, itsDisp, itsInfo, itsCumdif, itsArith itsInterp

Examples

x <- newIts(1:10)
dates(x)
names(x)
core(x)
dates(x) <- seq(from=Sys.time()+11*24*60*60,
            length.out=10,
            by="DSTday")
names(x) <- "B"
core(x) <- as.matrix(11:20)


Arithmetic Methods for Irregular Time-Series Objects

Description

Arithmetic methods for objects of class "its".

Arguments

e1 | its object
e2 | its object

Details

Date matching is performed then the arithmatic is done on the intersection of the dates of the two arguments. The arithmetic operators return numeric vectors containing the result of the element-by-element operations.

Note that the matrix multiplication operator, and the result of a matrix multiplication is a matrix, not an "its". The resulting matrix can be converted back to its using the function its() - see examples.

Value

The returned object is an object of class "its", having the same number of columns as the two arguments, however, the number of rows will be the length of the intersection of the dates of the two arguments.

Author(s)

Giles Heywood

See Also

ts, POSIXct, itsFile, itsLags itsJoin itsTimes itsSubset itsFin itsDisp itsInfo itsCumdif itsInterp

Examples

b <- newIts(1:30,ncol=3)
c <- newIts(1:10,ncol=3)[1:5,]
b+c
b+b-2*b
b/b
b%*%diag(ncol(b))
its(b%*%diag(ncol(b)))


Conversion for its objects

Description

Conversions to basic types for "its".

Usage

as.list.its(x,...)
as.data.frame.its(x, row.names = NULL, optional = FALSE,...)

Arguments

x | an object of class "its"
... | further arguments
row.names | character vector giving the row names for the data frame.
optional | logical. If 'TRUE', setting row names and converting column names (to syntactic names) is optional.

Details

Conversion ot basic types

Value

For as.list.its a list for as.data.frame.its a data frame

Author(s)

Gabor Grothendieck


Cumulation, Differencing for Irregular Time-Series Objects

itsCumdif(its) R Documentation

Cumulation Differencing for Irregular Time-Series Objects

Description

Cumulation, differencing for objects of class "its".

Details

cumsum and diff perform the cumulative sum and difference of each column in turn. In diff, the first lag rows are discarded.

Value

An object of class "its"

Usage

cumsum(x) diff(x,lag=1)

Arguments

x
an object of class "its"
lag
an integer number of lags

Author(s)

Giles Heywood

See Also

ts, POSIXct, itsFile, itsLags itsJoin itsTimes itsSubset itsFin itsDisp itsInfo itsCumdif itsArith itsInterp

Examples

b <- newIts(1:60,ncol=3)
cumsum(b)
diff(b,lag=2)


Irregularly Spaced Time-Series

Description

The function its is used to create irregular time-series objects from user-supplied data and time-stamps. newIts is used to create semi-regular time-series objects from user-supplied data, and rule for generating time-stamps. as.its coerces an object to an irregularly spaced time-series. is.its tests whether an object is an irregularly spaced time series.

Usage

its(x,
dates=as.POSIXct(x=strptime(dimnames(x)[[1]],format=its.format())),
names=dimnames(x)[[2]],
format=its.format(),
...)

newIts(x=NA,start=format(Sys.Date(),format=its.format()),
end,ncol=1,by="DSTday",extract=FALSE,format=its.format(),tz="",...)

as.its(x,...)

is.its(object)

its.format(formatDefault=NULL)

Arguments

dates | 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 number of seconds since the beginning of 1970, see POSIXct.
start, end | POSIXct or character representation of the start or end time-stamp, if character, then the format is as specified by the argument format
ncol | number of columns of synthetic sequence of dates
by | time increment for synthetic sequence of dates, see seq.POSIXt
extract | logical flag: if TRUE, a subset of the synthetic sequence of dates is extracted, see extractIts
x | a numeric matrix representing the values of the irregular time-series object. In the case of coercion in as.its, the first column is taken to be the time-stamps, in seconds since the beginning of 1970, see POSIXct.
object |
names | a vector of mode character
format | a formatting string, see format.POSIXct, defaults to its.format()
formatDefault | a formatting string, see format.POSIXct, defaults to "%Y-%m-%d" if formatDefault is not specified.
tz | time zone of dates of its object
... | further arguments passed to or from other methods: for its passed to format.POSIXct.; for as.its passed to its.; for newIts passed to extractIts.

Details

The function its is used to create irregular time-series objects, which have (S4) class "its". An object of class "its" is a matrix with rows indexed by a time-stamp of class "POSIXct". Unlike objects of class "ts", it can be used to represent irregularly spaced time-series. The object consists of a matrix, with a single slot, the named POSIX vector named "dates". An object of class "its" inherits matrix arithmetic methods. The matrix has dimnames: dimnames[[1]] is populated with a text representation of "dates", using a format which is defined by the function its.format. These dates are not used in computations - all computations use the POSIX representation. The dates are required to be in ascending order.

When matrix multiplication is applied to an "its", the result is of class matrix. It is possible to restore the "its" class (see examples) - its() is in this sense idempotent i.e. its(mat)==its(its(mat)). Note however that the dates will be taken from dimnames[[1]], so the accuracy of this operation depends on the format of the dates.

newIts is a utility for creating a new "its" using a series of 'semi-regular' time-stamps, such as weekday, weekly, monthend etc. Conceptually the date sequence generation has two parts. The first part is the generation of a sequence using seq.POSIXt - the arguments from, to, and by are passed to this function. The second part (which is optional, and applies only if extract=TRUE) is an extraction, performed by extractIts. See extractIts for details of the arguments, which are passed via '...' .

The function its.format assigns a private variable and returns its value. The value of this default format persists in the session until reset. The purpose of the function is one of convenience: to access and/or assign the default text format for dates in the "its" package, and hence reduce the need to define the format repeatedly in a session.

Value

For its, newIts and as.its, an object of class "its", inheriting from matrix, with a single slot named 'dates', which is a vector of class POSIXct
For is.its, a logical representing the result of a test for class membership
For its.format, a text representation of dates formatting to be used in the "its" package, see format.POSIXct

Author(s)

Giles Heywood

See Also

ts, POSIXct, itsFile, itsLags, itsJoin, itsTimes, itsSubset, itsFin, itsDisp, itsInfo, itsCumdif, itsArith, itsInterp

Examples

its.format("%Y-%m-%d")    #defines text format of dates read from dimnames
mat <- structure(1:6,dim=c(2,3),dimnames=list(c("2003-01-01","2003-01-04"),letters[1:3]))
its(mat)
its.format("%Y%m%d")    #defines text format of dates written to dimnames
times <- as.POSIXct(strptime(c("1999-12-31 01:00:00","2000-01-01 02:00:00"),format="%Y-%m-%d %X"))
its(mat,times)
its.format("%Y-%m-%d %X")
its(mat,times)
is.its(its(mat,times))
its.format("%Y%m%d %X")   #defines text format of dates written to dimnames
as.its(mat)
its.format("%a %d %b %Y")
newIts(start="2003-09-30",end="2005-05-05",format="%Y-%m-%d",period="month",find="last",extract=TRUE,weekday=TRUE)
newIts(start=ISOdate(2003,12,24,0),end=ISOdate(2004,1,10),extract=TRUE,weekday=TRUE)
its.format("%Y%m%d")
as(newIts(),"data.frame")


Display Methods for Irregular Time-Series Objects

Description

Display methods for objects of class "its".

Details

plot is the method for plotting irregular time-series objects. All series are displayed on a single set of axes, by default using different colours, linetypes, and widths. If the vectors defining these attributes are short, they are cycled. lab and leg are alternatives for labelling the curves - these are located using function labcurve() from package Hmisc on CRAN.

print is the method for printing irregular time-series objects. The format for the dates is determined at the time the 'its' object is created.

Value

The methods are called for their side-effects.

Usage

plot(x,y,colvec=1:ncol(x),type="l",ltypvec=1,lwdvec=1,
leg=FALSE,lab=FALSE,yrange,format,at,interp=c("linear","none"),...)
print(x,...)

Arguments

x
an object of class "its"
y
missing
type
plot type, "l" for line, "p" for point, "b" for both - see par.
colvec,ltypvec,lwdvec
vectors of colour codes, line types, and line widths: see par.
leg
logical flag to display legend; uses labcurve in package Hmisc for auto-position.
lab
logical flag to display labels; uses labcurve in package Hmisc for auto-position.
yrange
ordinate range for display.
format
a formatting string, see format.POSIXct, for the axis dates
at
a vector of POSIX dates defining tickmark locations on axis: see axis.POSIXct
interp
a flag, indicating for plot of type line, how NA vallues are interpolated
...
further arguments passed to or from other methods: for plot passed to plot.; for print passed to print.default

Author(s)

Giles Heywood

See Also

ts, POSIXct, itsFile, itsLags, itsJoin, itsTimes, itsSubset, itsFin, itsDisp, itsInfo, itsCumdif, itsArith itsInterp

Examples

b <- newIts(1:60,ncol=3)
plot(b,colvec=c(1,7),lwdvec=1:2,ltypvec=1:2,lab=TRUE)
print(b)
as.its(matrix(1:60,20,3))


Download Historical Finance Data

Description

Download historical financial data from a given data provider over the WWW.

Usage

priceIts(instruments = "^gdaxi", start, end,
                quote = c("Open","High", "Low", "Close"),
                provider = "yahoo", method = "auto",
                origin = "1899-12-30", compression = "d", quiet=TRUE)

Arguments

instruments | a character string giving the name of the quote symbol to download. See the web page of the data provider for information about the available quote symbols.
start | an R object specifying the date of the start of the period to download. This must be in a form which is recognized by as.POSIXct, which includes R POSIX date/time objects, objects of class "date" (from package date) and "chron" and "dates" (from package chron), and character strings representing dates in ISO 8601 format. Defaults to 1992-01-02.
end | an R object specifying the end of the download period, see above. Defaults to yesterday.
quote | a character string or vector indicating whether to download opening, high, low, or closing quotes, or volume. For the default provider, this can be specified as "Open", "High", "Low", "Close", and "Volume", respectively. Abbreviations are allowed.
provider | a character string with the name of the data provider. Currently, only "yahoo" is implemented. See http://quote.yahoo.com/ for more information.
method | tool to be used for downloading the data. See download.file for the available download methods.
origin | an R object specifying the origin of the Julian dates, see above. Defaults to 1899-12-30 (Popular spreadsheet programs internally also use Julian dates with this origin).
quiet | a flag to suppress output
compression | Governs the granularity of the retrieved data; "d" for daily, "w" for weekly or "m" for monthly. Defaults to "d".

Details

This function is a direct copy from package tseries, and all credit must go to the author of that package.

Value

An "its" object with the requested data

Author(s)

A. Trapletti [*not* responsible for errors, adapted from his original idea by Giles Heywood]

See Also

ts, as.POSIXct, download.file; http://quote.yahoo.com/

Examples

## Not run:
x1 <- priceIts(instrument = c("^ftse"), start = "1998-01-01",
                    quote = "Close")
x2 <- priceIts(instrument = c("^gdax"), start = "1998-01-01",
                    quote = "Close")
x <- union(x1,x2)
names(x) <- c("FTSE","DAX")
plot(x,lab=TRUE)
## End(Not run)


File Operations for Irregular Time-Series Objects

Description

File read and write operations for objects of class "its".

Usage

readcsvIts(filename,informat=its.format(),outformat=its.format(),tz="",usetz = FALSE,header=TRUE,...)
writecsvIts(x,filename,format=its.format(),tz="",usetz = FALSE,col.names=NA,
sep=",",split=FALSE,...)

Arguments

filename | filename
x | an object of class "its"
format, informat, outformat | formatting related arguments, see format.POSIXct.
tz | what timezone the its is in
usetz | whether to include the tzone information in the saved file
header | see read.csv
col.names, sep | see write.table
split | when columns exceed 255 in number, flags for splitting into numbered subfiles
... | further arguments passed to or from other methods: for readcsvIts passed to read.csv; for writecsvIts passed to write.table

Details

readcsvIts reads from a .csv file to a matrix. The first column is assumed to contain dates in text format specified by informat, which can optionally be reformatted into the text format outformat. Both of these formats default to the format specified by its.format. To convert the matrix to an its, use its (see example)

writecsvIts write an irregular time-series object to a text file.

Value

For readcsvIts a matrix

Author(s)

Giles Heywood

See Also

ts, POSIXct, itsFile, itsLags itsJoin itsTimes itsSubset itsFin itsDisp itsInfo itsCumdif itsArith itsInterp

Examples

## Not run:
b <- newIts(1:30,ncol=3)
fname <- tempfile()
# To write an irregular time-series object to a file one might use
writecsvIts(b,filename=fname)
# To read an irregular time-series object from a file one might use
its(readcsvIts(filename=fname))
unlink(fname)
## End(Not run)


Financial Functions for Irregular Time-Series Objects

Description

Financial functions for objects of class "its".

Usage

accrueIts(x,daysperyear=365)

Arguments

x | an object of class "its"
daysperyear | integer, representing days per year for accrual

Details

accrueIts Accrues an annual rate stored in x, expressed as a decimal (not a percentage), based on the difference of the time-stamps. The accrued value is not cumulated, it is a per-period return.

Value

An object of class "its"

Author(s)

Giles Heywood

See Also

ts, POSIXct, itsFile, itsLags itsJoin itsTimes itsSubset itsFin itsDisp itsInfo itsCumdif itsArith itsInterp

Examples

a <- matrix(c(seq(by=24*60*60,length=20),1:20,41:60),nrow=20,ncol=3)
b <- as.its(a)
accrueIts(b[which(weekdayIts(b)),]/100,daysperyear=365)


Summary Information for Irregular Time-Series Objects

Description

Summary information for objects of class "its".

Details

Summary returns the same statistics as summary for a matrix, plus the number of NA and non-NA data points for each series, and the standard deviation.

Start and end return the dates corresponding to the first and last rows, respectively.

Value

For start, end, a formatted text representation of the first and last times For summary, a table of summary statistics for each series

Usage

start(x,format=its.format(),...)
end(x,format=its.format(),...)
summary(object)

Arguments

x, object
an object of class "its"
format
a formatting string, see format.POSIXct
...
further arguments passed to or from other methods: for start and end, passed to format.POSIXct.

Author(s)

Giles Heywood

See Also

ts, POSIXct, itsFile, itsLags itsJoin itsTimes itsSubset itsFin itsDisp itsInfo itsCumdif itsArith itsInterp

Examples

b <- newIts(1:30,ncol=3)
start(b,format="%y-%m-%d")
end(b)
summary(b)


Interpolation Functions for Irregular Time-Series Objects

Description

Interpolation functions for objects of class "its".

Usage

locf(x)

Arguments

x an object of class "its" or NULL

Details

locf 'Last Observation Carry Forward'. NAs are replaced by the last preceding valid observation within the series.

Value

An object of class "its".

Author(s)

Giles Heywood

See Also

ts, POSIXct, itsFile, itsLags, itsJoin, itsTimes, itsSubset, itsFin, itsDisp, itsInfo, itsCumdif, itsArith

Examples

x <- newIts(11:40,ncol=3)
x[1:2,1] <- NA
x[3:4,2] <- NA
x[9:10,3] <- NA
print(x)
print(locf(x))


Join Functions for Irregular Time-Series Objects

Description

Join functions for objects of class "its".

Usage

union(x,y)
intersect(x,y)
alignedIts(obj1,obj2,print=FALSE)
appendIts(obj1,obj2,but=TRUE,matchnames=TRUE)
collapseIts(x)

Arguments

x, y | an object of class "its" or NULL
obj1,obj2 | object of class "its"
print | logical flag to display summary information
but | logical flag controls whether overlap is disallowed
matchnames | logical flag controls whether names must match

Details

union has a number of time values (rows) which is determined by the union of the time-stamps of the two inputs. The number of columns is the sum of the number of columns of the two inputs.

intersect has a number of time values (rows) which is determined by the intersect of the time-stamps of the two inputs. The number of columns is the sum of the number of columns of the two inputs.

alignedIts selects the rows from two inputs which have identical time-stamps.

appendIts appends one object to the other, removing overlapping data from the later object, optionally checking that the column names match. Overlapping data must match.

collapseIts checks for columns with the same names, using dimnames(x)[[2]]. columns with the same names are required to have the same numeric values in each row, but are allowed NAs. The numeric data is combined, and the resulting object has unique column names - this will in general result in a reduction in the number of columns.

Value

For union, intersect, appendIts an object of class "its".
For alignedIts, a list of two objects of class "its"

Author(s)

Giles Heywood

See Also

ts, POSIXct, itsFile, itsLags, itsJoin, itsTimes, itsSubset, itsFin, itsDisp, itsInfo, itsCumdif, itsArith itsInterp

Examples

its.format("%Y-%m-%d")
b <- newIts(1:30,ncol=3,start="2003-01-01",end="2003-01-10")
union(b,diff(b))
intersect(b,diff(b))
alignedIts(b,diff(b))
b1 <- newIts(1:30,ncol=3,start="2003-01-11",end="2003-01-20")
appendIts(b,b1)
c <- union(b,b*NA)
c[2,4] <- 99
c[2,1] <- NA
print(c)
collapseIts(c)


Lag Functions for Irregular Time-Series Objects

Description

Lag functions for objects of class "its".

Usage

lagIts(x,k=1)
lagdistIts(x,kmin,kmax)

Arguments

x | an object of class "its"
k, kmin, kmax | integer lag; positive value mean earlier data is assigned to a later timestamp

Details

lagIts returns an object with the same time-stamps, but with the data shifted. lagdistIts applies lagIts over a range of lags, and appends these columns

Value

An object of class "its".

Author(s)

Giles Heywood

See Also

ts, POSIXct, itsFile, itsLags itsJoin itsTimes itsSubset itsFin itsDisp itsInfo itsCumdif itsArith itsInterp

Examples

b <- newIts(1:10)
lagIts(b)
lagdistIts(b[,1],1,3)


~~ Methods for Function [<- in Package 'its' ~~

Description

~~ Methods for function [<- in package its ~~

Methods

x = "ANY", i = "ANY", j = "ANY", value = "ANY"
~~Normal subset rules for [ apply here.
x = "its", i = "ANY", j = "ANY", value = "its"
~~Replacement method for its class. Date matching is performed using the dates argument. If dates argument is absent, then normal replacement is done using normal subset rules for i and j


Range and Extract for Irregular Time-Series Objects

Description

Range and extract for objects of class "its".

Usage

rangeIts(x,start=dates(x)[1],end=dates(x)[nrow(x)],format=its.format(),...)
extractIts(x,weekday=FALSE,find=c("all","last","first"),period=c("week","month","year"),partials=TRUE,firstlast = FALSE,select)
x[i,j,dates]

Arguments

x | an object of class "its"
start, end | POSIXct or character representation of the start or end time-stamp, if character, then the format is as specified by the argument format
format | format of "start" and "end" dates, see format.POSIXct.
i,j | indices specifying the parts to be extracted from the irregular time-series object
dates | POSIX dates specifying the timestamps of rows to be extracted from the irregular time-series object
... | further arguments passed to as.POSIXct
weekday | logical, defines whether only weekdays are to be returned
find | to find the first, last, or all samples within each period
period | the period within which 'find' and/or 'select' operate
partials | defines whether the first (possibly incomplete) period is processed for find=first, and whether the last is processed for find=last
firstlast | if TRUE, the first and last observations are returned, in addition to those observations selected by other criteria
select | an integer vector defining one or more days to select. The integer specifies wday (for period=week) or mday (for period=month). See as.POSIXlt for details

Details

rangeIts selects a range of rows that fall between two times, specified in text format.

extractIts selects a subset of rows that obey some sort of semi-regular rule such as monthends, weekdays, and so on. The order of application is weekday, find, then select.

x[i,j,dates] extractor method for an irregular time-series: i and dates are mutually exclusive alternatives for specifying rows. It proceeds as for a matrix, with the exception that drop=FALSE is enforced, so the result always inherits from matrix.

Value

An object of class "its".

Author(s)

Giles Heywood

See Also

ts, POSIXct, itsFile, itsLags, itsJoin, itsTimes, itsSubset, itsFin, itsDisp, itsInfo, itsCumdif, itsArith itsInterp

Examples

its.format("%Y-%m-%d")
b <- newIts(start="2003-01-01",end="2003-01-20")
rangeIts(b,start = "2003-01-05" ,end= "2003-01-15")
rangeIts(b,start = ISOdate(2003,1,5,hour=0) ,end= ISOdate(2003,1,15,hour=0))
b[1:3,]
b[,1]
b[,dates=ISOdate(2003,1,1,hour=0,tz="")]
its.format("%a %d %b %Y")
c <- newIts()
extractIts(c,weekday=TRUE,period="month",find="last")  #the last weekdays of the month in c


Time Functions for Irregular Time-Series Objects

Description

Time functions for objects of class "its".

Usage

daysecondIts(x,...)
weekdayIts(x,...)

Arguments

x | an object of class "its"
... | further arguments passed to as.POSIXlt

Details

daysecondIts returns the number of seconds since midnight.

weekdayIts tests which entries of an irregular time-series object are time-stamped with weekdays.

Value

For daysecondIts a vector of decimal numbers representing the number of seconds.
For weekdayIts a vector of "logical" representing the test results for each time.

Author(s)

Giles Heywood

See Also

ts, POSIXct, itsFile, itsLags itsJoin itsTimes itsSubset itsFin itsDisp itsInfo itsCumdif itsArith itsInterp

Examples

## Not run:
its.format("%Y-%m-%d %A")
b <- newIts()
print(b)
daysecondIts(b)
weekdayIts(b)
its.format("%Y-%m-%d")
## End(Not run)