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:
: Dissimilarity data frame generated by
momentum()
,momentum_ls()
, ormomentum_dtw()
. The output model frame will have as many rows as this data frame.: Data frame with static descriptors of the time series. These descriptors are converted to distances between pairs of time series via
distance_matrix()
.: List defining composite predictors. This feature allows grouping together predictors that have a common meaning. For example,
composite_predictors = list(temperature = c("temperature_mean", "temperature_min", "temperature_max")
generates a new predictor named "temperature", which results from computing the multivariate distances between the vectors of temperature variables of each pair of time series. Predictors in one of such groups will be scaled before distance computation if their maximum standard deviations differ by a factor of 10 or more.
The resulting data frame contains the following columns:
-
x
andy
: names of the pair of time series represented in the row. response columns.
predictors columns: representing the distance between the values of the given static predictor between
x
andy
.(optional)
geographic_distance
: Ifpredictors_df
is ansf
data frame, then geographic distances are computed viasf::st_distance()
.
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 |
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 |
composite_predictors |
(optional, list) list defining composite predictors. For example, |
scale |
(optional, logical) if TRUE, all predictors are scaled and centered with |
distance |
(optional, string) Method to compute the distance between predictor values for all pairs of time series in |
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