Estimates the Probability of Informed Trading (`PIN`

) using the
initial sets from the algorithm in
Ersan and Alici (2016)
.

## Arguments

- data
A dataframe with 2 variables: the first corresponds to buyer-initiated trades (buys), and the second corresponds to seller-initiated trades (sells).

- factorization
A character string from

`{"E", "EHO", "LK", "NONE"}`

referring to a given factorization. The default value is`"E"`

.- xtraclusters
An integer used to divide trading days into

`#(2 + xtraclusters)`

clusters, thereby resulting in`#comb(1 + xtraclusters, 1)`

initial parameter sets in line with Ersan and Alici (2016) . The default value is`4`

.- verbose
A binary variable that determines whether detailed information about the steps of the estimation of the PIN model is displayed. No output is produced when

`verbose`

is set to`FALSE`

. The default value is`TRUE`

.

## 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.

The factorization variable takes one of four values:

`"EHO"`

refers to the factorization in Easley et al. (2010)`"LK"`

refers to the factorization in Lin and Ke (2011)`"E"`

refers to the factorization in Ersan (2016)`"NONE"`

refers to the original likelihood function - with no factorization

The function `pin_ea()`

implements the algorithm detailed in
Ersan and Alici (2016)
.
The higher the number of the additional layers (`xtraclusters`

), the
better is the estimation. Ersan and Alici (2016)
,
however, have shown the benefit of increasing this number beyond 5 is
marginal, and statistically insignificant.

The function `initials_pin_ea()`

provides the initial parameter sets
obtained through the implementation of the
Ersan and Alici (2016)
algorithm.
For further information on the initial parameter set determination, see
`initials_pin_ea()`

.

## References

Easley D, Hvidkjaer S, Ohara M (2010).
“Factoring information into returns.”
*Journal of Financial and Quantitative Analysis*, **45**(2), 293--309.
ISSN 00221090.

Ersan O (2016).
“Multilayer Probability of Informed Trading.”
*Available at SSRN 2874420*.

Ersan O, Alici A (2016).
“An unbiased computation methodology for estimating the probability of informed trading (PIN).”
*Journal of International Financial Markets, Institutions and Money*, **43**, 74--94.
ISSN 10424431.

Lin H, Ke W (2011).
“A computing bias in estimating the probability of informed trading.”
*Journal of Financial Markets*, **14**(4), 625-640.
ISSN 1386-4181.

## 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
# Estimate the PIN model using the factorization of Ersan (2016), and initial
# parameter sets generated using the algorithm of Ersan and Alici (2016).
# The argument xtraclusters is omitted so will take its default value 4.
estimate <- pin_ea(xdata, verbose = FALSE)
# Display the estimated PIN value
show(estimate@pin)
#> [1] 0.5661721
# Display the estimated parameters
show(estimate@parameters)
#> alpha delta mu eps.b eps.s
#> 0.7499975 0.1333342 1193.5179655 357.2659099 328.6291793
# Store the initial parameter sets used for MLE in a dataframe variable,
# and display its first five rows
initialsets <- estimate@initialsets
show(head(initialsets, 5))
#> alpha delta mu eps.b eps.s
#> 1 0.7500000 0.13333333 1213.3422 336.1429 336.1852
#> 2 0.6333333 0.10526316 1262.0469 446.8846 356.4107
#> 3 0.5333333 0.09375000 1329.2577 531.6774 367.4561
#> 4 0.4833333 0.03448276 1364.5773 556.6875 399.6780
#> 5 0.1000000 0.00000000 928.7648 1076.1852 423.2833
```