Skip to contents

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 verbose is set to FALSE. The default value is TRUE.

Value

Returns a dataframe containing numerical vector of five elements {\(\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.

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)
#> The function initials_pin_gwj(...) has generated 1 initial parameter sets.
#> 
To display them, either store them in a variable or call (initials_pin_gwj(...)). 
#> 
To hide these messages, set the argument 'verbose' to FALSE.
#> 

# 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)
#>        alpha        delta           mu        eps.b        eps.s 
#>    0.5833376    0.1714269 1197.2546207  554.0730552  328.5610583 
show(estimate.2@parameters)
#>        alpha        delta           mu        eps.b        eps.s 
#>    0.5833376    0.1714269 1197.2546207  554.0730552  328.5610583