Learn R Programming

patterncausality (version 0.2.1)

optimalParametersSearch: Search for Optimal Parameters in Pattern Causality Analysis

Description

Searches for the optimal embedding dimension (E) and time delay (tau) to maximize the accuracy of causality predictions in a dataset. This function implements a grid search approach to evaluate different parameter combinations.

Usage

optimalParametersSearch(
  Emax,
  tauMax,
  metric = "euclidean",
  distance_fn = NULL,
  state_space_fn = NULL,
  dataset,
  h = 0,
  weighted = FALSE,
  relative = TRUE,
  verbose = FALSE
)

Value

A pc_params object containing:

  • accuracy_summary: A data frame summarizing the accuracy for each parameter combination.

  • computation_time: The time taken for the analysis.

  • parameters: A list of the input parameters used.

Arguments

Emax

Positive integer > 2; maximum embedding dimension to test

tauMax

Positive integer; maximum time delay to test

metric

Character string; distance metric for causality analysis ('euclidean', 'manhattan', 'maximum'). Defaults to "euclidean". Ignored if distance_fn is provided.

distance_fn

Optional custom distance function; takes two numeric vectors as input and returns a numeric distance. (default: NULL)

state_space_fn

Optional custom function for state space reconstruction; takes a numeric vector and parameters E and tau as input and returns a reconstructed state space. (default: NULL)

dataset

Numeric matrix; each column represents a time series.

h

Positive integer; prediction horizon.

weighted

Logical; if TRUE, weighted causality analysis is performed.

relative

Logical; if TRUE calculates relative changes ((new-old)/old), if FALSE calculates absolute changes (new-old) in signature space. Default is TRUE.

verbose

Logical; if TRUE, prints progress information. (default: FALSE)

Details

Search for Optimal Parameters in Pattern Causality Analysis

This function evaluates each combination of embedding dimension and time delay for their effectiveness in detecting different types of causality:

  • Total causality: Overall causal relationship strength

  • Positive causality: Direct positive influences

  • Negative causality: Direct negative influences

  • Dark causality: Complex or indirect causal relationships

Examples

Run this code
# \donttest{
data(climate_indices)
dataset <- climate_indices[, -1]
optimalParams <- optimalParametersSearch(
  Emax = 3, 
  tauMax = 3, 
  metric = "euclidean",
  dataset = dataset,
  h = 1,
  weighted = FALSE
)
print(optimalParams)
# }

Run the code above in your browser using DataLab