initials_pin_gwj {PINstimation} | R Documentation |
Initial parameter set of Gan et al.(2015)
Description
Based on the algorithm in
Gan et al. (2015), generates an initial parameter
set for the maximum likelihood estimation of the PIN
model.
Usage
initials_pin_gwj(data, verbose = TRUE)
Arguments
data |
A dataframe with 2 variables: the first corresponds to buyer-initiated trades (buys), and the second corresponds to seller-initiated trades (sells). |
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 |
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.
Value
Returns a dataframe containing numerical vector of five elements
{\alpha
, \delta
, \mu
, \epsilon
b, \epsilon
s}.
References
Gan Q, Wei WC, Johnstone D (2015). “A faster estimation method for the probability of informed trading using hierarchical agglomerative clustering.” Quantitative Finance, 15(11), 1805–1821.
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
# Obtain the initial parameter set for the maximum likelihood estimation
# using the algorithm of Gan et al.(2015).
initparams <- initials_pin_gwj(xdata)
# 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_gwj() directly estimates the PIN model using an initial parameter set
# generated using the algorithm of Gan et al.(2015).
estimate.2 <- pin_gwj(xdata, "E", verbose = FALSE)
# Check that the obtained results are identical
show(estimate.1@parameters)
show(estimate.2@parameters)