Layer detection in trade-dataSource:
Detects the number of information layers present in trade-data using the algorithms in Ersan (2016) , Ersan and Ghachem (2022a) , and Ghachem and Ersan (2022a) .
detectlayers_e(data, confidence = 0.995, correction = TRUE) detectlayers_eg(data, confidence = 0.995) detectlayers_ecm(data, hyperparams = list())
A dataframe with 2 variables: the first corresponds to buyer-initiated trades (buys), and the second corresponds to seller-initiated trades (sells).
A number from
(0.5,1), corresponding to the range of the confidence interval used to determine whether a given cluster is compact, and therefore can be considered an information layer. If all values of absolute order imbalances (AOI) within a given cluster are within the confidence interval of a Skellam distribution with level equal to
'confidence', and centered on the mean of AOI, then the cluster is considered compact, and, therefore, an information layer. If some observations are outside the confidence interval, then the data is clustered further. The default value is
[i]This is an argument of the functions
A binary variable that determines whether the data will be adjusted prior to implementing the algorithm of Ersan (2016) . The default value is
A list containing the hyperparameters of the
ECMalgorithm. When not empty, it contains one or more of the following elements:
maxlayers. More about these elements are found in the Details section.
[i]This is an argument of the function
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.
hyperparams contains the hyperparameters of the
algorithm. It is either empty or contains one or more of the following
integer) It stands for maximum number of iterations of the
ECMfor each initial parameter set. When missing,
maxevaltakes the default value of
ECMalgorithm is stopped when the (relative) change of log-likelihood is smaller than tolerance. When missing,
tolerancetakes the default value of
integer) It is the maximum number of initial parameter sets used for the
ECMestimation per layer. When missing,
maxinittakes the default value of
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
maxlayers, and then picks the model that has the lowest Bayes information criterion (BIC). When missing,
maxlayerstakes the default value of
Ersan O (2016).
“Multilayer Probability of Informed Trading.”
Available at SSRN 2874420.
Ersan O, Ghachem M (2022a). “Identifying information types in probability of informed trading (PIN) models: An improved algorithm.” Available at SSRN 4117956.
Ghachem M, Ersan O (2022a). “Estimation of the probability of informed trading models via an expectation-conditional maximization algorithm.” Available at SSRN 4117952.
# 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)) #> e eg em #> 3 3 3