An Introduction to the RecordTest Package

Introduction

The RecordTest package (Inference Tools in Time Series Based on Record Statistics) contains functions to visualize the behavior of the record occurrence, functions to calculate a wide variety of distribution-free tests for trend in location and tools to pre-process a time series in order to study its records.

Install RecordTest using

install.packages("RecordTest")

The introductory theory for the package is at

help("RecordTest-package")

Here, the main purpose of the package is developed as well as the definitions of the record statistics and an outline of the functions available in the package.

RecordTest has several functions that attempt to test the classical record model which assumes randomness in its variables, that is, they are independent and identically distributed, by means of hypothesis tests and plots.

Data

To begin with, RecordTest has a benchmark dataset TX_Zaragoza containing the time series TX of daily maximum temperature at Zaragoza (Spain), from 01/01/1953 to 31/12/2018 measured in tenths of a degree Celsius.

Data preparation

As a preview, the temperature series TX_Zaragoza$TX is drawn highlighting its upper and lower records.

library(RecordTest)
library(ggpubr) # To join plots
data(TX_Zaragoza)

records(TX_Zaragoza$TX, alpha = c(1, 1, 0.05, 1))

A large number of upper records are observed in the first observations and very few lower records. Far from thinking that there is a big trend in the data, what happens is that this series has a strong seasonal component and serial correlation.

To solve the above problems, splitting the observed series into \(M\) independent series is especially useful in the presence of serial and seasonal component correlation. series_split splits TX_Zaragoza$TX into 365 subseries, each corresponding to each day of the year. series_uncor selects the larger number of columns or series that are not correlated with their adjacent series.

TxZ <- series_split(TX_Zaragoza$TX, Mcols = 365)

TxZ <- TxZ[, series_uncor(TxZ)]

Since the observed series is measured and rounded to tenths of a degree Celsius, we are going to untie the possible records by adding a random value from a Uniform and independent distribution for each observation.

TxZ <- series_untie(TxZ, a = -0.5, b = 0.5, seed = 23)