state_space_reconstruction_for_sve: State Space Reconstruction for Single View Embedding (and...

View source: R/state_space_reconstruction_for_sve.R

state_space_reconstruction_for_sveR Documentation

State Space Reconstruction for Single View Embedding (and then Multiview)

Description

Given data of variables and a list of lags, create matrix with rows being time and columns being each dimension in the state space; i.e. (S.10) from our first manuscript. Absolute numbers of the variables are first differenced (for each column, i.e. each original variable), then standardised (centred and scaled), and then the lagged matrix is created.

Usage

state_space_reconstruction_for_sve(
  data,
  lags,
  response_only = FALSE,
  max_allowed_correlation = 0.999999
)

Arguments

data

[matrix()] or [data.frame()] with variables as named columns

lags

[list()] of a named vector of lags for each explanatory variable

response_only

if TRUE then 'data' can only have one column and 'lags' a list of the form 'lags = list(R_t = 0)' (only the response variable and must be lag of 0). The variable specified is considered the response variable and is being rescaled and renamed here, and renamed, for example, 'R_t_s'.

max_allowed_cor

maximum allowed correlation between two axes (actually once their lagged, could change it to raw data if needed), if the correlation is greater than this then function stops and gives an error. TODO change to just giving NA in results maybe.

Details

Rewriting from 'state_space_reconstruction()' to include all the steps we gave in Appendix S1 of first manuscript, and to not have the response as an output (as it was getting used in the distance calculations later).

If this function changes then need to update 'untransform_predictions()' also. This function is called from 'single_view_embedding_for_sve()'.

Value

[state_space_reconstruction()] [matrix()] with lagged variables that are first differenced and then centred on their means and divided by their respective standard deviations, with automatically generated column names in the following style: for a variable called 'S_t' and lags of 0, 1, 2, the scaled variable and lagged names are 'S_t_s_0, 'S_t_s_1, and 'S_t_s_2, where the last number is the lag and 's' stands for scaled. OR if there is too high a correlation between lags to be used in the reconstruction, then just return a single NA and use that in 'single_view_embedding_for_sve()'.

Author(s)

Andrew M. Edward and Luke A. Rogers

Examples

## Not run: 
d <- data.frame(x = 1:10, y = 11:20)
state_space_reconstruction(d, lags = list(y = c(0, 1, 2, 3)))

# If thinking of x as being the response variable, but not having it in the
# embedding, then do
response_scaled <- state_space_reconstruction_for_sve(d, lags = list(x = 0))
names(response_scaled) <- substr(names(response_scaled), 1,
  nchar(names(response_scaled)) - 2)   TODO check these - think done in
  function now


## End(Not run)

luke-a-rogers/pbsedm documentation built on June 3, 2024, 5:20 a.m.