momentum_model_frame {distantia}R Documentation

Dissimilarity Model Frame

Description

This function generates a model frame for statistical or machine learning analysis from these objects:

The resulting data frame contains the following columns:

This function supports a parallelization setup via future::plan().

Usage

momentum_model_frame(
  response_df = NULL,
  predictors_df = NULL,
  composite_predictors = NULL,
  scale = TRUE,
  distance = "euclidean"
)

Arguments

response_df

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

predictors_df

(required, data frame or sf data frame) data frame with numeric predictors for the the model frame. Must have a column with the time series names in response_df$x and response_df$y. If sf data frame, the column "geographic_distance" with distances between pairs of time series is added to the model frame. Default: NULL

composite_predictors

(optional, list) list defining composite predictors. For example, composite_predictors = list(a = c("b", "c")) uses the columns "b" and "c" from predictors_df to generate the predictor a as the multivariate distance between "b" and "c" for each pair of time series in response_df. Default: NULL

scale

(optional, logical) if TRUE, all predictors are scaled and centered with scale(). Default: TRUE

distance

(optional, string) Method to compute the distance between predictor values for all pairs of time series in response_df. Default: "euclidean".

Value

data frame: with the attribute "predictors".

See Also

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

Examples


#Fagus sylvatica dynamics in Europe
tsl <- tsl_initialize(
  x = fagus_dynamics,
  name_column = "name",
  time_column = "time"
)

#dissimilarity analysis
df <- momentum_ls(tsl = tsl)

#generate model frame
model_frame <- momentum_model_frame(
  response_df = df,
  predictors_df = fagus_coordinates,
  scale = TRUE
)

head(model_frame)

#names of response and predictors
#and an additive formula
#are stored as attributes
attributes(model_frame)$predictors


[Package distantia version 2.0.0 Index]