sl_utils {pcts}R Documentation

Functions for some basic operations with seasons

Description

Functions for some basic operations with seasons.

Usage

toSeason(t, period, t1 = 1, from = 1)
toSeasonPair(t, s, period, ...)
ttTosl(r, period)
ttmatToslPairs(i, j, period)

Arguments

r

covariance matrix, see ‘Details’.

t

a vector of integers, representing times.

s

a vector of integers, representing times.

period

the number of seasons.

t1

time corresponding to the first season, an integer number.

from

1 or 0, depending on whether the season numbers start from 1 or 0.

i

a vector of integers.

j

a vector of integers.

...

todo: describe!

Details

ttmatToslPairs(i,j,period) transforms time-time pairs to season-lag pairs. The time pairs are obtained by pairing each element of i with each element of j. A four column matrix is created with one row for each pair (t,s), such that t=i[m] and s=j[n] for some m and n. The row is m, n, s, l, where (s,l) is the season-lag pair corresponding to (t,s).

ttTosl(r,period) converts autocovariances given in a covariance matrix (i.e. in “tt” form) to the “sl” form. The result is a period x (maxlag+1) matrix, where maxlag is the maximal lag available in r. Entries for which no values are available are filled with NA's. Warning is given if contradictory entries are found (i.e. if r is not from a periodically correlated process with the given period).

toSeason(t,period,t1=1,from=1) returns the season corresponding to t. t1 is a time (integer) whose season is the first season, from is 1 if the numbering of seasons is 1,2,...,period, or 0 if the numbering of seasons is 0,1,...,period-1. Other values for from are not admissible (but not checked). Note: some of the functions in this package implicitly assume that t1=1 and from=1.

toSeasonPair(t,s,period) converts the “tt” pair t,s to “sl” pair and returns the result in the form of a list with elements season and lag. Currently t and s must be scalars.

pc.omitneg helps to implement dropping of negative indices in season-lag objects. It returns its first argument, lags, if all of its elements are non-negative. Otherwise, all elements of lags must be non-positive. In this case the function creates the vector 0:maxlag and drops the elements specified by lags. Note that the default indexing will not work properly since zero elements in an index are omitted (and there are such indices in season-lag objects).

Value

for ttmatToslPairs, a matrix with four columns;

for ttTosl, a matrix with period rows;

for toSeason(t,period,t1=1,from=1), a vector of integers;

for toSeasonPair(t,s,period), a list with elements season and lag;

for pc.omitneg, a vector of lags (non-negative integers).

Note

2013-10-24 - Corrected the description of the return value of ttmatToslPairs. It incorrectly stated that the first two columns are "tt" pair (they are actually indices in i and j).

Author(s)

Georgi N. Boshnakov

References

Boshnakov GN, Iqelan BM (2009). “Generation of time series models with given spectral properties.” J. Time Series Anal., 30(3), 349–368. ISSN 0143-9782, doi:10.1111/j.1467-9892.2009.00617.x.

Examples

# ttmatToslPairs
ttmatToslPairs(3, 3, 4)  # 1, 1, 3, 0
ttmatToslPairs(3, 2, 4)  # 1, 1, 3, 1

ttmatToslPairs(1:4, 1:4, 4)

ttmatToslPairs(3:4, 3:4, 4)

# ttTosl -  :todo:

# toSeason
toSeason(1:10, 4)           # 1 2 3 4  1 2 3 4  1 2
toSeason(1:10, 4, from = 0) # 0 1 2 3  0 1 2 3  0 1

## first data is for 3rd quarter
toSeason(1:10, 4, t1 = 3)  # 3 4 1 2 3 4 1 2 3 4

# toSeasonPair
toSeasonPair(3, 3, period=4) # season=3, lag = 0
toSeasonPair(8, 8, period=4) # season=4, lag = 0

toSeasonPair(3, 2, period=4) # season=3, lag = 1
toSeasonPair(7, 6, period=4) # same

#### # pc.omitneg
#### pc.omitneg(0:5,10) # 0:5, unchaged since all values >= 0
#### 
#### pc.omitneg(-(0:5),10) # 6:10, works like
#### (0:10)[-(0:5 +1)]     # same
#### 
#### # don't mix positive and negative numbers in pc.omitneg
#### \dontrun{pc.omitneg(c(0,2,3,-4,5), 10)}

[Package pcts version 0.15.7 Index]