
Last chance! 50% off unlimited learning
Sale ends in
Based on the grid search algorithm of
Yan2012;textualPINstimation, generates
initial parameter sets for the maximum likelihood estimation of the PIN
model.
initials_pin_yz(data, grid_size = 5, ea_correction = FALSE,
verbose = TRUE)
Returns a dataframe of initial sets each consisting of five
variables {
A dataframe with 2 variables: the first corresponds to buyer-initiated trades (buys), and the second corresponds to seller-initiated trades (sells).
An integer between 1
, and 20
;
representing the size of the grid. The default value is 5
. See
more in details.
A binary variable determining whether the
modifications of the algorithm of Yan2012;textualPINstimation
suggested by ErsanAlici2016;textualPINstimation are
implemented. The default value is FALSE
.
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
to FALSE
. The default value is TRUE
.
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 Yan2012;textualPINstimation.
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
Yan2012;textualPINstimation 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.
# 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)
# }
Run the code above in your browser using DataLab