adjpin {PINstimation} | R Documentation |
Estimation of adjusted PIN model
Description
Estimates the Adjusted Probability of Informed Trading
(adjPIN
) as well as the Probability of Symmetric Order-flow Shock
(PSOS
) from the AdjPIN
model of Duarte and Young(2009).
Usage
adjpin(data, method = "ECM", initialsets = "GE", num_init = 20,
restricted = list(), ..., 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). |
method |
A character string referring to the method
used to estimate the model of Duarte and Young (2009).
It takes one of two values: |
initialsets |
It can either be a character string referring to
prebuilt algorithms generating initial parameter sets or a dataframe
containing custom initial parameter sets.
If |
num_init |
An integer specifying the maximum number of
initial parameter sets to be used in the estimation.
If |
restricted |
A binary list that allows estimating restricted
AdjPIN models by specifying which model parameters are assumed to be equal.
It contains one or multiple of the following four elements
|
... |
Additional arguments passed on to the function |
verbose |
A binary variable that determines whether
detailed information about the steps of the estimation of the AdjPIN model
is displayed. No output is produced 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.
If initialsets
is neither a dataframe, nor a character string from the
set {"GE",
"CL",
"RANDOM"}
, the estimation of the AdjPIN
model is
aborted. The default initial parameters ("GE"
) for the estimation
method are generated using a modified hierarchical agglomerative
clustering. For more information, see initials_adjpin()
.
The argument hyperparams
contains the hyperparameters of the ECM
algorithm. It is either empty or contains one or two of the following
elements:
-
maxeval
: (integer
) It stands for maximum number of iterations of theECM
algorithm for each initial parameter set. When missing,maxeval
takes the default value of100
. -
tolerance
(numeric
) TheECM
algorithm is stopped when the (relative) change of log-likelihood is smaller than tolerance. When missing,tolerance
takes the default value of0.001
.
Value
Returns an object of class estimate.adjpin
.
References
Cheng T, Lai H (2021).
“Improvements in estimating the probability of informed trading models.”
Quantitative Finance, 21(5), 771-796.
Duarte J, Young L (2009).
“Why is PIN priced?”
Journal of Financial Economics, 91(2), 119–138.
ISSN 0304405X.
Ersan O, Ghachem M (2022b).
“A methodological approach to the computational problems in the estimation of adjusted PIN model.”
Available at SSRN 4117954.
Ghachem M, Ersan O (2022a).
“Estimation of the probability of informed trading models via an expectation-conditional maximization algorithm.”
Available at SSRN 4117952.
Ghachem M, Ersan O (2022b).
“PINstimation: An R package for estimating models of probability of informed trading.”
Available at SSRN 4117946.
Examples
# We use 'generatedata_adjpin()' to generate a S4 object of type 'dataset'
# with 60 observations.
sim_data <- generatedata_adjpin(days = 60)
# The actual dataset of 60 observations is stored in the slot 'data' of the
# S4 object 'sim_data'. Each observation corresponds to a day and contains
# the total number of buyer-initiated transactions ('B') and seller-
# initiated transactions ('S') on that day.
xdata <- sim_data@data
# ------------------------------------------------------------------------ #
# Compare the unrestricted AdjPIN model with various restricted models #
# ------------------------------------------------------------------------ #
# Estimate the unrestricted AdjPIN model using the ECM algorithm (default),
# and show the estimation output
estimate.adjpin.0 <- adjpin(xdata, verbose = FALSE)
show(estimate.adjpin.0)
# Estimate the restricted AdjPIN model where mub=mus
estimate.adjpin.1 <- adjpin(xdata, restricted = list(mu = TRUE),
verbose = FALSE)
# Estimate the restricted AdjPIN model where eps.b=eps.s
estimate.adjpin.2 <- adjpin(xdata, restricted = list(eps = TRUE),
verbose = FALSE)
# Estimate the restricted AdjPIN model where d.b=d.s
estimate.adjpin.3 <- adjpin(xdata, restricted = list(d = TRUE),
verbose = FALSE)
# Compare the different values of adjusted PIN
estimates <- list(estimate.adjpin.0, estimate.adjpin.1,
estimate.adjpin.2, estimate.adjpin.3)
adjpins <- sapply(estimates, function(x) x@adjpin)
psos <- sapply(estimates, function(x) x@psos)
summary <- cbind(adjpins, psos)
rownames(summary) <- c("unrestricted", "same.mu", "same.eps", "same.d")
show(round(summary, 5))