Core function for optimization routines
pin_est_core(numbuys = NULL, numsells = NULL,
factorization = "Lin_Ke", init_vals = NULL, lower = rep(0, 5),
upper = c(1, 1, rep(Inf, 3)), num_best_res = 1,
only_converged = TRUE, nlminb_control = list(), confint = FALSE,
ci_control = list(), posterior = TRUE)
numeric: vector of daily buys
numeric: vector of daily sells
character: factorization of likelihood function: either 'EHO' or 'Lin_Ke', defaults to: 'Lin_Ke'
numeric: matrix of initial values: either generated by initial_vals
or
user-defined matrix with five columns for which colnames must consist of:
alpha
, delta
, epsilon_b
, epsilon_s
, mu
numeric: lower bounds for optimization, must have length of 5
numeric: upper bounds for optimization, must have length of 5
Number of optimization runs for which results should be returned, either numeric or 'all',
only relevant if init_vals
= 'Grid', defaults to 1
logical: Return only results for which the likelihood converged?
Defaults to TRUE
list: Control list for nlminb
logical: Compute confidence intervals for PIN?
Defaults to FALSE
list: see Details
logical: Should posterior probabilities for conditions of trading days be computed?
If num_best_res
= 1, a list with following elements is returned:
Matrix containing the parameter estimates as well as their estimated standard errors, t-values and p-values.
Value of likelihood function returned by nlminb
Estimated probability of informed trading
Convergence code for nlminb optimization
Convergence message returned by the nlminb optimizer
Number of iterations until convergence of nlminb optimizer
Vector of initial values
If confint = TRUE
; confidence interval for the probability of informed trading
If num_best_res
> 1, a named list of lists is returned. Each component of the outer list
is again a list structured as shown above.
Naming scheme for the outer list is 'Best1',..., 'Bestnum_best_res
'.
Grants the most control over optimization procedure.
User-friendly wrappers for estimation with trading data of arbitrary length and quarterly data
are implemented with pin_est
and qpin
, respectively.
nlminb
function in the stats package is used for maximization.
Vectors for numbuys
and numsells
need to have same length.
Confidence intervals for the probability of informed trading are calculated via Monte-Carlo-Simulation
if confint = TRUE
. Settings of the confidence interval simulation can be specified via a named list for ci_control
.
Valid list names are n
, seed
, level
and ncores
which pass
number of simulation runs (defaults to 10000), seed for RNG (defaults to seed = NULL
),
confidence level (defaults to 0.95) and number of cpu cores utilized (defaults to 1).
Easley, David et al. (2002) Is Information Risk a Determinant of Asset Returns? The Journal of Finance, Volume 57, Number 5, pp. 2185 - 2221 10.1111/1540-6261.00493
Easley, David et al. (1996) Liquidity, Information, and Infrequently Traded Stocks The Journal of Finance, Volume 51, Number 4, pp. 1405 - 1436 10.1111/j.1540-6261.1996.tb04074.x
Easley, David et al. (2010) Factoring Information into Returns Journal of Financial and Quantitative Analysis, Volume 45, Issue 2, pp. 293 - 309 10.1017/S0022109010000074
Ersan, Oguz and Alici, Asli (2016) An unbiased computation methodology for estimating the probability of informed trading (PIN) Journal of International Financial Markets, Institutions and Money, Volume 43, pp. 74 - 94 10.1016/j.intfin.2016.04.001
Gan, Quan et al. (2015) A faster estimation method for the probability of informed trading using hierarchical agglomerative clustering Quantitative Finance, Volume 15, Issue 11, pp. 1805 - 1821 10.1080/14697688.2015.1023336
Lin, Hsiou-Wei William and Ke, Wen-Chyan (2011) A computing bias in estimating the probability of informed trading Journal of Financial Markets, Volume 14, Issue 4, pp. 625 - 640 10.1016/j.finmar.2011.03.001
Revolution Analytics and Steve Weston (2015) doParallel: Foreach Parallel Adaptor for the 'parallel' Package R package version 1.0.10
Revolution Analytics and Steve Weston (2015) foreach: Provides Foreach Looping Construct for R R package version 1.4.3 Yan, Yuxing and Zhang, Shaojun (2012) An improved estimation method and empirical properties of the probability of informed trading Journal of Banking & Finance, Volume 36, Issue 2, pp. 454 - 467 10.1016/j.jbankfin.2011.08.003
# NOT RUN {
# Loading simulated data for frequently traded stock
data("BSfrequent")
# Generate several matrices of initial values utilizing all methods implemented
inits_grid <- initial_vals(numbuys = BSfrequent[,"Buys"],
numsells = BSfrequent[,"Sells"],
method = "Grid")
inits_hac <- initial_vals(numbuys = BSfrequent[,"Buys"],
numsells = BSfrequent[,"Sells"],
method = "HAC")
inits_hac_ref <- initial_vals(numbuys = BSfrequent[,"Buys"],
numsells = BSfrequent[,"Sells"],
method = "HAC_Ref")
# Optimization with different matrices of initial values
pin_core_grid <- pin_est_core(numbuys = BSfrequent[,"Buys"],
numsells = BSfrequent[,"Sells"],
factorization = "Lin_Ke", init_vals = inits_grid,
lower = rep(0,5), upper = c(1,1, rep(Inf,3)),
num_best_res = 5)
pin_core_hac <- pin_est_core(numbuys = BSfrequent[,"Buys"],
numsells = BSfrequent[,"Sells"],
factorization = "Lin_Ke", init_vals = inits_hac,
lower = rep(0,5), upper = c(1,1, rep(Inf,3)))
pin_core_hac_ref <- pin_est_core(numbuys = BSfrequent[,"Buys"],
numsells = BSfrequent[,"Sells"],
factorization = "Lin_Ke", init_vals = inits_hac_ref,
lower = rep(0,5), upper = c(1,1, rep(Inf,3)))
# }
# NOT RUN {
pin_core_hac <- pin_est_core(numbuys = BSfrequent[,"Buys"],
numsells = BSfrequent[,"Sells"],
factorization = "Lin_Ke", init_vals = inits_hac,
lower = rep(0,5), upper = c(1,1, rep(Inf,3)),
confint = TRUE)
# }
Run the code above in your browser using DataLab