initials_pin_yz | R Documentation |
Based on the grid search algorithm of
\insertCiteYan2012;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)
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 |
ea_correction |
A binary variable determining whether the
modifications of the algorithm of \insertCiteYan2012;textualPINstimation
suggested by \insertCiteErsanAlici2016;textualPINstimation are
implemented. The default value is |
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 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 \insertCiteYan2012;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
\insertCiteYan2012;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.
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
# 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).
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
comparison <- rbind(c(estimate.1@parameters, pin = estimate.1@pin),
c(estimate.2@parameters, estimate.2@pin))
rownames(comparison) <- c("all", "10")
show(comparison)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.