For the management of chronological objects under R three concepts
are available: The first is the implementation of date and time in R's
chron
package neglecting locals, time zones and day light saving
times. This approach is in most cases appropriate for economic time
series. The second approach, available in R's base package implements
the POSIX standard to date and time objects, named "POSIXt"
.
Unfortunately, the representation of these objects is in some cases
operating system dependent and especially under MS Windows several
problems appeared over the time in the management of time zones and
day light saving times. Rmetrics overcomes these difficulties with
POSIX objects and introduce a new S4 class of "timeDate"
objects
which allow for powerful methods to represent dates and times in
different financial centers around the world.
Many of the basic functionalities of these objects are in common
with S-Plus' "timeDate"
objects and thus many of your privately
written functions for SPlus/FinMetrics may also be used within the
R/Rmetrics environment.
A major difference is the time zone concept which is replaced by the
"Financial Center" concept. The FinCenter
character variable
specifies where you are living and at which financial center you are
working. With the variable myFinCenter
you can overwrite the
default setting with your personal settings. With the specification
of the FinCenter
your system knows what rules rules for day
light saving times should be applied, what is your holiday calendar,
what is your currency, what are your interest rate conventions.
(Not all specifications are already implemented.) Many other
aspects can be easily accessed when a financial center is named. So we
can distinguish between Frankfurt and Zurich, which both belong to the
same time zone, but differed in DST changes in the eighties and have
different holiday calendars. Futhermore, since the underlying time
refers to "GMT" and DST rules and all other information is available
in local (ASCII) databases, we are sure, that R/Rmetrics delivers with
such a date/time concept on every computer independent of the operating
systemin use, identical results.
Another important feature of the "timeDate"
concept used here is
the fact that we don't rely on American or European ways to write dates.
We use consequently the ISO-8601 standard for date and time notations.
Generation of "timeDate"
Objects
We have defined a "timeDate"
class which is in many aspects similar
to the S-Plus class with the same name, but has also some important
advantageous differeneces. The S4 class has four Slots, the Data
slot which holds date and time as 'POSIXct' objects in the standard
ISO-8601 format, the Dim
slot which gives the dimension
of the data object (i.e. its length), the format
specification
slot and the FinCenter
slot which holds the name of the financial
center. By default this is the value
Three functions allow to cgenerate date/time objects: "timeDate"
from character vectors, timeCalendar
from date and time atoms,
and timeSequence
from a "from/to" or from a "from/length" sequence
specification. Note, time zone transformations are easily handled by
by the "timeDate"
functions which can also take "timeDate"
and POSIXt
objects as inputs, while transforming them between
financial centers and/or time zones specified by the arguments zone
and FinCenter
. Finally the function Sys.timeDate
returns
current system time in form of a "timeDate"
object.
Tests and Representation of timeDate Objects:
Rmetrics has implemented several methods to represent
"timeDate"
objects. For example, the
print method returns the date/time in square "[]"
brackets
to distinguish the output from other date and time objects.
On top of the date and
time output the name of the FinCenter
is printed. The summary
method returns a printed report with information about the
"timeDate"
object. Finally, the format methods allows to
transform objects into a ISO conform formatted character strings.
Mathematical Operations:
Rmetrics supports methods
to perform many mathematical operations. Included are methods
to extract or
to replace subsets from "timeDate"
objects,
to perform arithmetic "+"
and "-"
operations,
to group Ops
generic functions,
to return suitably lagged and iterated differences diff
,
to return differences difftimeDate
of two "timeDate"
objects, to concatenate objects, to replicate objects,
to round
objects,
to truncate objects using trunc
,
to extract the first or last entry of a vector,
to sort
the objects of the elements of a date/time vector, and
to revert "timeDate"
vector objects, among other functions.
Transformation of Objects:
Rmetrics has also functions to transform dat/time objects between
different representations. Included are methods to transform
"timeDate"
objects to character strings, to data frames,
to POSIXct or POSIXlt objects, to julian
counts. One can extract date/time atoms
from calendar
dates, and the months
atoms from a "timeDate"
object.