TS_LG_object: Prepare a time series for a local Gaussian inspection

TS_LG_objectR Documentation

Prepare a time series for a local Gaussian inspection

Description

Prepare a time series for a local Gaussian inspection

Usage

TS_LG_object(
  TS_data,
  details = NULL,
  main_dir = c("~", "LG_DATA"),
  save_dir = NULL,
  .remove_ties = TRUE
)

Arguments

TS_data

The time series data we will work upon. This can either be an observed or a simulated time series. If TS_data are of class "TS_simulated", i.e. it has been generated by TS_sample, then the information stored in it will be used to create save_dir. Note that TS_data can be univariate or multivariate. A univariate time series can be given as a vector, whereas a multivariate must have the observations along the rows and the variables along the columns. (The program terminates if the number of rows are lower than the number of columns.)

details

This can be used to add a reminder that will be shown under the interactive investigation later on. The default value NULL will imply that no information is shown.

main_dir

The main directory into which the information will be stored. Default value c("~", "LG_DATA"), i.e. a specially designed directory in the home directory of your file-system. If the proposed default directory does not exists, then TS_LG_object will ask for permission to create it, but otherwise it is a requirement that only existing directories can be used. This is done as a precaution against accidentally ending up with unintended data-directories all over the file-system. Note that the default value is given as a vector in order to avoid issues related to operative system dependent values for the file separator. The argument can also be given as a character-string.

save_dir

The sub-directory of main_dir where all the stuff related to TS_data will be saved. Default value NULL, but with the following defaults in the code for what to replace it with: When TS_data has been created by TS_sample, a value for save_dir will be created from the information in TS_data, and any attempt from the user to create another name will be outright ignored. If no value is given for save_dir (and none can be computed from TS_data), then the default value from LG_default will be used to create save_dir. If the user specifies save_dir (for a time-series not originating from TS_sample), then that name will be used, but only if no previous directories happens to have that name too – if that should be the case, the program will terminate and inform the user about it.

.remove_ties

A logical value, default TRUE, in which case the presence of ties will trigger a minor perturbation of the data. Note: Whenever this happens, set.seed(1) will be used in order to ensure reproducibility.

Details

This function will for a given (sample from a) time series create a directory that will be used to store all the files that occur during the local Gaussian analysis. The function will in addition create a local info-file to take care of the subsequent bookkeeping. Moreover, this function will also maintain a global info-file in the main_dir-directory, where information about the top-level part of the directory-structure is stored – in order to avoid the despicable situation that more than one directory stores information about the exact same set of data. The sample will be nudged a tiny bit (always using 1 as the seed-value) if ties are detected in it. The algorithm ensures that this nudge is of a small order compared to the original values.

Value

This function will take care of some file-handling before it returns a two-component list to the work-flow, containing the following nodes:

TS_done_before

A logical value that reveals whether or not the time series from TS_data already was stored in the folder main_dir.

result

A list whose format depends upon whether or not TS_data was created by TS_sample – and some of the content are only connected to the internal work-flow of this function. The four parts of result that always is present is TS_key (the origin of the time series), TS (the values), N (the number of observations), and save_dir (the path to the save-directory). These four values will be used by the functions that analyses TS based upon Local Gaussian Approximations and Local Gaussian Spectral Densities.


LAJordanger/localgaussSpec documentation built on May 6, 2023, 4:31 a.m.