Based on the grid search algorithm of
Yan and Zhang (2012)
, generates
initial parameter sets for the maximum likelihood estimation of the PIN
model.
Arguments
- data
A dataframe with 2 variables: the first corresponds to buyer-initiated trades (buys), and the second corresponds to seller-initiated trades (sells).
- grid_size
An integer between
1
, and20
; representing the size of the grid. The default value is5
. See more in details.- ea_correction
A binary variable determining whether the modifications of the algorithm of Yan and Zhang (2012) suggested by Ersan and Alici (2016) are implemented. The default value is
FALSE
.- 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
verbose
is set toFALSE
. The default value isTRUE
.
Value
Returns a dataframe of initial sets each consisting of five variables {\(\alpha\), \(\delta\), \(\mu\), \(\epsilon\)b, \(\epsilon\)s}.
Details
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 grid_size
determines the size of the grid of the variables:
alpha
, delta
, and eps.b
. If grid_size
is set to a given value m
,
the algorithm creates a sequence starting from 1/2m
, and ending in
1 - 1/2m
, with a step of 1/m
. The default value of 5
corresponds
to the size of the grid in Yan and Zhang (2012)
.
In that case, the sequence starts at 0.1 = 1/(2 x 5)
, and ends in
0.9 = 1 - 1/(2 x 5)
with a step of 0.2 = 1/m
.
The function initials_pin_yz()
implements, by default, the original
Yan and Zhang (2012)
algorithm as the default value of
ea_correction
takes the value FALSE
.
When the value of ea_correction
is set to TRUE
; then, sets
with irrelevant mu
values are excluded, and sets with boundary values are
reintegrated in the initial parameter sets.
References
Ersan O, Alici A (2016).
“An unbiased computation methodology for estimating the probability of informed trading (PIN).”
Journal of International Financial Markets, Institutions and Money, 43, 74--94.
ISSN 10424431.
Yan Y, Zhang S (2012).
“An improved estimation method and empirical properties of the probability of informed trading.”
Journal of Banking and Finance, 36(2), 454--467.
ISSN 03784266.
Examples
# 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 transactions ('B') and seller-initiated
# transactions ('S') on that day. To know more, type ?dailytrades
xdata <- dailytrades
# Obtain the initial parameter set for the maximum likelihood estimation
# using the algorithm of Yan and Zhang (2012).
initparams <- initials_pin_yz(xdata)
#> 65 initial sets have been deleted because they contained negative values for eps.s!
#> The function initials_pin_yz(...) has generated 60 initial parameter sets.
#>
To display the initial sets, store them in a variable or call (initials_pin_yz(...)).
#>
To hide these messages, set the argument 'silent' to TRUE (silent = TRUE).
#>
# Use the obtained dataframe to estimate the PIN model using the function
# pin() with custom initial parameter sets
estimate.1 <- pin(xdata, initialsets = initparams, verbose = FALSE)
# pin_yz() directly estimates the PIN model using initial parameter sets
# generated using the algorithm of Yan and Zhang (2012).
estimate.2 <- pin_yz(xdata, verbose = FALSE)
# Check that the obtained results are identical
show(estimate.1@parameters)
#> alpha delta mu eps.b eps.s
#> 0.7500027 0.1333335 1193.5179578 357.2654415 328.6292757
show(estimate.2@parameters)
#> alpha delta mu eps.b eps.s
#> 0.7500027 0.1333335 1193.5179578 357.2654415 328.6292757