estimate_mlekop: Estimates the probability of informed trading with maximum...

Description Usage Arguments Details Value References See Also Examples

Description

Calling estimate_mlekop() estimates the parameters from the model of Easley et al. (1996, EKOP) together with the probability of informed trading (PIN). As described in the EKOP model trade data for buy and sell trades are needed, respectively. Note that in contrast the compressed EKOP model needs only data for the number of trades per day (see the function references below).

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
estimate_mlekop(
  data,
  startpar,
  T = 390,
  methodLik = c("precise", "approx"),
  fnLik = c("compute_ekop_lik", "compute_ekop_orig_lik"),
  fnscale = -1,
  trace = 0,
  grad_free = TRUE,
  return_opt = FALSE,
  opt_out = TRUE
)

Arguments

data

A data.frame containing the number of buyer- and seller-initiated trades. The data must be ordered in columns beginning with the number of mis-specified buys, mis-specified sells, number of buys, number of sells, and finally the sum of trades per day. See for an example simulate_ekop().

startpar

A vector containing start parameters for maximum likelihood estimation. These must be starting values for the logit of alpha, epsilon, the logit of delta, and mu. If no starting values are provided the function chooses the values (0, mean(trades)x.75/2, 0, mean(trades)x.25/2).

T

A double specifying the minutes of a trading day.

methodLik

A character specifying, if undefined function values in optimization should be approximated by large defined values (1e+6). This can help to make maximum likelihood estimation more stable.

fnLik

A character specifying which likelihood function to use. Either the original function by Easley et al. (1996) or the slightly modified variant of Easley et al. (2002) can be used. The latter one is known to also work better with large trading volumes.

fnscale

A negatve double specifying a scaling factor for the likelihood function. This can in some cases help when the algorithm does not reach convergence or suffer from number overflow.

trace

An integer specifying which level of tracing should be used. see ?optim for more details.

grad_free

A logical indicating if gradient-free optimization should be used when gradient descent did not converge. If TRUE the optimization procedure nmkb is used.

return_opt

A logical indicating, if in addition to the PIN estimates also the results from the optimization procedure should be returned. If TRUE a list is returned with an element pin_estimates holding the PIN estimates and an element opt_results holding the output of the optimization procedure.

opt_out

(Deprecated) A logical indicating if only the output of the optimization procedure should be returned. Some older applications still rely on this output. In the next version this feature will be removed. Note that the default value is TRUE.

Details

Maximum Likelihood functions

There exist different likelihood variants that can be used in maximum likelihood estimation of the EKOP model.

Optimization algorithms

Optimization is performed gradient-based by using the optim function. The algorithm used is the L-BFGS-B that allows for parameter restrictions. This is necessary because we use for the probabilities alpha and delta the logistic transformation exp()/(1+exp()) to produce valid probabilities in optimization.

In case that the gradient-based algorithm does not converge in between 100 steps, a gradient-free optimization is applied. For gradient-free optimization nmkb, a bounded Nelder-Mead algorithm is used. Derivative-free optimization is only performed after gradient-based optimization did not converge and the argument grad_free is TRUE.

The argument fnscale can be used to scale the likelihood function in case of very large values (e.g. very large volumes) that might lead to number overflow during computation. Note, fnscale must always be negative as the likelihood function should be maximized.

Value

A list with all components as returned by optim or nmkb.

References

See Also

Examples

1
2
3
4
5
6
# Simulate data from the EKOP model. 
trades_data <- simulate_ekop()
# Estimate the EKOP model by maximum likelihood.
pin_estml <- estimate_mlekop(trades_data, methodLik="approx", 
                             fnLik="compute_ekop_orig_lik", opt_out=FALSE)
                   

simonsays1980/bayespin documentation built on Dec. 23, 2021, 2:25 a.m.