momentum_to_wide: Momentum Data Frame to Wide Format

View source: R/momentum_to_wide.R

momentum_to_wideR Documentation

Momentum Data Frame to Wide Format

Description

Transforms a data frame returned by momentum() to wide format with the following columns:

  • most_similar: name of the variable with the highest contribution to similarity (most negative value in the importance column) for each pair of time series.

  • most_dissimilar: name of the variable with the highest contribution to dissimilarity (most positive value in the importance column) for each pair of time series.

  • importance__variable_name: contribution to similarity (negative values) or dissimilarity (positive values) of the given variable.

  • psi_only_with__variable_name: dissimilarity of the two time series when only using the given variable.

  • psi_without__variable_name: dissimilarity of the two time series when removing the given variable.

Usage

momentum_to_wide(df = NULL, sep = "__")

Arguments

df

(required, data frame) Output of momentum(), momentum_ls(), or momentum_dtw(). Default: NULL

sep

(required, character string) Separator between the name of the importance metric and the time series variable. Default: "__".

Value

data frame

See Also

Other momentum_support: momentum_aggregate(), momentum_boxplot(), momentum_model_frame(), momentum_spatial(), momentum_stats()

Examples


tsl <- tsl_initialize(
  x = distantia::albatross,
  name_column = "name",
  time_column = "time"
) |>
  tsl_transform(
    f = f_scale_global
  )

#importance data frame
df <- momentum(
  tsl = tsl
)

df

#to wide format
df_wide <- momentum_to_wide(
  df = df
)

df_wide


distantia documentation built on April 4, 2025, 5:42 a.m.