Rmetrics - Financial Time Series Objects

Rmetrics - Financial Time Series Objects [R logo]

Help pages for package ‘timeSeries’ version 2110.87

A C D E F G H I L M N O P Q R S T U V W misc

-- --

timeSeries-package Utilities and Tools Package

-- --

$,timeSeries-method | Subsettig Time Series
$<-,timeSeries,ANY,ANY-method | Subsettig Time Series
$<-,timeSeries,ANY,factor-method | Subsettig Time Series
$<-,timeSeries,ANY,numeric-method | Subsettig Time Series
$<-,timeSeries,ANY-method | Subsettig Time Series
$<-,timeSeries,factor-method | Subsettig Time Series
$<-,timeSeries,numeric-method | Subsettig Time Series
%*%,ANY,timeSeries-method | Mathematical Time Series Operations
%*%,timeSeries,ANY-method | Mathematical Time Series Operations
%*%,timeSeries,vector-method | Mathematical Time Series Operations
+,timeSeries,missing-method | Mathematical Time Series Operations
-,timeSeries,missing-method | Mathematical Time Series Operations

-- A --

aggregate | timeSeries Class, Functions and Methods
aggregate,timeSeries-method | timeSeries Class, Functions and Methods
aggregate-methods | timeSeries Class, Functions and Methods
aggregate.timeSeries | timeSeries Class, Functions and Methods
align,timeSeries-method | timeSeries Class, Functions and Methods
align-methods | timeSeries Class, Functions and Methods
alignDailySeries | Special Daily Time Series
apply,timeSeries-method | Apply Functions Over Time Series Periods
applySeries | Apply Functions Over Time Series Periods
as | timeSeries Class, Coercion and Transformation
as.data.frame,timeSeries-method | timeSeries Class, Coercion and Transformation
as.data.frame.timeSeries | timeSeries Class, Coercion and Transformation
as.list,timeSeries-method | timeSeries Class, Coercion and Transformation
as.list.timeSeries | timeSeries Class, Coercion and Transformation
as.matrix,timeSeries-method | timeSeries Class, Coercion and Transformation
as.matrix.timeSeries | timeSeries Class, Coercion and Transformation
as.timeSeries | timeSeries Class, Coercion and Transformation
as.timeSeries.character | timeSeries Class, Coercion and Transformation
as.timeSeries.data.frame | timeSeries Class, Coercion and Transformation
as.timeSeries.default | timeSeries Class, Coercion and Transformation
as.timeSeries.ts | timeSeries Class, Coercion and Transformation
as.timeSeries.zoo | timeSeries Class, Coercion and Transformation
as.ts,timeSeries-method | timeSeries Class, Coercion and Transformation
as.ts.timeSeries | timeSeries Class, Coercion and Transformation
attach | Attach a timSeries to the search path
attach,timeSeries-method | Attach a timSeries to the search path

-- C --

cbind | Bind two timeSeries objects
cbind.timeSeries | Bind two timeSeries objects
cbind2 | Bind two timeSeries objects
cbind2,ANY,timeSeries-method | Bind two timeSeries objects
cbind2,timeSeries,ANY-method | Bind two timeSeries objects
cbind2,timeSeries,missing-method | Bind two timeSeries objects
cbind2,timeSeries,timeSeries-method | Bind two timeSeries objects
coerce,ANY,timeSeries-method | timeSeries Class, Coercion and Transformation
coerce,ANY,timeSeries-method | timeSeries Class, Coercion and Transformation
coerce,character,timeSeries-method | timeSeries Class, Coercion and Transformation
coerce,data.frame,timeSeries-method | timeSeries Class, Coercion and Transformation
coerce,timeSeries,data.frame-method | timeSeries Class, Coercion and Transformation
coerce,timeSeries,list-method | timeSeries Class, Coercion and Transformation
coerce,timeSeries,matrix-method | timeSeries Class, Coercion and Transformation
coerce,timeSeries,ts-method | timeSeries Class, Coercion and Transformation
coerce,timeSeries,tse-method | timeSeries Class, Coercion and Transformation
coerce,ts,timeSeries-method | timeSeries Class, Coercion and Transformation
colAvgs | Column Statistics
colCum | Cumulated Column Statistics
colCummaxs | Cumulated Column Statistics
colCummaxs,matrix-method | Cumulated Column Statistics
colCummaxs,timeSeries-method | Cumulated Column Statistics
colCummins | Cumulated Column Statistics
colCummins,matrix-method | Cumulated Column Statistics
colCummins,timeSeries-method | Cumulated Column Statistics
colCumprods | Cumulated Column Statistics
colCumprods,matrix-method | Cumulated Column Statistics
colCumprods,timeSeries-method | Cumulated Column Statistics
colCumreturns | Cumulated Column Statistics
colCumreturns,matrix-method | Cumulated Column Statistics
colCumreturns,timeSeries-method | Cumulated Column Statistics
colCumsums | Cumulated Column Statistics
colCumsums,matrix-method | Cumulated Column Statistics
colCumsums,timeSeries-method | Cumulated Column Statistics
colKurtosis | Column Statistics
colMaxs | Column Statistics
colMeans,timeSeries-method | Column Statistics
colMins | Column Statistics
colnames,timeSeries-method | Time Series Columns and Rows
colnames<-,timeSeries-method | Time Series Columns and Rows
colProds | Column Statistics
colQuantiles | Column Statistics
colSds | Column Statistics
colSkewness | Column Statistics
colStats | Column Statistics
colStdevs | Column Statistics
colSums,timeSeries-method | Column Statistics
colVars | Column Statistics
comment,timeSeries-method | comment for timeSeries objects
comment<-,timeSeries-method | comment for timeSeries objects
cor,timeSeries-method | Time Series Correlations
cor-methods | Time Series Correlations
countMonthlyRecords | Special Monthly Series
cov,timeSeries-method | Time Series Correlations
cov-methods | Time Series Correlations
cummax,timeSeries-method | Mathematical Time Series Operations
cummin,timeSeries-method | Mathematical Time Series Operations
cumprod,timeSeries-method | Mathematical Time Series Operations
cumsum,timeSeries-method | Mathematical Time Series Operations
cumulated | Cumulated Time Series from Returns
cumulated.default | Cumulated Time Series from Returns
cut,timeSeries-method | Subsettig Time Series
cut.timeSeries | Subsettig Time Series

-- D --

dcauchy,timeSeries-method | Time Series Correlations
dcauchy-methods | Time Series Correlations
description | Date and User Information
diff,timeSeries-method | Mathematical Time Series Operations
diff.timeSeries | Mathematical Time Series Operations
dim,timeSeries-method | Time Series Columns and Rows
dim<-,timeSeries-method | Time Series Columns and Rows
dimnames,timeSeries-method | Time Series Columns and Rows
dimnames<-,timeSeries,list-method | Time Series Columns and Rows
dnorm,timeSeries-method | Time Series Correlations
dnorm-methods | Time Series Correlations
drawdowns | Calculations of Drawdowns
drawdownsStats | Calculations of Drawdowns
dt,timeSeries-method | Time Series Correlations
dt-methods | Time Series Correlations
dummyDailySeries | Special Daily Time Series
dummySeries | Special Daily Time Series
durations | Durations from a Time Series
durationSeries | Durations from a Time Series

-- E --

end,timeSeries-method | timeSeries, Positions
end.timeSeries | timeSeries, Positions

-- F --

fapply | Apply Functions Over Time Series Periods
filter,timeSeries-method | Linear Filtering on a Time Series
finCenter,timeSeries-method | Financial Center of to a timeSeries
finCenter<-,timeSeries-method | Financial Center of to a timeSeries
frequency,timeSeries-method | Checks if a time series is regular

-- G --

getDataPart,timeSeries-method | DataPart,timeSeries-method
getReturns | Financial Returns

-- H --

hclustColnames | Reorder Column Names of a Time Series
head,timeSeries-method | Subsettig Time Series
head.timeSeries | Subsettig Time Series

-- I --

index_timeSeries | timeSeries Class
index_timeSeries-class | timeSeries Class
initialize,timeSeries-method | timeSeries Class
interpNA | Handling Missing Time Series Values
is.na,timeSeries-method | timeSeries Class, Coercion and Transformation
is.signalSeries | timeSeries Class, Coercion and Transformation
is.timeSeries | timeSeries Class, Coercion and Transformation
is.unsorted,timeSeries-method | timeSeries Class, Coercion and Transformation
isDaily,timeSeries-method | Checks if a time series is regular
isMonthly,timeSeries-method | Checks if a time series is regular
isMultivariate | Checks if a Time Series is Univariate
isQuarterly,timeSeries-method | Checks if a time series is regular
isRegular,timeSeries-method | Checks if a time series is regular
isUnivariate | Checks if a Time Series is Univariate

-- L --

lag | Lag a Time Series
lag,timeSeries-method | Lag a Time Series
lag.timeSeries | Lag a Time Series
lines,timeSeries-method | Plot a Time Series
log,timeSeries-method | Mathematical Time Series Operations
LPP2005REC | Time Series Data Sets

-- M --

math | Mathematical Time Series Operations
Math,timeSeries-method | Mathematical Time Series Operations
Math2,timeSeries-method | Mathematical Time Series Operations
mean,timeSeries-method | Methods for 'timeSeries' object
merge | Bind two timeSeries objects
merge,ANY,timeSeries-method | Bind two timeSeries objects
merge,matrix,timeSeries-method | Bind two timeSeries objects
merge,numeric,timeSeries-method | Bind two timeSeries objects
merge,timeSeries,ANY-method | Bind two timeSeries objects
merge,timeSeries,matrix-method | Bind two timeSeries objects
merge,timeSeries,missing-method | Bind two timeSeries objects
merge,timeSeries,numeric-method | Bind two timeSeries objects
merge,timeSeries,timeSeries-method | Bind two timeSeries objects
merge.timeSeries | Bind two timeSeries objects
midquotes | Spreads and Mid Quotes
midquoteSeries | Spreads and Mid Quotes
model.frame | Model Frames for Time Series Objects
model.frame.default,ANY,timeSeries-method | Model Frames for Time Series Objects
monthly | Special Monthly Series
MSFT | Time Series Data Sets

-- N --

