pcts {pcts} | R Documentation |
Create objects from periodic time series classes
Description
Create objects from periodic time series classes.
Usage
pcts(x, nseasons, start, ..., keep = FALSE)
Arguments
x |
a time series. |
nseasons |
number of seasons. This argument is ignored by some methods. |
start |
the starting time of the time series, can be a |
keep |
if |
... |
further arguments to be passed on to methods. |
Details
pcts
creates periodic time series objects inheriting from
"PeriodicTimeSeries"
. The particular class depends on arguments
x
and, in some cases, keep
. The idea is that in normal
use the user does not care about the particular class. See section
‘Methods’ for further details.
Familiar functions from base-R work with the objects created by
pcts
. The help page window
describes such methods
and gives examples.
There are also methods for as
for conversion to and from the
time series classes defined in package pcts.
Value
an object inheriting from "PeriodicTimeSeries"
, the defaults
are "PeriodicTS"
for univariate and "PeriodicMTS"
and
for multivariate time series.
Methods
signature(x = "numeric", nseasons = "missing")
signature(x = "numeric", nseasons = "numeric")
signature(x = "numeric", nseasons = "BasicCycle")
-
Creates an object of class
"PeriodicTS"
, the native class for univariate periodic time series in package "pcts". signature(x = "matrix", nseasons = "missing")
signature(x = "matrix", nseasons = "numeric")
signature(x = "matrix", nseasons = "BasicCycle")
-
Creates an object of class
"PeriodicMTS"
, the native class for multivariate periodic time series in package "pcts". signature(x = "data.frame", nseasons = "ANY")
-
Currently this just converts
x
to matrix and callspcts
recursively. See the methods withx = "matrix"
in the signature. signature(x = "ts", nseasons = "missing")
signature(x = "ts", nseasons = "numeric")
-
If
keep = TRUE
creates an object of class"PeriodicTS_ts"
, otherwise the result is from"PeriodicTS"
. The number of seasons is taken from the"mts"
object. signature(x = "mts", nseasons = "missing")
signature(x = "mts", nseasons = "numeric")
-
If
keep = TRUE
creates an object of class"PeriodicMTS_ts"
, otherwise the result is from"PeriodicMTS"
. The number of seasons is taken from the"ts"
object. signature(x = "xtsORzoo", nseasons = "missing")
-
x
needs to be a regular time series, possibly with missing values for some times (technically,zoo::is.regular(x)
should give TRUE). For daily time series, the cycle is taken to be day of week or a subcycle of it, most commonly Monday-Friday. The implementation of this method is incomplete but for daily data should work as described.
Author(s)
Georgi N. Boshnakov
See Also
PeriodicTS
,
PeriodicMTS
, the two main periodic time series
classes in the package;
dataFranses1996
, Fraser2017
,
four_stocks_since2016_01_01
for further examples;
window
for extraction of subsets;
pcApply
for applying a function to each season;
Vec
,
tsVec
,
pcMatrix
for extraction of the core data
Examples
## convert a ts object, no need for further info
pcts(AirPassengers, 12)
## numeric
v24 <- rnorm(24)
pcts(v24, nseasons = 4) # generic seasons
pcts(v24, nseasons = BuiltinCycle(4)) # Quarter/Year
ts1 <- pcts(v24, nseasons = BuiltinCycle(4), c(2006, 1)) # Quarter/Year with dates
## select subset of the seasons
window(ts1, seasons = 3:4)
## matrix, multivariate pcts
m24 <- matrix(v24, ncol =3)
colnames(m24) <- c("A", "B", "C")
pcts(m24, nseasons = 4) # generic seasons
pcts(m24, nseasons = BuiltinCycle(4)) # Quarter/Year
mts1 <- pcts(m24, nseasons = BuiltinCycle(4), c(2006, 1)) # Quarter/Year with dates
mts1
## select subset of the seasons for mutivariate
window(mts1, seasons = 3:4)