Title: | Time Series from 'S-PLUS' |
---|---|
Description: | A collection of classes and methods for working with indexed rectangular data. The index values can be calendar (timeSeries class) or numeric (signalSeries class). Methods are included for aggregation, alignment, merging, and summaries. The code was originally available in 'S-PLUS'. |
Authors: | Stephen Kaluzny [aut, cre], TIBCO Software Inc. [aut, cph] |
Maintainer: | Stephen Kaluzny <[email protected]> |
License: | BSD_3_clause + file LICENSE |
Version: | 1.5.7 |
Built: | 2025-01-03 06:14:30 UTC |
Source: | https://github.com/spkaluzny/splustimeseries |
Aggregation and coursening of time series and signals.
This is the method for the aggregate
function for objects of class
timeSeries
and signalSeries
.
aggregateSeries(x, pos, FUN, moving=FALSE, together=FALSE, drop.empty=TRUE, include.ends=FALSE, adj, offset, colnames, by, k.by=1, week.align=NULL, holidays=timeDate(), align.by=TRUE, incr=1, ...)
aggregateSeries(x, pos, FUN, moving=FALSE, together=FALSE, drop.empty=TRUE, include.ends=FALSE, adj, offset, colnames, by, k.by=1, week.align=NULL, holidays=timeDate(), align.by=TRUE, incr=1, ...)
x |
the series object to be aggregated. |
pos |
the break positions for aggregation (can also be supplied in the |
FUN |
the function to use for aggregation. Often Possible choices for |
moving |
either |
together |
a logical value. if |
drop.empty |
a logical value. If |
include.ends |
a logical value. If |
adj |
if provided, adjusts the positions of the output series so that they lie a
fraction |
offset |
as an alternative to |
colnames |
new column names for the output series. The default is to use the same names as the input series if the output series has the same width. |
by |
if
Alternatively, it can be one of the following character strings:
giving the time units of intervals between values in the sequence. |
k.by |
a non-zero integer giving the width of the interval between consecutive
values in the sequence in terms of the units given in |
week.align |
if not |
holidays |
holidays for business day sequences. (Ignored if |
align.by |
a logical value. If |
incr |
For moving aggregation, the moving window moves forward by this many steps in the time series, for each window. |
... |
Additional arguments to pass to FUN. |
returns a new time series whose positions are the adjusted passed-in positions or
positions generated from by
, k.by
, and so on,
(or possibly a subset if drop.empty
is TRUE
) and whose
rows are aggregated from x
as specified in the arguments.
Aggregation takes place by separating x
into blocks separated by the positions
(or overlapping blocks with a fixed number of samples if moving
is
supplied), and then applying FUN
to each column (or all columns
together if together
is TRUE
) and forming a new time series with
the positions and aggregated data.
timeSeries
, signalSeries
,
align
, aggregate
x <- timeSeries(data.frame(1:20,rnorm(20)), timeCalendar(d=1:20)) aggregate(x, FUN=mean, by="weeks")
x <- timeSeries(data.frame(1:20,rnorm(20)), timeCalendar(d=1:20)) aggregate(x, FUN=mean, by="weeks")
Aligns or interpolates a time series or signal to new positions.
align(x, pos, how="NA", error.how="NA", localzone=FALSE, matchtol=0, by, k.by=1, week.align=NULL, holidays=timeDate())
align(x, pos, how="NA", error.how="NA", localzone=FALSE, matchtol=0, by, k.by=1, week.align=NULL, holidays=timeDate())
x |
the object to be aligned or interpolated. |
||||||||||||
pos |
the new positions to align or interpolate it to
(either |
||||||||||||
how |
specifies how to treat unmatched positions. Must be one of the following:
|
||||||||||||
error.how |
specifies available actions when an out of bounds error occurs. (Such an error can occur
when
|
||||||||||||
localzone |
if T ( |
||||||||||||
matchtol |
the tolerance for matching positions. Positions that match within |
||||||||||||
by |
if
Alternatively, it can be one of the following character strings:
These strings give the time units of intervals between values in the sequence. |
||||||||||||
k.by |
a non-zero integer giving the width of the interval between consecutive
values in the sequence in terms of the units given in |
||||||||||||
week.align |
if not |
||||||||||||
holidays |
the holidays for business day sequences. (Ignored if |
If either x
or pos
(or the generated sequence) has zero length,
a zero-length series is returned.
returns a new time series or a signal whose positions are the passed-in positions or
positions generated from by
, k.by
, and so on, and whose
rows are derived from x
as specified in the arguments.
(Can be a subset if how
or error.how
is "drop"
.)
timeSeries
, signalSeries
, positions
, seriesMerge
.
a <- signalSeries(pos=1:10, data=data.frame(a = 11:20, b = 5 * (1:10))) align(a, c(.2, 3, 7.8, 12), how = "interp", error.how = "nearest") a <- timeSeries(pos=as(1:10, "timeDate"), data=data.frame(a = 11:20, b = 5 * (1:10))) alpos <- as(c(.2, 3, 7.8, 12), "timeDate") [email protected] <- "JST" positions(a)@time.zone <- "PST" align(a, alpos, matchtol = 1, localzone = TRUE) align(a, matchtol=1, localzone=TRUE, by="days", k.by=2)
a <- signalSeries(pos=1:10, data=data.frame(a = 11:20, b = 5 * (1:10))) align(a, c(.2, 3, 7.8, 12), how = "interp", error.how = "nearest") a <- timeSeries(pos=as(1:10, "timeDate"), data=data.frame(a = 11:20, b = 5 * (1:10))) alpos <- as(c(.2, 3, 7.8, 12), "timeDate") alpos@time.zone <- "JST" positions(a)@time.zone <- "PST" align(a, alpos, matchtol = 1, localzone = TRUE) align(a, matchtol=1, localzone=TRUE, by="days", k.by=2)
Functions that allow you to access all rectangular data objects in the same way. Rectangular data objects include matrices, data frames and vectors.
as.rectangular(x) as.char.rect(x) is.rectangular(x) subscript2d(x,i,j) subscript2d(x,i,j) <- value numRows(x) numRows(x) <- value numCols(x) numCols(x) <- value rowIds(x) rowIds(x) <- value colIds(x) colIds(x) <- value
as.rectangular(x) as.char.rect(x) is.rectangular(x) subscript2d(x,i,j) subscript2d(x,i,j) <- value numRows(x) numRows(x) <- value numCols(x) numCols(x) <- value rowIds(x) rowIds(x) <- value colIds(x) colIds(x) <- value
x |
the object to be converted to rectangular data ( |
i |
the first (row) subscript. |
j |
the second (column) subscript. |
value |
the object to be assign to |
subscript2d
, numRows
, numCols
, rowIds
,
colIds
can also be used on the left side of assignments. The value
can be a character vector, or anything that
can be coerced to a character vector.
subscript2d
is for subscripting. When subscript2d
is used in an assignment, it does not allow subscript replacement
outside the bounds of x
. Instead, set numRows
or
numCols
first.
When numRows
or numCols
is used in
an assignment, the row and column IDs are maintained
to have the correct length. Usually, this is done by setting numRows
on the ID vector,
but for some objects (for example, data frames)
this might not be appropriate, and they have their own methods.
Functions colnames<-
and rownames<-
simply call
colIds<-
and rowIds<-
, respectively.
as.rectangular
converts any object to a rectangular
data object (usually a data frame), if possible.
is.rectangular
tests whether an object is rectangular.
numRows
and numCols
count the number of rows and columns.
rowIds
and colIds
(and rownames
and
colnames
) return the row and column names or other
identifiers attached to rows and columns.
colnames
and rownames
return the same values as
colIds
and rowIds
, respectively, if do.NULL=T
.
Instead of using names
to replace row names from a matrix,
use rowIds
or dimnames
.
The functions colnames
, rownames
,
colnames<-
, rownames<-
emulate R
functions of the same names.
as.rectangular |
returns |
as.char.rect |
takes a rectangular object and returns a rectangular object (vector or matrix) consisting of character strings, suitable for printing (but not formatted to fixed width). |
is.rectangular |
returns |
subscript2d(x , i , j)
|
is like |
numRows and numCols |
return integers, like |
rowIds and colIds |
return the IDs of the rows and columns.
These are often character vectors, but need not be,
depending on the class of |
colnames and rownames |
return the same values as
|
as.data.frame
, matrix
, Subscript
, nrow
, dimnames
.
x <- 1:10 y <- list(a=1:10, b=11:20) is.rectangular(x) y <- as.rectangular(y) subscript2d(x,3,1) subscript2d(y,4,1) <- 55 numRows(x) numCols(y) <- 3 rowIds(x) <- letters[1:10] colIds(y) z <- cbind(1,1:4) colnames(z) colnames(z) <- colnames(z) rownames(z) <- rownames(z)
x <- 1:10 y <- list(a=1:10, b=11:20) is.rectangular(x) y <- as.rectangular(y) subscript2d(x,3,1) subscript2d(y,4,1) <- 55 numRows(x) numCols(y) <- 3 rowIds(x) <- letters[1:10] colIds(y) z <- cbind(1,1:4) colnames(z) colnames(z) <- colnames(z) rownames(z) <- rownames(z)
High, low, opening, and closing prices and trading volume for the Dow Jones Industrial Average.
The data set has:
The closing price only from 1915 through September 1928.
The high, low, and closing prices from October 1928 through March 9, 1984.
The high, low, opening, and closing prices from March 12, 1984 through December 1986.
The high, low, opening, and closing prices and the trading volume from January 1987 through February 1990.
An object of class timeSeries
with the high, low, open and
close prices stored as a data.frame
.
Downloaded from the College of Business, Ohio State University web site in early 1990.
Exchange rates between the US Dollar and the
British Pound (GBP)
Canadian Dollar (CAD)
German Mark (DEM)
Japanese Yen (JPY)
Swiss Franc (CHF)
in a multi-variate time series.
Data from Andreas S. Weigend, Bernardo A. Huberman, and David E. Rumelhart, "Predicting Sunspots and Exchange Rates with Connectionist Networks", pp. 395-432 in M. Casdagli and S. Eubank, eds, Nonlinear Modeling and Forecasting, Addison-Wesley, 1992.
Interest rate data from the web site of the Federal Reserve Bank, https://www.federalreserve.gov/releases/h15/data.htm, running from 1972 to 1997.
You can find more information on that web site.
Documentation below is derived from the data files.
fed.rate
is a multi-variate time series, with the following
columns:
prime.rate |
Bank Prime Loan Rate, daily including weekends and holidays. |
discount.rate |
Discount Rate for the Federal Reserve Bank of New York, daily including weekends and holidays, which is the simple interest rate at which depository institutions borrow from the Federal Reserve Bank of New York. |
fedfunds.rate |
Federal Funds Effective Rate, daily including weekends and holidays, which is the cost of borrowing immediately available funds, primarily for one day. The effective rate is a weighted average of the reported rates at which different amounts of the day's trading through New York brokers occurs. |
mortgage.rate |
Conventional Mortgage Rates for fixed-rate mortgages from the Federal Home Loan Mortgage Corporation, weekly on Fridays. |
Calculates the high, low, first, and last elements of a vector.
Especially useful for financial trading data in conjunction with
the aggregateSeries
function.
hloc(x)
hloc(x)
x |
a vector for which to calculate high, low, open, and close. |
returns a vector with four elements:
high |
the maximum value in |
low |
the minimum value in |
open |
the first value of |
close |
the last value of |
x
can be an array, but dimensions are ignored.
x <- c(5, 2, 3, 6, 3, 2, 1, 7, 1) hloc(x)
x <- c(5, 2, 3, 6, 3, 2, 1, 7, 1) hloc(x)
Time, type, and size for 10,000 network packets
on a local intranet, just before 5PM on March 27, 1998, as
reported by the Unix snoop command. Size is available only
for packets whose type is "TCP"
.
An object of class timeSeries
with the high, low, open and
close prices stored as a data.frame
.
series
Objects
Accesses the positions of series
objects.
positions(object) positions(object) <- value
positions(object) positions(object) <- value
object |
the object for which to find positions. |
value |
the value to which to set the positions. |
This function can also be used on the left side of an assignment
to set the positions of a series
object.
returns the positions
slot of object
.
seriesData
, timeSeries
, signalSeries
.
x <- signalSeries(pos=1:10, data=11:20) positions(x) positions(x) <- 11:20
x <- signalSeries(pos=1:10, data=11:20) positions(x) positions(x) <- 11:20
A signal of a voice saying the word "wavelet"
, sampled at 11025 Hz.
There are 8192 samples, ranging in time from 0 to approximately
0.7429 seconds.
The signal is of class signalSeries
.
A base class representing ordered data objects, such as time series and signals, that have positions (x values, times), and for each position a set of variables (stored in any rectangular data object).
The series
class holds x positions and variable data.
It is valid only when the lengths of the positions and data match,
and when the data slot is a rectangular object.
seriesVirtual
is a virtual class
corresponding to series
. All of the methods
for series
objects are defined on the corresponding virtual
seriesVirtual
class so they can be inherited easily
by extending classes.
series
has two built-in extending classes:
timeSeries
and signalSeries
. series
is not meant to be used directly. Instead, most users should use the
signalSeries
and timeSeries
classes. Extending classes
should include both series
and seriesVirtual
in their representations.
(ANY
) the variable data, which can be any data object for which
is.rectangular
is TRUE
,
such as a data.frame
, matrix
, or atomic vector.
(positions
) the x values for the variables.
(positions
) the starting x value.
(positions
) the ending x value.
(positions
) future x values used for predictions.
(character
) units for the data.
(character
) title of the data set.
(character
) user-supplied documentation.
(ANY
) attributes slot for arbitrary use.
The series
class has a validity function, seriesValid
.
The access functions positions
and seriesData
can access the positions and data in the object, and they can be used
on the left side of assignments.
There are also methods defined for series
objects for the
following functions:
nrow
ncol
start
end
subscripting
the standard rectangular data functions (see is.rectangular
)
basic arithmetic.
timeSeries
class, signalSeries
class, is.rectangular
.
series
Objects
Accesses the seriesData of series
objects.
seriesData(object) asSeriesData(object) seriesData(object) <- value seriesDataNew() seriesDataValid(object)
seriesData(object) asSeriesData(object) seriesData(object) <- value seriesDataNew() seriesDataValid(object)
object |
the object for which to find |
value |
the value to which to set |
This function can also be used on the left side of an assignment
to set the seriesData
of a series
object.
returns the seriesData
slot of object
.
positions
, timeSeries
, signalSeries
.
x <- signalSeries(pos=1:10, data=11:20) seriesData(x) seriesData(x) <- 1:10
x <- signalSeries(pos=1:10, data=11:20) seriesData(x) seriesData(x) <- 1:10
Returns a lagged/leading timeSeries
or signalSeries
object.
seriesLag(X, k = 1, trim = FALSE, pad = NA)
seriesLag(X, k = 1, trim = FALSE, pad = NA)
X |
an object of class |
k |
the number of positions the new time series or signal series is to lag or lead the input series, with a positive value resulting in a lagged series and a negative value resulting in a leading series. |
trim |
a logical flag. If |
pad |
any padding to fill in the beginning or ending missing values.
The default is |
The difference between shift
and seriesLag
is
that the returned series of shift
is shifted in time (position
)
while the returned series of seriesLag
shifts the entire data slot
but keeps the same time (position
) intact.
They all work for both timeSeries
and signalSeries
objects.
returns a lagged or leading time (signal) series of the original data.
x <- timeSeries(data=data.frame(x=1:10, y=11:20), from="7/4/2000", by="bizdays") seriesLag(x, 1) seriesLag(x, -1)
x <- timeSeries(data=data.frame(x=1:10, y=11:20), from="7/4/2000", by="bizdays") seriesLag(x, 1) seriesLag(x, -1)
timeSeries
Returns the length of a timeSeries
; that is, it returns the number of positions
in the timeSeries
.
seriesLength(x)
seriesLength(x)
x |
an object of class |
returns the length of the timeSeries
.
This function is distinguished from the length
function, which returns
the number of series in the timeSeries
object.
timeSeries
class.
x <- timeSeries(data=data.frame(x=1:10, y=11:20), from="7/4/2000", by="bizdays") seriesLength(x) length(x)
x <- timeSeries(data=data.frame(x=1:10, y=11:20), from="7/4/2000", by="bizdays") seriesLength(x) length(x)
Merges time series or signal objects, making a new object with all the columns of the input objects, and some or all of the rows, depending on how their positions match.
seriesMerge(x1, x2, ..., pos=positions(x1), how, error.how, localzone=FALSE, matchtol=0, suffixes)
seriesMerge(x1, x2, ..., pos=positions(x1), how, error.how, localzone=FALSE, matchtol=0, suffixes)
x1 |
the first object to be merged. |
||||||||||||
x2 |
the second object to be merged. |
||||||||||||
... |
the other objects to be merged. |
||||||||||||
pos |
the positions to align to, or |
||||||||||||
how |
after the positions to align to are determined, Can be one of the following:
The default is |
||||||||||||
error.how |
specifies what to do in the event of an out of bounds error, which can
occur when Can be one of the following:
The default is |
||||||||||||
localzone |
if |
||||||||||||
matchtol |
the tolerance for matching positions. Positions that match within |
||||||||||||
suffixes |
the suffixes to append to the column names that are duplicated between
the various input data objects. The default value is
|
returns a new series
object containing all the columns of all the inputs, and
all the rows of all the inputs, according to the alignment methods described above.
timeSeries
, signalSeries
, positions
, align
, merge
.
a <- signalSeries(pos=1:10, data=data.frame(a = 11:20, b = 5 * (1:10))) b <- signalSeries(pos=5:14, data=data.frame(a = 11:20, b = 5 * (1:10))) seriesMerge(a, b) a <- timeSeries(pos=as(1:10, "timeDate"), data=data.frame(a = 11:20, b = 5 * (1:10))) b <- timeSeries(pos=as(5:14, "timeDate"), data=data.frame(a = 11:20, b = 5 * (1:10))) seriesMerge(a, b, pos="union")
a <- signalSeries(pos=1:10, data=data.frame(a = 11:20, b = 5 * (1:10))) b <- signalSeries(pos=5:14, data=data.frame(a = 11:20, b = 5 * (1:10))) seriesMerge(a, b) a <- timeSeries(pos=as(1:10, "timeDate"), data=data.frame(a = 11:20, b = 5 * (1:10))) b <- timeSeries(pos=as(5:14, "timeDate"), data=data.frame(a = 11:20, b = 5 * (1:10))) seriesMerge(a, b, pos="union")
Returns a time series like the input but shifted in time.
shift(x, k=1)
shift(x, k=1)
x |
a univariate or multivariate regular time series.
Missing values ( |
k |
the number of positions the input series is to lead the new series.
That is, the resulting series is shifted forwards in time;
negative values lag the series backwards in time.
Non-integer values of |
shift
is a generic function.
Its default method calls lag(x,-k).
shift
also has a method
for series
objects,
which works for both timeSeries
and signalSeries
objects.
To align the times of several new-style time series,
use seriesMerge
.
To align the times of several old-style time series, use
ts.intersect
or ts.union
.
To compute a lagged/leading series with same time position
but shifted data slot, use seriesLag
. (seriesLag
also works for both timeSeries
and signalSeries
objects.)
returns a time series with the same data as x
,
but with positions lagged by k
steps.
The shift
function replaces the lag
function,
which illogically had the opposite sign of shifting.
(The lag
function has been retained only because
it is used in other functions.)
seriesMerge
,
lag
,
lag.plot
,
ts.intersect
,
ts.union
.
x <- signalSeries(data=data.frame(a=1:10, b=letters[1:10]), positions=1:10) x5 <- shift(x,5) seriesMerge(x, x5, pos="union")
x <- signalSeries(data=data.frame(a=1:10, b=letters[1:10]), positions=1:10) x5 <- shift(x,5) seriesMerge(x, x5, pos="union")
signalSeries
object
Creates an object of class signalSeries
signalSeries(data, positions., units, units.position, from = 1, by = 1)
signalSeries(data, positions., units, units.position, from = 1, by = 1)
data |
( |
positions. |
( |
units |
( |
units.position |
( |
from |
the start of the sequence. |
by |
the increment for the sequence. |
an object of class "signalSeries"
.
See the
signalSeries
class help file
for the names and structure of the slots in the object.
signalSeries
class.
signalSeries(pos=1:10 , data=1:10) signalSeries(data=data.frame(x=1:10, y=11:20), from=2, by=2)
signalSeries(pos=1:10 , data=1:10) signalSeries(data=data.frame(x=1:10, y=11:20), from=2, by=2)
Represents non-calendar time series and signal objects.
The signalSeries
class inherits from the series
and seriesVirtual
classes. It has slots that hold x positions and variable data
inherited from the series
class.
A signalSeries
object is valid only when the lengths of the positions and data match, the data is a rectangular object,
and the positions
slot holds a positionsNumeric
object.
All slots except the last, units.position
,
come from the series
object.
(ANY
) the variable data, which can be any data object for which
is.rectangular
is TRUE
,
such as a data.frame
, matrix
, or atomic vector.
(positions
) the x values for the variables, which must be
of type positionsNumeric
.
(positions
) the starting x value.
(positions
) the ending x value.
(positions
) future x values used for predictions.
(character
) the units for the data.
(character
) the title of the data set.
(character
) user-supplied documentation.
(ANY
) the attributes slot for arbitrary use.
(character
) the units for the positions
slot.
You can create objects of class signalSeries
using the new
function, in
which case they are set up to be empty. Alternatively, you can create objects
of class signalSeries
using the signalSeries
function.
These objects can be subscripted and used in mathematical operations much like data frames or matrices.
series
class, signalSeries
, is.rectangular
.
Treasury Bill auction rate data running from 1980 to 1997 for 3 month, 6 month, and 1 year durations.
Three separate timeSeries
objects with Treasury Bill auction rates:
Average of interest rate bids accepted in regular treasury auctions of 13-week bills (also known as 3-month bills). Currently, the auctions are held each Monday for bills to be issued the ensuing Thursday, in the absence of holidays.
Average of interest rate bids accepted in regular treasury auctions of 26-week bills (also known as 6-month bills). Currently, the auctions are held each Monday for bills to be issued the ensuing Thursday, in the absence of holidays.
Average of interest rate bids accepted in regular treasury auctions of 52-week bills (also known as 1-year bills). Currently, the auctions are held at roughly monthly intervals.
From the web site of the Federal Reserve Bank, https://www.federalreserve.gov/releases/h15/data.htm.
Treasury Bond futures trading data: high and low prices over 20-minute intervals from January 7, 1994, to February 3, 1995.
It is used to illustrate a drop in bond prices that occurred in 1994.
An object of class timeSeries
with the high and low prices
stored as a data.frame
.
Downloaded from the Fisher College of Business, Ohio State University web site in early 1996.
Treasury Constant Maturity Curve data running from 1982 to 1997. The Constant Maturity Curve data come from yield curves constructed by the U.S. Treasury Department from the yields of actively traded issues adjusted to constant maturities.
tcm.curve
is a multivariate timeSeries
object with the following columns:
Three-month rate.
Six-month rate.
One-year rate.
Two-year rate.
Three-year rate.
Five-year rate.
Seven-year rate.
Ten-year rate.
Constructed from the 20-year Treasury department numbers, based on the 20-year bond through December 1986 (at which time the 20-year bond was discontinued), and from the new computation starting in October of 1993 based on outstanding bonds with approximately 20 years remaining to maturity. There is no data between 1987 and September 1992.
Thirty-year rate.
An unweighted average of rates on all outstanding bonds neither due nor callable in less than 10 years, also calculated by the Treasury Department.
From the web site of the Federal Reserve Bank, https://www.federalreserve.gov/releases/h15/data.htm.
timeSeries
Object
Creates an object of class timeSeries
.
timeSeries(data, positions., units., from = timeCalendar(d = 1, m = 1, y = 1960), by = "days", k.by = 1, align.by = FALSE, week.align = NULL)
timeSeries(data, positions., units., from = timeCalendar(d = 1, m = 1, y = 1960), by = "days", k.by = 1, align.by = FALSE, week.align = NULL)
data |
( |
positions. |
( |
units. |
( |
from |
the starting value of the sequence. A |
by |
the spacing between successive values in the sequence. Can be
a Alternatively, it can be one of the following character strings:
giving the time units of intervals between values in the sequence. |
k.by |
a non-zero integer giving the width of the interval between consecutive
values in the sequence in terms of the units given in |
align.by |
a logical value. If |
week.align |
if
In either case, the |
an object of class "timeSeries"
.
See the
timeSeries
class help file
for the names and structure of the slots in the object.
timeSeries
class.
timeSeries(pos=timeCalendar(d=1:10), data=1:10) timeSeries(data=data.frame(x=1:10, y=11:20), from="7/4/2000", by="bizdays")
timeSeries(pos=timeCalendar(d=1:10), data=1:10) timeSeries(data=data.frame(x=1:10, y=11:20), from="7/4/2000", by="bizdays")
Represents calendar time series objects.
The timeSeries
class inherits series
and seriesVirtual
.
From series
, it inherits slots that hold x positions and variable data.
A timeSeries
object is valid only when the lengths of the positions and
data match, the data
slot is rectangular,
and the positions
slot holds a positionsCalendar
object.
All slots except the last two, fiscal.year.start
and type
,
are inherited from the base series
class.
(ANY
) the variable data,
which can be any data object for which is.rectangular
is TRUE
,
such as a data.frame
, matrix
, or atomic vector.
(positions
) the x values for the variables,
which must be of type positionsCalendar
.
(positions
) the starting x value.
(positions
) the ending x value.
(positions
) future x values used for predictions.
(character
) the units for the data.
(character
) the title of the data set.
(character
) user-supplied documentation.
(ANY
) the attributes slot for arbitrary use.
(numeric
) the month number for fiscal year start.
(character
) the type of time series.
You can create objects of class timeSeries
using the
new
function, in which case they are set up to be empty
and have their fiscal year starting in January. Alternatively, you
can create objects of class timeSeries
using the timeSeries
function.
These can be subscripted and used in mathematical operations much like data frames or matrices.
series
class, timeSeries
,
is.rectangular
.
ts
Objects
Converts an old ts
object to a signalSeries
object.
ts.update(x)
ts.update(x)
x |
the time series to convert. |
returns a signalSeries
object with equivalent positions.
ts.update(ts(1:10))
ts.update(ts(1:10))
Makes a union of numeric or calendar positions (that is, positions of
series objects (which can be numeric), time vectors, or sequences)
objects using localzone
and matchtol
as in the seriesMerge
and align
functions.
unionPositions(..., localzone = FALSE, matchtol = 0)
unionPositions(..., localzone = FALSE, matchtol = 0)
... |
the positions objects to be joined. |
localzone |
a logical value. If |
matchtol |
the tolerance for matching positions. Positions that match within |
Returns a new positions object containing all of the input positions,
with duplicates (as defined by matchtol
and localzone
) removed.
Returns numeric(0)
if no ...
arguments are given.
positions
,
align
,
seriesMerge
.
unionPositions(1:10, 5:20) unionPositions(1:10, 5.1:20.1, matchtol=.3) unionPositions(timeCalendar(d=1:10), timeCalendar(d=5:20)) unionPositions(timeCalendar(d=1:10, zone="PST"), timeCalendar(d=5:20, zone="EST")) unionPositions(timeCalendar(d=1:10, zone="PST"), timeCalendar(d=5:20, zone="EST"), localzone=TRUE)
unionPositions(1:10, 5:20) unionPositions(1:10, 5.1:20.1, matchtol=.3) unionPositions(timeCalendar(d=1:10), timeCalendar(d=5:20)) unionPositions(timeCalendar(d=1:10, zone="PST"), timeCalendar(d=5:20, zone="EST")) unionPositions(timeCalendar(d=1:10, zone="PST"), timeCalendar(d=5:20, zone="EST"), localzone=TRUE)