Skip to contents

Computes, for each day in the sample, the posterior probability that the day is a no-information day, good-information day and bad-information day, respectively (Easley and Ohara (1992) , Easley et al. (1996) , Ersan (2016) ).

## Usage

get_posteriors(object)

## Arguments

object

(S4 object) an object of type estimate.pin, estimate.mpin, or estimate.mpin.ecm.

## Value

If the argument object is of type estimate.pin, returns a dataframe of three variables post.N, post.G and post.B containing in each row the posterior probability that a given day is a no-information day (N), good-information day (G), or bad-information day (B) respectively. If the argument object is of type estimate.mpin or estimate.mpin.ecm, with J layers, returns a dataframe of 2*J+1 variables Post.N, and Post.G[j] and Post.B[j] for each layer j containing in each row the posterior probability that a given day is a no-information day, good-information day in layer j or bad-information day in layer j, for each layer j respectively. If the argument object is of any other type, an error is returned.

## References

Easley D, Kiefer NM, Ohara M, Paperman JB (1996). “Liquidity, information, and infrequently traded stocks.” Journal of Finance, 51(4), 1405--1436. ISSN 00221082.

Easley D, Ohara M (1992). “Time and the Process of Security Price Adjustment.” The Journal of Finance, 47(2), 577--605. ISSN 15406261.

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

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

# ------------------------------------------------------------------------ #
# Posterior probabilities for PIN estimates                                #
# ------------------------------------------------------------------------ #

# Estimate PIN using the Ersan and Alici (2016) algorithm and the
# factorization Lin and Ke(2011).

estimate <- pin_ea(xdata, "LK", verbose = FALSE)

# Display the estimated PIN value

estimate@pin
#> [1] 0.5661721

# Store the posterior probabilities in a dataframe variable and display its
# first 6 rows.

modelposteriors <- get_posteriors(estimate)
show(round(head(modelposteriors), 3))
#>   post.N post.G post.B
#> 1      1      0      0
#> 2      0      1      0
#> 3      0      1      0
#> 4      0      1      0
#> 5      0      1      0
#> 6      0      1      0

# ------------------------------------------------------------------------ #
# Posterior probabilities for MPIN estimates                               #
# ------------------------------------------------------------------------ #

# Estimate MPIN via the ECM algorithm, assuming that the dataset has 2
# information layers

estimate <- mpin_ecm(xdata, layers = 2, verbose = FALSE)

# Display the estimated Multilayer PIN value

show(estimate@mpin)
#> [1] 0.576684

# Store the posterior probabilities in a dataframe variable and display its
# first six rows. The posterior probabilities are contained in a dataframe
# with 7 variables: one for no-information days, and two variables for each
# layer, one for good-information days and one for bad-information days.

modelposteriors <- get_posteriors(estimate)
show(round(head(modelposteriors), 3))
#>   post.N post.G[1] post.G[2] Post.B[1] Post.B[2]
#> 1      1         0         0         0         0
#> 2      0         1         0         0         0
#> 3      0         1         0         0         0
#> 4      0         1         0         0         0
#> 5      0         1         0         0         0
#> 6      0         1         0         0         0