TS_LG_object: Prepare a time series for a local Gaussian inspection

Description Usage Arguments Details Value

View source: R/TS_LG_object.R


Prepare a time series for a local Gaussian inspection


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



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 variates along the columns. (The program terminates if the number of rows are lower than the number of columns.)


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.


The main directory into which the information will be stored. Default value "~/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 create it, but otherwise it's 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.


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.


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.


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.


This function will take care of some file-handling before it returns a two-component list to the work-flow. The first component TS_done_before is a logic value to inform the use whether or not the time series from TS_data already was stored in the folder main_dir. The second component, result, is 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 Dec. 18, 2018, 2:31 a.m.