timeSeries-package {timeSeries} | R Documentation |
Package of time series tools and utilities.
Package: | timeSeries |
Type: | Package |
URL: | http://www.rmetrics.org |
1. S4 timeSeries Class Definition
2. Creating timeSeries Objects
3. Printing and Plotting timeSeries Objects
4. Modifying 'timeSeries' Objects
timeSeries Class Definition
'timeSeries' ...
Extracting Information from a timeSeries object:
isUnivariate
isMultivariate
'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]. |
List of Functions:
print | ..., |
plot | ..., |
points | ..., |
lines | ... . |
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. |
'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 | ... . |
List of Functions:
merge | merges ..., |
rbind | binds ..., |
lag | lags ... . |
List of Functions:
orderColnames | ..., |
sortColname | ..., |
sampleColnames | ..., |
statsColnames | ..., |
pcaColnames | ..., |
hclustColnames | ... . |
List of Functions:
dim | ..., |
dimnames | ..., |
colnames<- | ..., |
rownames<- | ..., |
is.array | ... |
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'. |
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. |
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. |
List of Functions:
colStats | ..., |
rowStats | ... . |
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