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 trades ('B') and seller-initiated
# trades ('S') on that day. To know more, type ?dailytrades
xdata <- dailytrades
# The function pin_yz() allows the user to directly estimate the PIN model
# using the full set of initial parameter sets generated using the algorithm
# of Yan and # Zhang (2012).
# \donttest{
estimate.1 <- pin_yz(xdata, verbose = FALSE)
# }
# Obtaining the set of initial parameter sets using initials_pin_yz allows
# us to estimate the PIN model using a subset of these initial sets.
initparams <- initials_pin_yz(xdata, verbose = FALSE)
# Use 10 randonly chosen initial sets from the dataframe 'initparams' in
# order to estimate the PIN model using the function pin() with custom
# initial parameter sets
numberofsets <- nrow(initparams)
selectedsets <- initparams[sample(numberofsets, 10),]
estimate.2 <- pin(xdata, initialsets = selectedsets, verbose = FALSE)
# Compare the parameters and the pin values of both specifications
# \donttest{
comparison <- rbind(c(estimate.1@parameters, pin = estimate.1@pin),
c(estimate.2@parameters, estimate.2@pin))
rownames(comparison) <- c("all", "10")
show(comparison)
#> alpha delta mu eps.b eps.s pin
#> all 0.7500027 0.1333335 1193.518 357.2654 328.6293 0.5661740
#> 10 0.7499982 0.1333331 1193.518 357.2658 328.6293 0.5661723
# }