initials_pin_ea | R Documentation |
Based on the algorithm in Ersan and Alici (2016),
generates initial parameter sets for the maximum likelihood
estimation of the PIN
model.
initials_pin_ea(data, xtraclusters = 4, verbose = TRUE)
data |
A dataframe with 2 variables: the first corresponds to buyer-initiated trades (buys), and the second corresponds to seller-initiated trades (sells). |
xtraclusters |
An integer used to divide trading days into
|
verbose |
a binary variable that determines whether information messages
about the initial parameter sets, including the number of the initial
parameter sets generated. No message is shown when |
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 function initials_pin_ea()
uses a hierarchical agglomerative
clustering (HAC) to find initial parameter sets for
the maximum likelihood estimation. The steps in
\insertCiteErsanAlici2016;textualPINstimation algorithm differ from those
used by \insertCiteGan2015;textualPINstimation, and are summarized below.
Via the use of HAC, daily absolute order imbalances (AOIs) are grouped in
2+J
(default J=4
) clusters. After sorting the clusters based on
AOIs, they are combined into two larger groups of days (event and no-event)
by merging neighboring clusters with each other. Consequently, those groups
are formed in #comb(5, 1) = 5
different ways. For each of the 5
configurations with which, days are grouped into two (event group and
no-event group), the procedure below is applied to obtain initial parameter
sets.
Days in the event group (the one with larger mean AOI) are distributed into
two groups, i.e. good-event days (days with positive OI) and bad-event days
(days with negative OI).
Initial parameters are obtained from the frequencies, and average trade
rates of three types of days. See
\insertCiteErsanAlici2016;textualPINstimation for further details.
The higher the number of the additional clusters (xtraclusters
), the
better is the estimation. \insertCiteErsanAlici2016;textualPINstimation,
however, have shown the benefit of increasing this number beyond 4 is
marginal, and statistically insignificant.
Returns a dataframe of initial sets each consisting of five
variables {\alpha
, \delta
, \mu
, \eb, \es}.
# 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
# Obtain a dataframe of initial parameters for the maximum likelihood
# estimation using the algorithm of Ersan and Alici (2016).
init.sets <- initials_pin_ea(xdata)
# Use the obtained dataframe to estimate the PIN model using the function
# pin() with custom initial parameter sets
estimate.1 <- pin(xdata, initialsets = init.sets, verbose = FALSE)
# pin_ea() directly estimates the PIN model using initial parameter sets
# generated using the algorithm of Ersan & Alici (2016).
estimate.2 <- pin_ea(xdata, verbose = FALSE)
# Check that the obtained results are identical
show(estimate.1@parameters)
show(estimate.2@parameters)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.