series_uncor: Subset of Uncorrelated Series

View source: R/series_uncor.R

series_uncorR Documentation

Subset of Uncorrelated Series

Description

Given a matrix this function extracts a subset of uncorrelated columns (see Details).

Usage

series_uncor(
  X,
  test.fun = stats::cor.test,
  return.value = c("series", "indexes"),
  type = c("adjacent", "all"),
  first.last = TRUE,
  m = 1,
  alpha = 0.05,
  ...
)

Arguments

X

A numeric matrix (or data frame) where the uncorrelated vectors are extracted from.

test.fun

A function that tests the correlation (it could also test dependence or other feature that is desired to test on the columns). It must take as arguments two numeric vectors of the same length to apply the test to. The alternative hypothesis between both vectors is that the true correlation is not equal to 0 (or that they are dependent, etc). The return value should be a list object with a component p.value with the p-value of the test. Default is cor.test. Other function to test tail dependence is found in the package extRemes as taildep.test.

return.value

A character string indicating the return of the function, "series" for a matrix with uncorrelated columns or "indexes" for a vector with the position of the uncorrelated columns in X.

type

A character string indicating the type of uncorrelation wanted between the extracted series (or columns), "adjacent" or "all" (see Details).

first.last

Logical. Indicates if the first and last columns have also to be uncorrelated (when type = "adjacent").

m

Integer value giving the starting column.

alpha

Numeric value in (0,1). It gives the significance level. For cor.test the alternative hypothesis is that the true correlation is not equal to 0.

...

Further arguments to be passed to test.fun function.

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.

Given a matrix X considered as a set of M^* vectors, which are the columns of X, this function extracts a subset of uncorrelated vectors (columns), using the following procedure: starting from column m, the test test.fun is applied to study the correlation between columns depending on argument type.

If type = "adjacent", the test is computed between m and \code{m} + 1, \code{m} + 2, \ldots and so on up to find a column \code{m} + k which is not significantly correlated with column m. Then, the process is repeated starting at column \code{m} + k. All columns are checked.

When the first and last columns may not have a significant correlation, where m is the first column, the parameter first.last should be FALSE. When the first and last columns could be correlated, the function requires first.last = TRUE.

If type = "all", the procedure is similar as above but the new kept column cannot be significantly correlated with any other column already kept, not only the previous one. So this option results in a fewer number of columns.

Value

A matrix or a vector as specified by return.value.

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_split, series_ties, series_untie

Examples

# Split Zaragoza series
TxZ <- series_split(TX_Zaragoza$TX)

# Index of uncorrelated columns depending on the criteria
series_uncor(TxZ, return.value = "indexes", type = "adjacent")
series_uncor(TxZ, return.value = "indexes", type = "all")

# Return the set of uncorrelated vectors
ZaragozaSeries <- series_uncor(TxZ)


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