na | Handling Missing Time Series Values
na.contiguous,timeSeries-method | Find Longest Contiguous Stretch of non-NAs
na.omit | Handling Missing Time Series Values
na.omit,timeSeries-method | Handling Missing Time Series Values
na.omit.timeSeries | Handling Missing Time Series Values
names,timeSeries-method | Time Series Columns and Rows
names<-,timeSeries-method | Time Series Columns and Rows
newPositions<- | Deprecated functions in timeSeries package

-- O --

ohlcDailyPlot | Special Daily Time Series
Ops,array,timeSeries-method | Mathematical Time Series Operations
Ops,timeSeries,array-method | Mathematical Time Series Operations
Ops,timeSeries,timeSeries-method | Mathematical Time Series Operations
Ops,timeSeries,ts-method | Mathematical Time Series Operations
Ops,timeSeries,vector-method | Mathematical Time Series Operations
Ops,ts,timeSeries-method | Mathematical Time Series Operations
Ops,vector,timeSeries-method | Mathematical Time Series Operations
orderColnames | Reorder Column Names of a Time Series
orderStatistics | order Statistics
outlier | Subsettig Time Series
outlier,ANY-method | Subsettig Time Series
outlier,timeSeries-method | Subsettig Time Series

-- P --

pcaColnames | Reorder Column Names of a Time Series
plot | Plot a Time Series
plot,timeSeries-method | Plot a Time Series
points,timeSeries-method | Plot a Time Series
print,timeSeries-method | Print a Time Series

-- Q --

quantile,timeSeries-method | Mathematical Time Series Operations
quantile.timeSeries | Mathematical Time Series Operations

-- R --

rank,timeSeries-method | Sample Ranks of a Time Series
rbind | Bind two timeSeries objects
rbind.timeSeries | Bind two timeSeries objects
rbind2 | Bind two timeSeries objects
rbind2,ANY,timeSeries-method | Bind two timeSeries objects
rbind2,timeSeries,ANY-method | Bind two timeSeries objects
rbind2,timeSeries,missing-method | Bind two timeSeries objects
rbind2,timeSeries,timeSeries-method | Bind two timeSeries objects
readSeries | timeSeries Class
removeNA | Handling Missing Time Series Values
returns | Financial Returns
returns,ANY-method | Financial Returns
returns,timeSeries-method | Financial Returns
returnSeries | Financial Returns
rev,timeSeries-method | timeSeries, Positions
rev.timeSeries | timeSeries, Positions
rollDailySeries | Special Daily Time Series
rollMonthlySeries | Special Monthly Series
rollMonthlyWindows | Special Monthly Series
rowCum | Cumulated Column Statistics
rowCumsums | Cumulated Column Statistics
rowCumsums,ANY-method | Cumulated Column Statistics
rowCumsums,timeSeries-method | Cumulated Column Statistics
rownames,timeSeries-method | Time Series Columns and Rows
rownames<-,timeSeries,ANY-method | Time Series Columns and Rows
rownames<-,timeSeries,timeDate-method | Time Series Columns and Rows

-- S --

sample,timeSeries-method | timeSeries, Positions
sampleColnames | Reorder Column Names of a Time Series
scale,timeSeries-method | Mathematical Time Series Operations
scale.timeSeries | Mathematical Time Series Operations
sd,timeSeries-method | Time Series Correlations
sd-methods | Time Series Correlations
series | Data of a timeSeries object
series,timeSeries-method | Data of a timeSeries object
series<- | Data of a timeSeries object
series<-,timeSeries,ANY-method | Data of a timeSeries object
series<-,timeSeries,data.frame-method | Data of a timeSeries object
series<-,timeSeries,matrix-method | Data of a timeSeries object
series<-,timeSeries,vector-method | Data of a timeSeries object
seriesData | timeSeries Class
seriesPositions | Deprecated functions in timeSeries package
setDataPart,timeSeries-method | DataPart,timeSeries-method
show,timeSeries-method | Print a Time Series
sort,timeSeries-method | timeSeries, Positions
sort.timeSeries | timeSeries, Positions
sortColnames | Reorder Column Names of a Time Series
spreads | Spreads and Mid Quotes
spreadSeries | Spreads and Mid Quotes
start,timeSeries-method | timeSeries, Positions
start.timeSeries | timeSeries, Positions
statsColnames | Reorder Column Names of a Time Series
str | Object Str
str,timeSeries-method | Object Str
substituteNA | Handling Missing Time Series Values
Summary,timeSeries-method | Mathematical Time Series Operations
summary,timeSeries-method | Methods for 'timeSeries' object

-- T --

t,timeSeries-method | timeSeries Transpose
tail,timeSeries-method | Subsettig Time Series
tail.timeSeries | Subsettig Time Series
time | timeSeries, Positions
time,timeSeries-method | timeSeries, Positions
time.timeSeries | timeSeries, Positions
time<- | timeSeries, Positions
time<-.timeSeries | timeSeries, Positions
timeSeries | timeSeries Class
timeSeries,ANY,ANY-method | timeSeries Class
timeSeries,ANY,missing-method | timeSeries Class
timeSeries,ANY,timeDate-method | timeSeries Class
timeSeries,matrix,ANY-method | timeSeries Class
timeSeries,matrix,missing-method | timeSeries Class
timeSeries,matrix,numeric-method | timeSeries Class
timeSeries,matrix,timeDate-method | timeSeries Class
timeSeries,missing,ANY-method | timeSeries Class
timeSeries,missing,missing-method | timeSeries Class
timeSeries,missing,timeDate-method | timeSeries Class
timeSeries-class | timeSeries Class
TimeSeriesClass | timeSeries Class
TimeSeriesData | Time Series Data Sets
TimeSeriesSubsettings | Subsettig Time Series
time_timeSeries | timeSeries Class
time_timeSeries-class | timeSeries Class
trunc,timeSeries-method | Mathematical Time Series Operations

-- U --

USDCHF Time Series Data Sets

-- V --

var,timeSeries-method | Time Series Correlations
var-methods | Time Series Correlations

-- W --

window,timeSeries-method | Subsettig Time Series
window.timeSeries | Subsettig Time Series

-- misc --

