detecting-layers | R Documentation |
Detects the number of information layers present in trade-data using the algorithms in \insertCiteErsan2016;textualPINstimation, \insertCiteErsan2022a;textualPINstimation, and \insertCiteGhachem2022;textualPINstimation.
detectlayers_e(data, confidence = 0.995, correction = TRUE)
detectlayers_eg(data, confidence = 0.995)
detectlayers_ecm(data, hyperparams = list())
data |
A dataframe with 2 variables: the first corresponds to buyer-initiated trades (buys), and the second corresponds to seller-initiated trades (sells). |
confidence |
A number from |
correction |
A binary variable that determines whether the
data will be adjusted prior to implementing the algorithm of
\insertCiteErsan2016;textualPINstimation. The default value is |
hyperparams |
A list containing the hyperparameters of the |
The argument 'data' should be a numeric dataframe, and contain
at least two variables. Only the first two variables will be considered:
The first variable is assumed to correspond to the total number of
buyer-initiated trades, while the second variable is assumed to
correspond to the total number of seller-initiated trades. Each row or
observation correspond to a trading day. NA
values will be ignored.
The argument hyperparams
contains the hyperparameters of the ECM
algorithm. It is either empty or contains one or more of the following
elements:
maxeval
: (integer
) It stands for maximum number of iterations
of the ECM
for each initial parameter set. When missing, maxeval
takes the default value of 100
.
tolerance
(numeric
) The ECM
algorithm is stopped when the
(relative) change of log-likelihood is smaller than tolerance. When
missing, tolerance
takes the default value of 0.001
.
maxinit
: (integer
) It is the maximum number of initial
parameter sets used for the ECM
estimation per layer. When missing,
maxinit
takes the default value of 20
.
maxlayers
(integer
) It is the upper limit of number of layers
used in the ECM algorithm. To find the optimal number of layers, the ECM
algorithm will estimate a model for each value of the number of layers
between 1
and maxlayers
, and then picks the model that has the lowest
Bayes information criterion (BIC). When missing, maxlayers
takes the
default value of 8
.
Returns an integer corresponding to the number of layers detected in the data.
# There is a preloaded quarterly dataset called 'dailytrades' with 60
# observations. Each observation corresponds to a day and contains the
# total number of buyer-initiated trades ('B') and seller-initiated
# trades ('S') on that day. To know more, type ?dailytrades
xdata <- dailytrades
# Detect the number of layers present in the dataset 'dailytrades' using the
# different algorithms and display the results
e.layers <- detectlayers_e(xdata)
eg.layers <- detectlayers_eg(xdata)
em.layers <- detectlayers_ecm(xdata)
show(c(e = e.layers, eg = eg.layers, em = em.layers))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.