series_split: Split Series

View source: R/series_split.R

series_splitR Documentation

Split Series

Description

The vector X of length T is broken into Mcols blocks, each part containing T/\code{Mcols} elements.

If the vector X represents consecutive daily values in a year, then Mcols = 365 is preferred. This function rearranges X into a matrix format, where each column is the vector of values at the same day of the year. For monthly data in a year, Mcols = 12 should be used.

Usage

series_split(X, Mcols = 365)

Arguments

X

A numeric vector.

Mcols

An integer number, giving the number of columns in the final matrix.

Details

This function is used in the data preparation (or pre-processing) often required to apply the exploratory and inference tools based on theory of records within this package when the time series presents seasonality.

This function transforms a vector into a matrix, applying the following procedure: the first row of the matrix is built of the first Mcols elements of the vector, the second row by the Mcols following elements, and so on. The length of the vector must be a multiple of Mcols (see Note otherwise).

In the case of a vector of daily values, Mcols is usually 365, so that the first column corresponds to all the values observed at the 1st of January, the second to the 2nd of January, etc.

If X_{t,m} represents the value in day m of year t, then if

\code{X} = (X_{1,1},X_{1,2},\ldots,X_{1,365},X_{2,1},X_{2,2},\ldots,X_{T,365}),

applying series_split to X returns the following matrix:

\left( \begin{array}{cccc} X_{1,1} & X_{1,2} & \cdots & X_{1,365} \\ X_{2,1} & X_{2,2} & \cdots & X_{2,365} \\ \vdots & \vdots & & \vdots \\ X_{T,1} & X_{T,2} & \cdots & X_{T,365} \end{array} \right)_{T \times 365}.

Value

A matrix with Mcols columns.

Note

series_double can be implemented for the same purpose as this function but without requiring that the length of X be divisible by Mcols. It removes the first elements of X until its length is divisible by Mcols.

Author(s)

Jorge Castillo-Mateo

References

Cebrián AC, Castillo-Mateo J, Asín J (2022). “Record Tests to Detect Non Stationarity in the Tails with an Application to Climate Change.” Stochastic Environmental Research and Risk Assessment, 36(2), 313-330. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1007/s00477-021-02122-w")}.

See Also

series_double, series_record, series_rev, series_ties, series_uncor, series_untie

Examples

series_split(1:100, Mcols = 10)

TxZ <- series_split(TX_Zaragoza$TX)
dim(TxZ)


RecordTest documentation built on Aug. 8, 2023, 1:09 a.m.