[,timeSeries,ANY,index_timeSeries-method | Subsettig Time Series
[,timeSeries,character,character-method | Subsettig Time Series
[,timeSeries,character,index_timeSeries-method | Subsettig Time Series
[,timeSeries,character,missing-method | Subsettig Time Series
[,timeSeries,index_timeSeries,character-method | Subsettig Time Series
[,timeSeries,index_timeSeries,index_timeSeries-method | Subsettig Time Series
[,timeSeries,index_timeSeries,missing-method | Subsettig Time Series
[,timeSeries,matrix,index_timeSeries-method | Subsettig Time Series
[,timeSeries,matrix,missing-method | Subsettig Time Series
[,timeSeries,missing,character-method | Subsettig Time Series
[,timeSeries,missing,index_timeSeries-method | Subsettig Time Series
[,timeSeries,missing,missing-method | Subsettig Time Series
[,timeSeries,timeDate,character-method | Subsettig Time Series
[,timeSeries,timeDate,index_timeSeries-method | Subsettig Time Series
[,timeSeries,timeDate,missing-method | Subsettig Time Series
[,timeSeries,timeSeries,index_timeSeries-method | Subsettig Time Series
[,timeSeries,timeSeries,missing-method | Subsettig Time Series
[,timeSeries,time_timeSeries,ANY-method | Subsettig Time Series
[,timeSeries,time_timeSeries,character-method | Subsettig Time Series
[,timeSeries,time_timeSeries,index_timeSeries-method | Subsettig Time Series
[,timeSeries,time_timeSeries,missing-method | Subsettig Time Series
[<-,timeSeries,character,ANY-method | Subsettig Time Series
[<-,timeSeries,character,character-method | Subsettig Time Series
[<-,timeSeries,character,index_timeSeries-method | Subsettig Time Series
[<-,timeSeries,character,missing-method | Subsettig Time Series
[<-,timeSeries,index_timeSeries,character-method | Subsettig Time Series
[<-,timeSeries,matrix,character-method | Subsettig Time Series
[<-,timeSeries,timeDate,ANY-method | Subsettig Time Series
[<-,timeSeries,timeDate,character-method | Subsettig Time Series
[<-,timeSeries,timeDate,index_timeSeries-method | Subsettig Time Series
[<-,timeSeries,timeDate,missing-method | Subsettig Time Series
[<-,timeSeries,timeSeries,character-method | Subsettig Time Series
[<-,timeSeries,timeSeries,index_timeSeries-method | Subsettig Time Series
[<-,timeSeries,timeSeries,missing-method | Subsettig Time Series


Utilities and Tools Package

Description

Package of time series tools and utilities.

Details

Package: | timeSeries
Type: | Package
URL: | http://www.rmetrics.org

Overview of Topics:

1. S4 timeSeries Class Definition
2. Creating timeSeries Objects
3. Printing and Plotting timeSeries Objects
4. Modifying 'timeSeries' Objects

1. S4 timeSeries Class

timeSeries Class Definition

'timeSeries' ...

Extracting Information from a timeSeries object:

isUnivariate
isMultivariate

2. Creating timeSeries Objects

'timeSeries' objects can be created in several ways. One can create them from scratch, or one can read them from a file. If we have a file it is assumed that the first column holds a character string with the date/time positions, named "charvec", and the remaining column(s), depending if we consider the univariate or multivariate case the numeric time series records named "data".

Create a 'timeSeries' object from scratch:

timeSeries

Read a time Series from a file:

readSeries

Attach a 'timeSeries' object to the search path:

List of Functions:

timeSeries | Creates a 'timeSeries' from scratuch,
readSeries | reads a time series from a file,
attach | attaches a 'timeSeries' object,
detach | detaches a 'timeSeries' object [see base package].

3. Printing and Plotting 'timeSeries' Objects

List of Functions:

print | ...,
plot | ...,
points | ...,
lines | ... .

4. Modifying 'timeSeries' Objects

If we have a price/index series or a return series, it is often required taht we have to convert from one to the other representation. So Rmetrics makes functions available which compute returns from price/index series or the cumulated series from returns. Further modifications are concerned with drawdowns, durations, spreads and midquotes.

List of Functions:

returns | Compute returns from prices or indexes,
cumulated | compute cumulated series from a returns,
drawdowns | compute series of drawdowns from financial returns,
durations | compute durations from a financial time series,
spreads | compute spreads from a price/index stream,
miquotes | compute mid quotes from a price/index stream.

Subsetting timeSeries Objects

'timeSeries' objects can subsetted in several ways. The method window (and the deprecated function cut) extracts the subset of a 'timeSeries' observed between the times from and to. The methods head and tail return the first or last part of a time series for a specified length. The method outlier can be used to remove huge "outliers" which may appear for example through the redefinition of an index (it should not be used for outlier detection).

There are other functions provided which can be considered in broader sense as subset functions. For example the function

        fapply(x, from, to, FUN, ...)

can be used to subset a time series with very complex rules, e.g. subset Mondays from a series, subset the last Thursdays in every Month, subset from a daily series open (first), high, low, close (last) prices to a end-of-month time series, etc.

As another example, we mention the function aggreagte which can data records subset to monthly or quarterly information with information specified by the function FUN

         aggregate(x, by = c("monthly", "quarterly"), FUN = colMeans,
            units = NULL, ...)

List of Functions:

"[" | ...,
"[<-" | ...,
window | ...,
head | ...,
tail | ...,
outlier | ...,
fapply | ...,
aggreagte | ... .

Merging and Binding timeSeries Objects

List of Functions:

merge | merges ...,
rbind | binds ...,
lag | lags ... .

Reordering the columns of timeSeries Objects

List of Functions:

orderColnames | ...,
sortColname | ...,
sampleColnames | ...,
statsColnames | ...,
pcaColnames | ...,
hclustColnames | ... .

Renaming column and rows of timeSeries Objects

List of Functions:

dim | ...,
dimnames | ...,
colnames<- | ...,
rownames<- | ...,
is.array | ...

Mathematical Operations

List of Functions:

Ops.timeSeries | S3: Arith method for a 'timeSeries' object,
abs | Returns absolute values of a 'timeSeries' object,
sqrt | Returns square root of a 'timeSeries' object,
exp | Returns the exponential values of a 'timeSeries' object,
log | Returns the logarithm of a 'timeSeries' object,
sign | Returns the signs of a 'timeSeries' object,
diff | Differences a 'timeSeries' object,
scale | Centers and/or scales a 'timeSeries' object,
quantile | Returns quantiles of an univariate 'timeSeries'.

Handling Missing Data

List of Functions:

na.omit | Handles NAs in a timeSeries object,
removeNA | removes NAs from a matrix object,
substituteNA | substitutes NAs by zero, the column mean or median,
interpNA | interpolates NAs using R's "approx" function.

Special Daily and Monthly Operations

Note, a daily time series is not necessarily a series which has only position dates, rather it should mean that we have not more than one record per day. The availability of daily data, e.g. end of day data, is in real time usually at the same local time every working day, but this may be influenced due to holidays or due to the fact that you get the data from a financial center located in another time zone than your own.

If all all these facts can be neglected and only date positions without time information is relevant and we speak losely of "daily" data records. It is also worth to note, that Rmetrics uses in this case by default the ISO-8601 format "%Y-%m-%d".

In the case of monthly data, it is important to note that Rmetrics always expects the full date for the position vector and not only the years ans monhts. ...

List of Functions:

dummyDailySeries | Creates a dummy daily 'timeSeries' object,
alignDailySeries | Aligns a daily 'timeSeries' to new positions,
rollDailySeries | Rolls daily a 'timeSeries' on a given period,
ohlcDailyPlot | Plots open high low close bar chart,
countMonthlyRecords | Returns a series with monthly counts of records,
isMonthly | Decides if the series consists of monthly records,
rollMonthlyWindows | Returns start and end dates for rolling time windows,
rollMonthlySeries | Rolls monthly a 'timeSeries' on a given period.

Column and Row Statistics

List of Functions:

colStats | ...,
rowStats | ... .

Coercion of timeSeries Objects

List of Functions:

as
is.timeSeries

as.timeSeries
as.timeSeries.default
as.timeSeries.numeric
as.timeSeries.data.frame
as.timeSeries.matrix
as.timeSeries.ts
as.timeSeries.character
as.timeSeries.zoo

as.vector.timeSeries
as.matrix.timeSeries
as.data.frame.timeSeries
as.ts.timeSeries

[Package timeSeries version 2110.87 Index]


Apply Functions Over Time Series Periods

Description

Apply a function over time series peridos of arbitrary positons and lengths.

Usage

fapply(x, from, to, FUN, ...)

applySeries(x, from = NULL, to = NULL, by = c("monthly", "quarterly"),
    FUN = colMeans, units = NULL, format = x@format, zone = x@FinCenter,
    FinCenter = x@FinCenter, recordIDs = data.frame(), title = x@title,
    documentation = x@documentation, ...)

Arguments

x | an object of class timeSeries.
from, to | starting date and end date as timeDate objects. Note, to must be time ordered after from. If from and to are missing in function fapply they are set by default to from=start(x), and to=end(x).
FUN | the function to be applied. For the function applySeries the default setting is FUN=colMeans.
by | a character value either "monthly" or "quarterly" used in the function applySeries. The default value is "monthly". Only operative when both arguments from and to have their default values NULL. In this case the function FUN will be applied to monthly or quarterly periods.
units | an optional character string, which allows to overwrite the current column names of a timeSeries object. By default NULL which means that the column names are selected automatically.
format | the format specification of the input character vector in POSIX notation.
zone | the time zone or financial center where the data were recorded.
FinCenter | a character value with the the location of the financial center named as "continent/city", or "city".
recordIDs | a data frame which can be used for record identification information. Note, this is not yet handled by the apply functions, an empty data.frame will be returned.
title | an optional title string, if not specified the inputs data name is deparsed.
documentation | optional documentation string, or a vector of character strings.
... | arguments passed to other methods.

Details

Like apply applies a function to the margins of an array, the function fapply applies a function to the time stamps or signal counts of a financial (therefore the "f" in front of the function name) time series of class 'timeSeries'.

The function fapply inputs a timeSeries object, and if from and to are missing, they take the start and end time stamps of the series as default falues. The function then behaves like apply on the column margin.

Note, the function fapply can be used repetitive in the following sense: If from and to are two timeDate vectors of equal length then for each period spanned by the elelemts of the two vectors the function FUN will be applied to each period. The resulting time stamps, are the time stamps of the to vector. Note, the periods can be regular or irregelar, and they can even overlap.

The function fapply calls the more general function applySeries which also offers, to create automatical monthly and quarterly periods.

Examples

## Percentual Returns of Swiss Bond Index and Performance Index -
   data(LPP2005REC)
   LPP = 100 * LPP2005REC[, c("SBI", "SPI")]
   head(LPP, 20)

## Aggregate Quarterly Returns -
   applySeries(LPP, by = "quarterly", FUN = colSums)

## Aggregate Quarterly every last Friday in Quarter -
   oneDay = 24*3600
   from = unique(timeFirstDayInQuarter(time(LPP))) - oneDay
   from = timeLastNdayInMonth(from, nday = 5)
   to = unique(timeLastDayInQuarter(time(LPP)))
   to = timeLastNdayInMonth(to, nday = 5)
   data.frame(from = as.character(from), to = as.character(to))
   applySeries(LPP, from, to, FUN = colSums)

## Alternative Use -
   fapply(LPP, from, to, FUN = colSums)

## Count Trading Days per Month -
   colCounts = function(x) rep(NROW(x), times = NCOL(x))
   applySeries(LPP, FUN = colCounts, by = "monthly")


Attach a timSeries to the search path

Description

Attach a 'timeSeries' object to the search path.

attach | attaches a 'timeSeries' object,
detach | detaches a 'timeSeries' object [see base package].

Usage

## S4 method for signature 'timeSeries':
attach(what, pos = 2, name = deparse(substitute(what)),
    warn.conflicts = TRUE)

Arguments

name | [attach] - alternative way to specify the database to be attached. See for details help(attach,package=base).
pos | [attach] - an integer specifying position in search() where to attach the database. See for details help(attach,package=base).
warn.conflicts | [attach] - a logical value. If TRUE, warnings are printed about conflicts from attaching the database, unless that database contains an object .conflicts.OK. A conflict is a function masking a function, or a non-function masking a non-function. See for details help(attach,package=base).
what | [attach] - database to be attached. This may currently be a timeSeries object, a data.frame or a list or a R data file created with save or NULL or an environment. See for details help(attach,package=base).

Note

Preliminary, further work has to be done.

Examples

## Load Microsoft Data Set -
   data(MSFT)
   x <- MSFT[1:10, ]

## Attach the Series and Compute the Range -
   attach(x)
   High - Low


Bind two timeSeries objects

Description

Binds two 'timeSeries' objects either by column or row.

Value

returns a S4 object of class timedate.

Examples

## Load Microsoft Data Set -
   data(MSFT)
   x = MSFT[1:12, ]

## Bind Columnwise -
   X <- cbind(x[, "Open"], returns(x[, "Open"]))
   colnames(X) <- c("Open", "Return")
   X

## Bind Rowwise -
   Y <- rbind(x[1:3, "Open"], x[10:12, "Open"])
   Y


Cumulated Column Statistics

Description

Functions to compute cumulative column statistics.

Usage

## S4 method for signature 'timeSeries':
colCumsums(x, na.rm = FALSE, ...)

## S4 method for signature 'timeSeries':
colCummaxs(x, na.rm = FALSE, ...)

## S4 method for signature 'timeSeries':
colCummins(x, na.rm = FALSE, ...)

## S4 method for signature 'timeSeries':
colCumprods(x, na.rm = FALSE, ...)

## S4 method for signature 'timeSeries':
colCumreturns(x, method = c("geometric", "simple"), na.rm = FALSE, ...)

Arguments

method | a character string to indicate if geometric (TRUE) or simple (FALSE) returns should be computed.
na.rm | a logical. Should missing values be removed?
x | a time series, may be an object of class "matrix", or "timeSeries".
... | arguments to be passed.

Value

all functions return an S4 object of class timeSeries.

Examples

## Simulated Return Data -
   x = matrix(rnorm(24), ncol = 2)

## Cumulative Sums Column by Column  -
   colCumsums(x)


Column Statistics

Description

A collection and description of functions to compute column statistical properties of financial and economic time series data.

The functions are:

colStats | calculates column statistics,
colSums | calculates column sums,
colMeans | calculates column means,
colSds | calculates column standard deviations,
colVars | calculates column variances,
colSkewness | calculates column skewness,
colKurtosis | calculates column kurtosis,
colMaxs | calculates maximum values in each column,
colMins | calculates minimum values in each column,
colProds | computes product of all values in each column,
colQuantiles | computes quantiles of each column.

Usage

colStats(x, FUN, ...)

colSds(x, ...)
colVars(x, ...)
colSkewness(x, ...)
colKurtosis(x, ...)
colMaxs(x, ...)
colMins(x, ...)
colProds(x, ...)
colQuantiles(x, prob = 0.05, ...)

colStdevs(x, ...)
colAvgs(x,  ...)

Arguments

FUN | a function name. The statistical function to be applied.
prob | a numeric value, the probability with value in [0,1].
x | a rectangular object which can be transformed into a matrix by the function as.matrix.
... | arguments to be passed.

Value

the functions return a numeric vector of the statistics.

See Also

link{rowStats}.

Examples

## Simulated Return Data in Matrix Form -
   x = matrix(rnorm(252), ncol = 2)

## Mean Columnwise Statistics -
   colStats(x, FUN = mean)

## Quantiles Column by Column -
   colQuantiles(x, prob = 0.10, type = 1)


Time Series Columns and Rows

Description

Functions and methods handling columns and rows of 'timeSeries' objects.

dim | Returns the dimension of a 'timeSeries' object,
dimnames | Returns the dimension names of a 'timeSeries' object,
colnames<- | Assigns column names to a 'timeSeries' object,
rownames<- | Assigns row names to a 'timeSeries' object,

Arguments

value | a valid value for names component of dimnames(x).
x | an object of class timeSeries.

Value

NA

Examples

## Load Swiss Pension Fund Benchmark Data -
   data(LPP2005REC)
   X = LPP2005REC[1:10, 1:3]

## Get Dimension -
   dim(X)

## Get Column and Row Names -
   dimnames(X)

## Get Column Names -
   colnames(X)

## Get Row Names -
   rownames(X)


Sample Ranks of a Time Series

Description

Return the sample ranks of the values of a 'timeSeries' object.

Value

returns the ranks of a timeSeries object

Examples

## Load Microsoft Data -
   data(MSFT)
   X = 100 * returns(MSFT)

## Compute the Ranks -
   head(rank(X[, "Open"]), 10)

## Only Interested in the Vector, then use -
   head(rank(series(X[, "Open"])), 10)


Cumulated Column Statistics

Description

Compute cumulative row Statistics.

Usage

## S4 method for signature 'ANY':
rowCumsums(x, na.rm = FALSE, ...)
## S4 method for signature 'timeSeries':
rowCumsums(x, na.rm = FALSE, ...)

Arguments

na.rm | a logical. Should missing values be removed?
x | a time series, may be an object of class "matrix" or "timeSeries".
... | arguments to be passed.

Value

all functions return an S4 object of class timeSeries.

Examples

## Simulated Monthly Return Data -
   X = matrix(rnorm(24), ncol = 2)

## Compute cumulated Sums -
   rowCumsums(X)


Subsettig Time Series

Description

Subset a 'timeSeries' objects due to different aspects.

[ | "[" method for a 'timeSeries' object,
[<- | "[<-" method to assign value for a subset of a 'timeSeries' object,
window | Windows a piece from a 'timeSeries' object,
cut | A no longer used synonyme for window,
head | Returns the head of a 'timeSeries' object,
tail | Returns the tail of a 'timeSeries' object,
outliers | Removes outliers from a 'timeSeries' object.

Usage

## S4 method for signature 'timeSeries':
window(x, start, end, ...)

## S4 method for signature 'timeSeries':
head(x, n = 6, recordIDs = FALSE, ...)
## S4 method for signature 'timeSeries':
tail(x, n = 6, recordIDs = FALSE, ...)

## S4 method for signature 'timeSeries':
outlier(x, sd = 10, complement = TRUE, ...)

## S4 method for signature 'timeSeries':
cut(x, from, to, ...)

Arguments

complement | [outlierSeries] - a logical flag, should the outler series or its complement be returns, by default TRUE which returns the series free of outliers.
from, to | starting date and end date, to must be after from.
start, end | starting date and end date, end must be after start.
n | [head][tail] - an integer specifying the number of lines to be returned. By default n=6.
recordIDs | [head][tail] - a logical value. Should the recordIDs returned together with the data matrix and time series positions?
sd | [outlierSeries] - a numeric value of standard deviations, e.g. 10 means that values larger or smaller tahn ten times the standard deviation will be removed from the series.
x | an object of class timeSeries.
... | arguments passed to other methods.

Value

all functions return an object of class timeSeries.

Examples

## Create an Artificial timeSeries Object -
   setRmetricsOptions(myFinCenter = "GMT")
   charvec = timeCalendar()
   set.seed(4711)
   data = matrix(exp(cumsum(rnorm(12, sd = 0.1))))
   tS = timeSeries(data, charvec, units = "tS")
   tS

## Subset Series by Counts "[" -
   tS[1:3, ]

## Subset the Head of the Series -
   head(tS, 6)


timeSeries Transpose

Description

Returns the transpose of a timeSries object.

Usage

## S4 method for signature 'timeSeries':
t(x)

Arguments

x a timeSeries object.

Value

A matrix object.

Examples

## Dummy timeSeries with NAs entries
   data <- matrix(1:24, ncol = 2)
   s <- timeSeries(data, timeCalendar())

## transpose
   t(s)


Time Series Data Sets

Description

Three data sets used in example files.

The data sets are:

LPP2005REC | Swiss pension fund assets returns benchmark,
MSFT | Daily Microsoft OHLC prices and volume,
USDCHF | USD CHF intraday foreign exchange xchange rates.

Examples

## Plot LPP2005 Example Data Set -
   data(LPP2005REC)
   plot(LPP2005REC, type = "l")

## Plot MSFT Example Data Set -
   data(MSFT)
   plot(MSFT[, 1:4], type = "l")
   plot(MSFT[, 5], type = "h")

## Plot USDCHF Example Data Set -
   plot(USDCHF, type = "l")


timeSeries Class, Functions and Methods

align-methods(timeSeries) R Documentation

timeSeries Class Functions and Methods

Description

Aligns a 'timeSeries' Object.

Usage

## S4 method for signature 'timeSeries':
align(x, by = "1d", offset = "0s",
    method = c("before", "after", "interp", "fillNA"),
    include.weekends = FALSE)

Arguments

x | an object of class timeSeries.
by | a character string denoting the period
offset | a character string denoting the offset
method | a character string denoting the alignment approach.
include.weekends | a logical flag, should weekend be included.

Value

returns an aligned S4 object of class timeSeries.

Examples

## Load Microsoft Dataset -
   data(MSFT)

## Compute Sample Size -
   dim(MSFT)

## Align the Series -
   MSFT.AL = align(MSFT)

## Show the Size of the Aligned Series -
   dim(MSFT.AL)


Cumulated Time Series from Returns

Description

Compute cumulated financial series, e.g. prices or indexes, from financial returns.

Usage

cumulated(x, ...)

## Default S3 method:
cumulated(x, method = c("continuous", "discrete",
    "compound", "simple"), percentage = FALSE, ...)

Arguments

method | a character string naming the method how the returns were computed.
percentage | a logical value. By default FALSE, if TRUE the series will be expressed in percentage changes.
x | an object of class timeSeries.
... | arguments to be passed.

Value

all functions return a time series object of the same class as the input argument x.

Examples

## Load Microsoft Data -
   data(MSFT)
   setRmetricsOptions(myFinCenter = "GMT")
   MSFT <- MSFT[1:10, "Close"]
   MSFT

## Discrete Return Series  -
   MSFT = 100 * MSFT/as.numeric(MSFT[1, 1])
   MSFT.RET = returns(MSFT, method = "discrete")
   MSFT.RET

## Cumulative Series, Indexed to 100 -
   cumulated(MSFT.RET, method = "discrete")


Special Daily Time Series

Description

Special daily 'timeSeries' functions.

dummyDailySeries | Creates a dummy daily 'timeSeries' object,
alignDailySeries | Aligns a daily 'timeSeries' to new positions,
rollDailySeries | Rolls daily a 'timeSeries' on a given period,
ohlcDailyPlot | Plots open high low close bar chart,
dummySeries | Creates a dummy monthly 'timeSeries' object

Usage

dummyDailySeries(x = rnorm(365), units = NULL, zone = "",
    FinCenter = "")
alignDailySeries(x, method = c("before", "after", "interp", "fillNA"),
    include.weekends = FALSE, units = NULL, zone = "",
    FinCenter = "")
rollDailySeries(x, period = "7d", FUN, ...)
ohlcDailyPlot(x, volume = TRUE, colOrder = c(1:5), units = 1e6,
    xlab = c("Date", "Date"), ylab = c("Price", "Volume"),
    main = c("O-H-L-C", "Volume"), grid.nx = 7, grid.lty = "solid", ...)

Arguments

colOrder | [ohlcDailyPlot] - an integer vector which gives the order of the prices and the volume in the input object. By default the following order of columns from 1 to 5 is assumed: Open, high, low, close, and volume.
FinCenter | a character with the the location of the financial center named as "continent/city".
FUN | the function to be applied. [applySeries] - a function to use for aggregation, by default colAvgs.
grid.lty, grid.nx | [ohlcDailyPlot] - The type of grid line and the number of grid lines used in the plot.
include.weekends | [alignDailySeries] - a logical value. Should weekend dates be included or removed from the series.
main | [ohlcDailyPlot] - a character string to title the price and volume plot.
method | [alignDailySeries] - the method to be used for the alignment. A character string, one of "before", use the data from the row whose position is just before the unmatched position, or "after", use the data from the row whose position is just after the unmatched position, or "linear", interpolate linearly between "before" and "after".
period | [rollDailySeries] - a character string specifying the rollling period composed by the length of the period and its unit, e.g. "7d" represents one week.
units | [allignDailySeries] - an optional character string, which allows to overwrite the current column names of a timeSeries object. By default NULL which means that the column names are selected automatically. [ohlcDailyPlot] - a numeric value, specifying in which multiples the volume should be referenced on the plot labels. By default 1e6, i.e. in units of 1 Million.
volume | [ohlcDailyPlot] - a logigical value. Should a volume plot added to the OHLC Plot. By default TRUE.
x | an object of class timeSeries.
xlab, ylab | [ohlcDailyPlot] - two string vectors to name the x and y axis of the price and volume plot.
zone | the time zone or financial center where the data were recorded.
... | arguments passed to other methods.

Value

dummyDailySeries
creates from a numeric matrix with daily records of unknown dates a timeSeries object with dummy daily dates.

alignDailySeries
returns from a daily time series with missing holidays a weekly aligned daily timeSeries object

rollDailySeries

returns an object of class timeSeries with rolling values, computed from the function FUN.

ohlcDailyPlot displays a Open-High-Low-Close Plot of daily data records.

Examples

## Load Microsoft Data -
   setRmetricsOptions(myFinCenter = "GMT")
   data(MSFT)
   head(MSFT)

## Cut out April Data from 2001 -
   Close = MSFT[, "Close"]
   tsApril01 = window(Close, "2001-04-01", "2001-04-30")
   tsApril01

## Align with NA -
   tsRet = returns(tsApril01, trim = TRUE)
   GoodFriday(2001)
   EasterMonday(2001)
   alignDailySeries(tsRet, method = "fillNA", include.weekends = FALSE)
   alignDailySeries(tsRet, method = "fillNA", include.weekends = TRUE)

## Interpolate -
   alignDailySeries(tsRet, method = "interp", include.weekend = FALSE)
   alignDailySeries(tsRet, method = "interp", include.weekend = TRUE)


Calculations of Drawdowns

Description

Compute series of drawdowns from financial returns and ccalculate drawdown statisitcs.

The functions are:

drawdowns | Generates 'timeSeries' object of drawdown levels,
drawdownsStats | Compute drawdown stats for univariate time series.

Usage

drawdowns(x, ...)

drawdownsStats(x, ...)

Arguments

x | [drawdowns] - an uni- or multivariate 'timeSeries' object of financial returns, [drawdowns] - an univariate 'timeSeries' object of financial returns.
... | [drawdowns] - optional arguments passed to the function na.omit, [drawdownsStats] - arguments passed to the function drawdowns.

Value

drawdowns
returns an object of class 'timeSeries'.
drawdownsStats
returns an object of class 'data.frame' wit the following entries:
"drawdown" - the depth of the drawdown,
"from" - the start date,
"trough" - the trough period,
"to" - the end date,
"length" - the length in number of records,
"peaktrough" - the peak trough, and ,
"recovery" - the recovery length in number of records.

Author(s)

Peter Carl and Sankalp Upadhyay for code from the contributed R package PerformanceAnalytics.

Examples

## Load Swiss Pension Fund Data Set -
   setRmetricsOptions(myFinCenter = "GMT")
   data(LPP2005REC)
   head(LPP2005REC)

## Compute Drawdowns Statistics -
   drawdownsStats(LPP2005REC[, "SPI"])

## Plot Drawdowns -
   dd = drawdowns(LPP2005REC[, "SPI"])
   plot(dd)


Durations from a Time Series

Description

Compute durations from an object of class 'timeSeries'.

Usage

durations(x, trim = FALSE, units = c("secs", "mins", "hours"))

durationSeries(...)

Arguments

trim | a logical value. By default TRUE, the first missing observation in the return series will be removed.
units | [durationSeries] - a character value or vector which allows to set the units in which the durations are measured. By default durations are measured in seconds.
x | an object of class timeSeries.
... | arguments to be passed.

Value

returns an object of class timeSeries.

Examples

## Load Microsoft Data -
   data(MSFT)
   setRmetricsOptions(myFinCenter = "GMT")
   MSFT = MSFT[1:20, "Open"]
   MSFT

## Compute Durations in hours, Use Continuous Returns -
   durations(MSFT, units = "hours")


Special Monthly Series

Description

Functions and methods dealing with special monthly 'timeSeries' objects.

countMonthlyRecords | Returns a series with monthly counts of records,
rollMonthlyWindows | Returns start and end dates for rolling time windows,
rollMonthlySeries | Rolls monthly a 'timeSeries' on a given period.

Usage

countMonthlyRecords(x)

rollMonthlyWindows(x, period = "12m", by = "1m")
rollMonthlySeries(x, period = "12m", by = "1m", FUN, ...)

Arguments

by | a character string specifying the rolling shift composed by the length of the shift and its unit, e.g. "3m" represents quarterly shifts.
FUN | the function to be applied. [applySeries] - a function to use for aggregation, by default colAvgs.
period | [rollMonthlySeries] - a character string specifying the rollling period composed by the length of the period and its unit, e.g. "12m" represents one year.
x | an object of class timeSeries.
... | arguments passed to other methods.

Value

NA

Examples

## Load Microsoft Daily Data Set:
   data(MSFT)

## Count Monthly Records -
   MSFT.CTS <- countMonthlyRecords(MSFT)
   MSFT.CTS


Reorder Column Names of a Time Series

Description

Functions and methods dealing with the rearrangement of column names of 'timeSeries' objects.

orderColnames | Returns ordered column names of a time Series,
sortColnames | Returns sorted column names of a time Series,
sampleColnames | Returns sampled column names of a time Series,
statsColnames | Returns statistically rearranged column names,
pcaColnames | Returns PCA correlation ordered column names,
hclustColnames | Returns hierarchical clustered column names.

Usage

orderColnames(x, ...)
sortColnames(x, ...)
sampleColnames(x, ...)
statsColnames(x, FUN = colMeans, ...)
pcaColnames(x, robust = FALSE, ...)
hclustColnames(x, method = c("euclidean", "complete"), ...)

Arguments

FUN | a character string indicating which statistical function should be applied. By default statistical ordering operates on the column means of the time series.
method | a character string with two elements. The first determines the choice of the distance measure, see dist, and the second determines the choice of the agglomeration method, see hclust.
robust | a logical flag which indicates if robust correlations should be used.
x | an object of class timesSeries or any other rectangular object which can be transformed by the function as.matrix into a numeric matrix.
... | further arguments to be passed, see details.

Details

Statistically Motivated Rearrangement

The function statsColnames rearranges the column names according to a statical measure. These measure must operate on the columns of the time series and return a vector of values which can be sorted. Typical functions ar those listed in in help page colStats but one can also crete his own functions which compute for example risk or any other statistical measure. The ... argument allows to pass additional arguments to the underlying function FUN.

PCA Ordering of the Correlation Matrix

The function pcaColnames rearranges the column names according to the PCA ordered correlation matrix. The argument robust allsows to select between the use of the standard cor and computation of robust correlations using the function covMcd from contributed R package robustbase. The ... argument allows to pass additional arguments to the two underlying functions cor or covMcd. E.g. adding method="kendall" to the argument list calculates Kendall's rank correlations instead the default which calculates Person's correlations.

Ordering by Hierarchical Clustering

The function pcaColnames uses the hierarchical clustering approach hclust to rearrange the column names of the time series.

Value

returns a vector of character string, the rearranged column names.

Examples

## Load Swiss Pension Fund Benchmark Data -
   data(LPP2005REC)

## Abbreviate Column Names -
   colnames(LPP2005REC)

## Sort Alphabetically -
   sortColnames(LPP2005REC)

## Sort by Column Names by Hierarchical Clustering -
   hclustColnames(LPP2005REC)
   head(LPP2005REC[, hclustColnames(LPP2005REC)])


order Statistics

Description

Computes order statistic of a 'timeSeries'.

Usage

orderStatistics(x)

Arguments

x an object of class timeSeries.

Value

orderStatistics
returns ...

Examples

## Load Swiss Pension Fund Benchmark Data -
   setRmetricsOptions(myFinCenter = "GMT")
   data(LPP2005REC)

## Compute Order Statistics -
   head(orderStatistics(LPP2005REC))


Financial Returns

Description

Compute financial returns from prices or indexes.

Usage

returns(x, ...)

## S4 method for signature 'ANY':
returns(x, method = c("continuous", "discrete",
    "compound", "simple"), percentage = FALSE, ...)
## S4 method for signature 'timeSeries':
returns(x, method = c("continuous", "discrete",
    "compound", "simple"), percentage = FALSE, na.rm = TRUE,
    trim = TRUE, ...)

getReturns(...)
returnSeries(...)

Arguments

percentage | a logical value. By default FALSE, if TRUE the series will be expressed in percentage changes.
method | a character string. Which method should be used to compute the returns, "continuous", "discrete", or "compound", "simple". The second pair of methods is a synonyme for the first two methods.
na.rm | a logical value. Should NAs be removed? By Default TRUE.
trim | a logical value. Should the time series be trimmed? By Default TRUE.
x | an object of class timeSeries.
... | arguments to be passed.

Value

all functions return an object of class timeSeries.

Note

The functions returnSeries, getReturns, are synonymes for returns.timeSeries.

Examples

## Load Microsoft Data -
   setRmetricsOptions(myFinCenter = "GMT")
   data(MSFT)
   X = MSFT[1:10, 1:4]
   X

## Continuous Returns -
   returns(X)

## Discrete Returns:
   returns(X, type = "discrete")

## Don't trim:
   returns(X, trim = FALSE)

## Use Percentage Values:
   returns(X, percentage = TRUE, trim = FALSE)


Spreads and Mid Quotes

Description

Compute spreads and midquotes from price streams.

Usage

spreads(x, which = c("Bid", "Ask"), tickSize = NULL)
midquotes(x, which = c("Bid", "Ask"))

midquoteSeries(...)
spreadSeries(...)

Arguments

tickSize | the default is NULL to simply compute price changes in original price levels. If ticksize is supplied, the price changes will be divided by the value of inTicksOfSize to compute price changes in ticks.
which | a vector with two character strings naming the column names of the time series from which to compute the mid quotes and spreads. By default these are bid and ask prices with column names c("Bid", "Ask").
x | an object of class timeSeries.
... | arguments to be passed.

Value

all functions return an object of class timeSeries.

Note

The functions returnSeries, getReturns, midquoteSeries, spreadSeries are synonymes for returns, midquotes, and spreads.

Examples

## Load the Microsoft Data -
   setRmetricsOptions(myFinCenter = "GMT")
   data(MSFT)
   X = MSFT[1:10, ]
   head(X)

## Compute Open/Close Midquotes -
   X.MID <- midquotes(X, which = c("Close", "Open"))
   colnames(X.MID) <- "X.MID"
   X.MID

## Compute Open/Close Spreads -
   X.SPREAD <- spreads(X, which = c("Close", "Open"))
   colnames(X.SPREAD) <- "X.SPREAD"
   X.SPREAD


Plot a Time Series

Description

Plot 'timeSeries' objects.

Usage

## S4 method for signature 'timeSeries':
plot(x, y, FinCenter = NULL, plot.type =
    c("multiple", "single"), format = "auto", at = "auto", widths = 1,
    heights = 1, xy.labels, xy.lines, panel = lines, nc, yax.flip =
    FALSE, mar.multi = c(0, 5.1, 0, if (yax.flip) 5.1 else 2.1),
    oma.multi = c(6, 0, 5, 0), axes = TRUE, ...)
## S4 method for signature 'timeSeries':
lines(x, FinCenter = NULL, ...)
## S4 method for signature 'timeSeries':
points(x, FinCenter = NULL, ...)

Arguments

x | an object of class timeSeries.
y | an object of class timeSeries.
FinCenter | a character with the the location of the financial center named as "continent/city".
plot.type | for multivariate time series, should the series by plotted separately (with a common time axis) or on a single plot?
format | ...
at | ...
widths | ...
heights | ...
xy.labels | logical, indicating if text() labels should be used for an x-y plot, _or_ character, supplying a vector of labels to be used. The default is to label for up to 150 points, and not for more.
xy.lines | logical, indicating if lines should be drawn for an x-y plot. Defaults to the value of xy.labels if that is logical, otherwise to TRUE
panel | a function(x, col, bg, pch, type, ...) which gives the action to be carried out in each panel of the display for plot.type="multiple". The default is lines
nc | the number of columns to use when type="multiple". Defaults to 1 for up to 4 series, otherwise to 2.
yax.flip | : logical indicating if the y-axis (ticks and numbering) should flip from side 2 (left) to 4 (right) from series to series when type="multiple".
mar.multi, oma.multi | the (default) par settings for plot.type="multiple".
axes | logical indicating if x- and y- axes should be drawn.
... | additional graphical arguments, see plot, plot.default and par

Value

a plot or plot elements of an object of class timeSeries.

Examples

## Load Swiss Pension Fund Benchmark Data -
   LPP = LPP2005REC[1:12, 1:4]
   colnames(LPP) <- abbreviate(colnames(LPP), 2)
   finCenter(LPP) <- "GMT"

## Example Plot 1 -
   plot(LPP[, 1], type = "o", col = "steelblue",
     main = "LPP", xlab = "2005", ylab = "Return")

## Example Plot 2 -
   plot(LPP[, 1:2], type = "o", col = "steelblue",
     main = "LPP", xlab = "2005", ylab = "Return")

## Example Plot 3 -
   plot(LPP[, 1], LPP[, 2], type = "p", col = "steelblue",
     main = "LPP", xlab = "Return 1", ylab = "Return 2")

## Example Plot 4a, The Wrong Way to do it! -
   LPP = as.timeSeries(data(LPP2005REC))
   ZRH = as.timeSeries(LPP[,"SPI"], zone = "Zurich", FinCenter = "Zurich")
   NYC = as.timeSeries(LPP[,"LMI"], zone = "NewYork", FinCenter = "NewYork")
   finCenter(ZRH)
   finCenter(NYC)
   plot(ZRH, type = "p", pch = 19, col = "blue")
   points(NYC, pch = 19, col = "red")

## Example Plot 4b, Convert NYC to Zurich Time -
   finCenter(ZRH) <- "Zurich"
   finCenter(NYC) <- "Zurich"
   at = unique(round(time(ZRH)))
   plot(ZRH, type = "p", pch = 19, col = "blue", format = "%b %d", at = at,
       xlab = paste(ZRH@FinCenter, "local Time"), main = ZRH@FinCenter)
   points(NYC, pch = 19, col = "red")

## Example 4c, Force Everything to GMT Using "FinCenter" Argument -
   finCenter(ZRH) <- "Zurich"
   finCenter(NYC) <- "NewYork"
   at = unique(round(time(ZRH)))
   plot(ZRH, type = "p", pch = 19, col = "blue", format = "%b %d", at = at,
       FinCenter = "GMT", xlab = "GMT", main = "ZRH - GMT")
   points(NYC, FinCenter = "GMT", pch = 19, col = "red")


timeSeries Class, Coercion and Transformation

as(timeSeries) R Documentation

timeSeries Class Coercion and Transformation

Description

Functions and methods dealing with the coercion of 'timeSeries' objects.

Functions to create 'timeSeries' objects from other objects:

as.timeSeries | Generic function to convert an object to a 'timeSeries' object,
as.timeSeries.default | Returns the unchanged object,
as.timeSeries.numeric | Converts from a numeric vector,
as.timeSseries.data.frame | Converts from a numeric vector,
as.timeSeries.matrix | Converts from a matrix,
as.timeSeries.ts | Converts from an object of class 'ts',
as.timeSeries.character | Converts from a named demo file,
as.timeSeries.zoo | Converts an object of class zoo.

Functions to transform 'timeSeries' objects into other objects:

as.matrix.timeSeries | Coerces a 'timeSeries' to a matrix,
as.data.frame.timeSeries | Coerces a 'timeSeries' to a data.frame,
as.ts.timeSeries | S3: Coerces a 'timeSeries' to a 'ts' object.
as.ts.timeSeries | S3: Coerces a 'timeSeries' to a 'logical' object.

Usage

## Default S3 method:
as.timeSeries(x, ...)
## S3 method for class 'ts':
as.timeSeries(x, ...)
## S3 method for class 'data.frame':
as.timeSeries(x, ...)
## S3 method for class 'character':
as.timeSeries(x, ...)
## S3 method for class 'zoo':
as.timeSeries(x, ...)

## S4 method for signature 'timeSeries':
as.matrix(x, ...)
## S4 method for signature 'timeSeries':
as.ts(x, ...)
## S4 method for signature 'timeSeries':
as.data.frame(x, row.names = NULL, optional = FALSE, ...)
## S4 method for signature 'timeSeries':
as.ts(x, ...)

Arguments

optional | A logical value. If TRUE, setting row names and converting column names (to syntactic names) is optional.
row.names | NULL or a character vector giving the row names for the data frame. Missing values are not allowed.
x | an object which is coerced according to the generic function.
... | arguments passed to other methods.

Value

as.timeSeries

returns a S4 object of class timeSeries.

as.numeric
as.data.frame
as.matrix
as.ts
return depending on the generic function a numeric vector, a data frame, a matrix, or an object of class ts.

Examples

## Create an Artificial timeSeries Object -
   setRmetricsOptions(myFinCenter = "GMT")
   charvec = timeCalendar()
   data = matrix(rnorm(12))
   TS = timeSeries(data, charvec, units = "RAND")
   TS

## Coerce to Vector -
   as.vector(TS)

## Coerce to Matrix -
   as.matrix(TS)

## Coerce to Data Frame -
   as.data.frame(TS)


Methods for 'timeSeries' object

Description

Methods for function in Package `base' for timeSeries object.

var

summary

var

Methods

x = "timeSeries"
a timeSeries object.

Examples

## None -


comment for timeSeries objects

Description

Print or assign new comment to a timeSeries object.

Usage

## S4 method for signature 'timeSeries':
comment(x)
## S4 method for signature 'timeSeries':
comment(x) <- value

Arguments

x | a timeSeries object.
value | a character string.

Examples

## Load Swiss Pension Fund Benchmark -
   data(LPP2005REC)

## Get Description from timeSeries -
   comment(LPP2005REC)


timeSeries Class, Coercion and Transformation

is.timeSeries(timeSeries) R Documentation

timeSeries Class Coercion and Transformation

Description

is.timeSeries tests if its argument is a timeSeries. is.timeSeries tests if series has no timestamps.

Usage

is.timeSeries(x)
is.signalSeries(x)

Arguments

x an R object.

Value

returns TRUE or FALSE depending on whether its argument is of timeSeries type or not.

Examples

## Create an Artificial timeSeries Object -
   setRmetricsOptions(myFinCenter = "GMT")
   charvec = timeCalendar()
   data = matrix(rnorm(12))
   TS = timeSeries(data, charvec, units = "RAND")
   TS

## Test for timeSeries -
   is.timeSeries(TS)


Mathematical Time Series Operations

Description

Functions and methods dealing with mathematical 'timeSeries' operations.

Ops-method | Group 'Ops' methods for a 'timeSeries' object
Math-method | Group 'Math' methods for a 'timeSeries' object
Math2-method | Group 'Math2' methods for a 'timeSeries' object
Summary-method | Group 'Summary' methods for a 'timeSeries' object
diff | Differences a 'timeSeries' object,
scale | Centers and/or scales a 'timeSeries' object,
quantile | Returns quantiles of an univariate 'timeSeries'.

Usage

## S4 method for signature 'timeSeries':
diff(x, lag = 1, diff = 1, trim = FALSE, pad = NA, ...)
## S4 method for signature 'timeSeries':
scale(x, center = TRUE, scale = TRUE)
## S4 method for signature 'timeSeries':
quantile(x, ...)

Arguments

center, scale | [scale] - either a logical value or a numeric vector of length equal to the number of columns of x.
diff | an integer indicating the order of the difference. By default 1.
lag | an integer indicating which lag to use. By default 1.
pad | [diffSeries] - which value should get the padded values? By default NA. Another choice often used would be zero.
trim | a logical value. By default TRUE, the first missing observation in the return series will be removed.
x | an object of class timeSeries.
... | arguments to be passed.

Value

returns the value from a mathematical or logical operation operating on objects of class timeSeries, or the value computed by a mathematical function.

Examples

## Create an Artificial timeSeries Object -
   setRmetricsOptions(myFinCenter = "GMT")
   charvec = timeCalendar()
   set.seed(4711)
   data = matrix(exp(cumsum(rnorm(12, sd = 0.1))))
   TS = timeSeries(data, charvec, units = "TS")
   TS

## Mathematical Operations: | +/- * ^ ... -
   TS^2
   TS[2:4]
   OR = returns(TS)
   OR
   OR > 0


Print a Time Series

Description

Print 'timeSeries' pbjects.

Arguments

object an object of class timeSeries.

Value

prints an object of class timeSeries.

Examples

## Load Micsrosoft Data -
   setRmetricsOptions(myFinCenter = "GMT")
   LPP = MSFT[1:12, 1:4]

## Abbreviate Column Names -
   colnames(LPP) <- abbreviate(colnames(LPP), 6)

## Print Data Set -
   print(LPP)

## Alternative Use, Show Data Set -
   show(LPP)


Time Series Correlations

Description

S4 methods of stats package for timeSeries objects.

cov | Computes Covariance from a 'timeSeries' object,
cor | Computes Correlations from a 'timeSeries' object.
dcauchy | ...
dnorm | ...
dt | ...

Usage

## S4 method for signature 'timeSeries':
cov(x, y = NULL, use = "all.obs",
    method = c("pearson", "kendall", "spearman"))

## S4 method for signature 'timeSeries':
cor(x, y = NULL, use = "all.obs",
    method = c("pearson", "kendall", "spearman"))

Arguments

method | a character string indicating which correlation coefficient (or covariance) is to be computed. One of "pearson" (default), "kendall", or "spearman", can be abbreviated.
use | an optional character string giving a method for computing covariances in the presence of missing values. This must be (an abbreviation of) one of the strings "all.obs", "complete.obs" or "pairwise.complete.obs".
x | an univariate object of class timeSeries.
y | NULL (default) or a timeSeries object with compatible dimensions to x. The default is equivalent to y = x (but more efficient).

Value

returns the covariance or correlation matrix.

Examples

## Load Microsoft Data Set -
   data(MSFT)
   X = MSFT[, 1:4]
   X = 100 * returns(X)

## Compute Covariance Matrix -
   cov(X[, "Open"], X[, "Close"])
   cov(X)


timeSeries Class, Functions and Methods

aggregate-methods(timeSeries) R Documentation

timeSeries Class Functions and Methods

Description

Aggregates a 'timeSeries' Object.

Usage

## S4 method for signature 'timeSeries':
aggregate(x, by, FUN, ...)

Arguments

by | [aggregate] - sequence of timeDate objects denoting the aggregation period.
FUN | the function to be applied.
x | an object of class timeSeries.
... | arguments passed to other methods.

Value

returns an aggregated S4 object of class timeSeries.

Examples

## Load Microsoft Data Set -
   data(MSFT)
   x <- MSFT

## Aggregate by Weeks -
   by <- timeSequence(from = start(x),  to = end(x), by = "week")
   aggregate(x, by, mean)

## Aggregate to Last Friday of Month -
   by <- unique(timeLastNdayInMonth(time(x), 5))
   aggregate(x, by, mean)

## Aggregate to Last Day of Quarter -
   by <- unique(timeLastDayInQuarter(time(x)))
   aggregate(x, by, mean)


Linear Filtering on a Time Series

Description

Applies linear filtering to a univariate time series or to each series separately of a multivariate time series.

Value

A timeSeries object without missing values.

Examples

## Dummy timeSeries
   data <- matrix(rnorm(24), ncol = 2)
   s <- timeSeries(data, timeCalendar())

## Filter
   filter(s, rep(1, 3))


Lag a Time Series

Description

Compute a lagged version of a 'timeSeries' object.

Usage

## S4 method for signature 'timeSeries':
lag(x, k = 1, trim = FALSE, units = NULL, ...)

Arguments

k | [lagSeries] - an integer value. The number of lags (in units of observations). By default 1.
trim | a logical value. By default TRUE, the first missing observation in the return series will be removed.
units | an optional character string, which allows to overwrite the current column names of a timeSeries object. By default NULL which means that the column names are selected automatically.
x | an object of class timeSeries.
... | arguments passed to other methods.

Value

returns a lagged S4 object of class timeSeries.

Examples

## Load Micsrosoft Data Set -
   x = MSFT[1:20, "Open"]

## Lag the timeSeries Object:
   lag(x, k = -1:1)


Model Frames for Time Series Objects

Description

Allow to work with model frames for 'timeSeries' objects.

Details

The function model.frame is a generic function which returns in the R-ststs framework by default a data.frame with the variables needed to use formula and any ... arguments. In contrast to this the method returns an object of class timeSeries when the argument data was not a data.frame but also an object of class timeSeries.

Value

an object of class timeSeries.

Note

This function is preliminary and untested.

See Also

model.frame.

Examples

## Load Microsoft Data -
   setRmetricsOptions(myFinCenter = "GMT")
   data(MSFT)
   X = MSFT[1:12, ]

## Extract High's and Low's:
   model.frame( ~ High + Low, data = X)

## Extract Open Prices and their log10's:
   base = 10
   Open = model.frame(Open ~ log(Open, base = `base`), data = X)
   colnames(Open) <- c("X", "log10(X)")
   Open


Find Longest Contiguous Stretch of non-NAs

Description

Find the longest consecutive stretch of non-missing values in a timeSeries object. (In the event of a tie, the first such stretch.)

Usage

## S4 method for signature 'timeSeries':
na.contiguous(object, ...)

Arguments

object | a timeSeries object.
... | further arguments passed to or from other methods.

Value

A timeSeries object without missing values.

Examples

## Dummy timeSeries with NAs entries
   data <- matrix(sample(c(1:20, rep(NA,4))), ncol = 2)
   s <- timeSeries(data, timeCalendar())

## Find the longest consecutive non-missing values
   na.contiguous(s)


Handling Missing Time Series Values

Description

Functions for handling missing values in 'timeSeries' objects or in objects which can be transformed into a vector or a two dimensional matrix.

The functions are listed by topic.

na.omit | Handles NAs,
removeNA | Removes NAs from a matrix object,
substituteNA | substitute NAs by zero, the column mean or median,
interpNA | interpolates NAs using R's "approx" function.

Usage

## S4 method for signature 'timeSeries':
na.omit(object, method = c("r", "s", "z", "ir", "iz", "ie"),
    interp = c("before", "linear", "after"), ...)

removeNA(x, ...)
substituteNA(x, type = c("zeros", "mean", "median"), ...)
interpNA(x, method = c("linear", "before", "after"), ...)

Arguments

interp, type | [nna.omit][substituteNA] - Three alternative methods are provided to remove NAs from the data: type="zeros" replaces the missing values by zeros, type="mean" replaces the missing values by the column mean, type="median" replaces the missing values by the the column median.
method | [na.omit] - Specifies the method how to handle NAs. One of the applied vector strings: method="s" na.rm = FALSE, skip, i.e. do nothing, method="r" remove NAs, method="z" substitute NAs by zeros, method="ir" interpolate NAs and remove NAs at the beginning and end of the series, method="iz" interpolate NAs and substitute NAs at the beginning and end of the series, method="ie" interpolate NAs and extrapolate NAs at the beginning and end of the series, [interpNA] - Specifies the method how to interpolate the matrix column by column. One of the applied vector strings: method="linear", method="before" or method="after". For the interpolation the function approx is used.
object | an object of class("timeSeries").
x | a numeric matrix, or any other object which can be transformed into a matrix through x = as.matrix(x, ...). If x is a vector, it will be transformed into a one-dimensional matrix.
... | arguments to be passed to the function as.matrix.

Details

Missing Values in Price and Index Series:

Applied to timeSeries objects the function removeNA just removes rows with NAs from the series. For an interpolation of time series points one can use the function interpNA. Three different methods of interpolation are offered: "linear" does a linear interpolation, "before" uses the previous value, and "after" uses the following value. Note, that the interpolation is done on the index scale and not on the time scale.

Missing Values in Return Series:

For return series the function substituteNA may be useful. The function allows to fill missing values either by method="zeros", the method="mean" or the method="median" value of the appropriate columns.

Note

The functions removeNA, substituteNA and interpNA are older implementations. Please use in all cases if possible the new function na.omit.

References

Troyanskaya O., Cantor M., Sherlock G., Brown P., Hastie T., Tibshirani R., Botstein D., Altman R.B., (2001); Missing Value Estimation Methods for DNA microarrays Bioinformatics 17, 520–525.

Examples

## Create a Matrix -
   X = matrix(rnorm(100), ncol = 5)

## Replace a Single NA Inside -
   X[3, 5] = NA

## Replace Three in a Row Inside -
   X[17, 2:4] = c(NA, NA, NA)

## Replace Three in a Column Inside -
   X[13:15, 4] = c(NA, NA, NA)

## Replace Two at the Right Border -
   X[11:12, 5] = c(NA, NA)

## Replace One in the Lower Left Corner -
   X[20, 1] = NA
   print(X)

## Remove Rows with NAs -
   removeNA(X)

## Subsitute NA's by Zeros or Column Mean -
   substituteNA(X, type = "zeros")
   substituteNA(X, type = "mean")

## Interpolate NA's Linearily -
   interpNA(X, method = "linear")
   # Note the corner missing value cannot be interpolated!

## Take Previous Values in a Column -
   interpNA(X, method = "before")
   # Also here, the corner value is excluded


timeSeries Class

Description

A collection and description of functions and methods dealing with regular and irregular 'timeSeries' objects. Dates and times are implemented as 'timeDate' objects.

Functions to generate and modify 'timeSeries' objects:

timeSeries | Creates a 'timeSeries' object from scratch,
readSeries | Reads a 'timeSeries' from a spreadsheet file.

Data Slot and classification of 'timeSeries' objects:

seriesData Extracts data slot from a 'timeSeries'.

Usage

timeSeries(data, charvec, units = NULL, format = NULL, zone = "",
    FinCenter = "", recordIDs = data.frame(), title = NULL,
    documentation = NULL, ...)

readSeries(file, header = TRUE, sep = ";", zone = "",
    FinCenter = "",  ...)

seriesData(object)

Arguments

charvec | a character vector of dates and times or any objects which can be coerced to a timeDate object.
data | a matrix object or any objects which can be coereced to a matrix.
documentation | optional documentation string, or a vector of character strings.
file | the filename of a spreadsheet data set from which to import the data records.
FinCenter | a character with the the location of the financial center named as "continent/city".
header | a logical value indicating whether the file contains the names of the variables as its first line. If missing, the value is determined from the file format: 'header' is set to 'TRUE' if and only if the first row contains one fewer field than the number of columns.
format | the format specification of the input character vector, [as.timeSeries] - a character string with the format in POSIX notation to be passed to the time series object.
object | [is][seriesData][seriesPositions][show][summary] - an object of class timeSeries.
recordIDs | a data frame which can be used for record identification information. [print] - a logical value. Should the recordIDs printed together with the data matrix and time series positions?
sep | [readSeries] - the field seperator used in the spreadsheet file to separate columns.
title | an optional title string, if not specified the inputs data name is deparsed.
units | an optional character string, which allows to overwrite the current column names of a timeSeries object. By default NULL which means that the column names are selected automatically.
zone | the time zone or financial center where the data were recorded.
... | arguments passed to other methods.

Details

Generation of Time Series Objects:

We have defined a timeSeries class which is in many aspects similar to the S-Plus class with the same name, but has also some important differences. The class has seven Slots, the 'Data' slot which holds the time series data in matrix form, the 'position' slot which holds the time/date as a character vector, the 'format' and 'FinCenter' slots which are the same as for the 'timeDate' object, the 'units' slot which holds the column names of the data matrix, and a 'title' and a 'documentation' slot which hold descriptive character strings. Date and time is managed in the same way as for timeDate objects.

Value

timeSeries
readSeries
returnSeries

return a S4 object of class timeSeries.

orderStatistics
returns ...

series

extracts the @.Data slot from a timeSeries object and is equivalent to as.amtrix.

Note

These functions were written for Rmetrics users using R and Rmetrics under Microsoft's Windows operating system where timze zones, daylight saving times and holiday calendars are insuffeciently supported.

Examples

## Load Microsoft Data -
   # Microsoft Data:
   setRmetricsOptions(myFinCenter = "GMT")
   data(MSFT)
   head(MSFT)

## Create a timeSeries Object, The Direct Way ...
   Close = MSFT[, 5]
   head(Close)

## Create a timeSeries Object from Scratch -
   data = as.matrix(MSFT[, 4])
   charvec = rownames(MSFT)
   Close = timeSeries(data, charvec, units = "Close")
   head(Close)
   c(start(Close), end(Close))

## Cut out April Data from 2001 -
   tsApril01 = window(Close, "2001-04-01", "2001-04-30")
   tsApril01

## Compute Continuous Returns -
   returns(tsApril01)

## Compute Discrete Returns -
   returns(tsApril01, type = "discrete")

## Compute Discrete Returns, Don't trim -
   returns(tsApril01, trim = FALSE)

## Compute Discrete Returns, Use Percentage Values -
   tsRet = returns(tsApril01, percentage = TRUE, trim = FALSE)
   tsRet

## Aggregate Weekly -
   GoodFriday(2001)
   to = timeSequence(from = "2001-04-11", length.out = 3, by = "week")
   from = to - 6*24*3600
   from
   to
   applySeries(tsRet, from, to, FUN = sum)

## Create large timeSeries objects with different 'charvec' object classes -
   # charvec is a 'timeDate' object
   head(timeSeries(1:1e6L, timeSequence(length.out = 1e6L, by = "sec")))
   head(timeSeries(1:1e6L, seq(Sys.timeDate(), length.out = 1e6L, by = "sec")))
   # 'charvec' is a 'POSIXt' object
   head(timeSeries(1:1e6L, seq(Sys.time(), length.out = 1e6L, by = "sec")))
   # 'charvec' is a 'numeric' object
   head(timeSeries(1:1e6L, 1:1e6L))


Deprecated functions in timeSeries package

Description

seriesPositions | Extracts positions slot from a 'timeSeries',
newPositions<- | Modifies positions of a 'timeSeries' object,


Date and User Information

Description

Returns data and user string.

Usage

description()

Examples

## Show Default Description String -
   description()


Financial Center of to a timeSeries

Description

Print or assign new financial center to a timeSeries object.

Usage

## S4 method for signature 'timeSeries':
finCenter(x)
## S4 method for signature 'timeSeries':
finCenter(x) <- value

Arguments

x | a timeSeries object.
value | a character with the the location of the financial center named as "continent/city".

See Also

listFinCenter

Examples

## A timeSeries Object -
   data <- matrix(rnorm(24), ncol = 2)
   charvec <- as.character(timeCalendar())
   ts <- timeSeries(data, charvec, FinCenter = "NewYork")
   ts

## Print Financial Center -
   finCenter(ts)

## Assign New Financial Center -
   finCenter(ts) <- "Zurich"
   ts


DataPart,timeSeries-method

DataPart,timeSeries-method(timeSeries) R Documentation

DataParttimeSeries-method

Description

utilites called to implement object@.Data of timeSeries objects.

Examples

## Load Microsoft Data -
   data(MSFT)
   X <- MSFT[1:10, 1:4]

## Get Data Part -
   getDataPart(X)


Checks if a time series is regular

Description

Checks if a time series is regular. i.e. if a series is a daily, a monthly, or a weekly time series. If the series is regular the frequency of the serie scan determined calling the function frequency.

Usage

## S4 method for signature 'timeSeries':
isDaily(x)
## S4 method for signature 'timeSeries':
isMonthly(x)
## S4 method for signature 'timeSeries':
isQuarterly(x)

## S4 method for signature 'timeSeries':
isRegular(x)

## S4 method for signature 'timeSeries':
frequency(x, ...)

Arguments

x | an R object of class timeSeries.
... | arguments to be passed.

Details

A time series is defined as daily if the series has not more than one date/time stamp per day.

A time series is defined as monthly if the series has not more than one date/time stamp per month.

A time series is defined as quarterly if the series has not more than one date/time stamp per quarter.

A monthly series is also a daily series, a quarterly series is also a monthly series.

A regular series is either a monthly or a quarterly series.

NOT yet implemented is the case of weekly series.

Value

The is* functions return TRUE or FALSE depending on whether the series fulfills the condition or not.
The function frequency returns in general 1, for quarterly series 4, and for monthly series 12.

Examples

## None


Checks if a Time Series is Univariate

Description

Checks if a time series o bject or any other rectangular object is univariate or multivariate.

Usage

isUnivariate(x)
isMultivariate(x)

Arguments

x an object of class timeSeries or any other rectangular object.

Details

A rectangular object x is considered to be univariate if the function NCOL(x) returns one, and is considered to be multivariate if NCOL(x) returns a value bigger than one.

Value

isUnivariate
isMultivariate

return a logical depending if the test is true or not.

Examples

## Load Microsoft Data -
   setRmetricsOptions(myFinCenter = "GMT")
   data(MSFT)
   Open = MSFT[, "Open"]

## Is the timeSeries Univariate -
   isUnivariate(MSFT)
   isUnivariate(Open)

## Is the timeSeries Multivariate -
   isMultivariate(MSFT)
   isMultivariate(Open)


Data of a timeSeries object

Description

series returns Data slot a timeSeries object in a matrix form. New series can also be assign to the timeSeries.

Usage

series(x)
series(x) <- value

Arguments

x | a timeSeries object.
value | a vector, a data.frame or a matrix object of numeric data.

See Also

timeSeries()

Examples

## A Dummy timeSeries Object
   ts <- timeSeries()
   ts

## Get the Matrix Part -
   mat <- series(ts)
   class(mat)
   mat

## Assign a New Univariate Series -
   series(ts) <- rnorm(12)
   ts

## Assign a New Bivariate Series -
   series(ts) <- rnorm(12)
   ts


timeSeries, Positions

time(timeSeries) R Documentation

timeSeries Positions

Description

Functions and methods extracting and modifying positions of 'timeSeries' objects.

The functions and methods for the Generation of 'timeSeries' Objects are:

time.timeSeries | Extracts time positions from a 'timeSeries',
time<-.timeSeries | Assign time positions to a 'timeSeries',
sample.timeSeries | Resamples a 'timeSeries' object in time,
sort.timeSeries | Sorts reverts a 'timeSeries' object in time,
rev.timeSeries | Reverts a 'timeSeries' object in time,
start.timeSeries | Extracts start date of a 'timeSeries' object,
end.timeSeries | Extracts end date of a 'timeSeries' object.

Usage

## S4 method for signature 'timeSeries':
time(x, ...)
## S3 method for class 'timeSeries':
time(x) <- value

## S4 method for signature 'timeSeries':
start(x, ...)
## S4 method for signature 'timeSeries':
end(x, ...)

## S4 method for signature 'timeSeries':
sort(x, decreasing = FALSE, ...)
## S4 method for signature 'timeSeries':
rev(x)

Arguments

decreasing | logical. Should the sort be increasing or decreasing? Not available for partial sorting.
value | a valid value for the component of time(x).
x | [as] - a matrix type object to be converted. [as.vector][as.matrix][as.data.frame] - [applySeries] - [cut][end][mergeSeries][plot][print][rev][start] - an object of class timeSeries.
... | arguments passed to other methods.

Value

timeSeries
read.timeSeries
as.timeSeries
return a S4 object of class timeSeries.

seriesData
seriesPositions
extract the @.Data and @position slots from a timeSeries object. Thus, seriesData returns an object of class matrix, and seriesPositions returns an object of class timeDate.

is.timeSeries
returns TRUE or FALSE depending on whether its argument is of timeSeries type or not.

aggregateSeries
applySeries
cutSeries
mergeSeries
returnSeries
revSeries
return a S4 object of class timeSeries.

end, start
return a S4 object of class timedate. These are the start and end dates of a timeSeries object.

as.vector
as.matrix
as.data.frame
these are methods which convert a S4 object of class timeSeries either to a vector, a matrix or to a data frame.

plot
lines
points
print
plot and print methods for an object of class timeSeries. Note that the plot function requires the packages its and Hmisc.

Examples

## Create Dummy timeSeries:
   X = timeSeries(matrix(rnorm(24), 12), timeCalendar())

## Return Series Positions -
   time(X)


Object Str

Description

Compactly Display the Structure of a 'timeSeries' Object.

Usage

## S4 method for signature 'timeSeries':
str(object, ...)

Arguments

object | an object of class timeSeries.
... | arguments passed to other methods.

Value

returns a str report for an object of class timeSeries.

Examples

## Load Microsoft Data Set -
   data(MSFT)
   X = MSFT[1:12, 1:4]
   colnames(X) <- abbreviate(colnames(X), 4)

## Display Structure -
   str(X)